LCOV - code coverage report
Current view: top level - sfx2/source/appl - sfxhelp.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 227 392 57.9 %
Date: 2012-08-25 Functions: 24 37 64.9 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 265 1053 25.2 %

           Branch data     Line data    Source code
       1                 :            : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2                 :            : /*
       3                 :            :  * This file is part of the LibreOffice project.
       4                 :            :  *
       5                 :            :  * This Source Code Form is subject to the terms of the Mozilla Public
       6                 :            :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7                 :            :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8                 :            :  *
       9                 :            :  * This file incorporates work covered by the following license notice:
      10                 :            :  *
      11                 :            :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12                 :            :  *   contributor license agreements. See the NOTICE file distributed
      13                 :            :  *   with this work for additional information regarding copyright
      14                 :            :  *   ownership. The ASF licenses this file to you under the Apache
      15                 :            :  *   License, Version 2.0 (the "License"); you may not use this file
      16                 :            :  *   except in compliance with the License. You may obtain a copy of
      17                 :            :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18                 :            :  */
      19                 :            : 
      20                 :            : #include "sfx2/sfxhelp.hxx"
      21                 :            : 
      22                 :            : #include <set>
      23                 :            : #include <algorithm>
      24                 :            : #include <com/sun/star/uno/Reference.h>
      25                 :            : #include <com/sun/star/frame/XFrame.hpp>
      26                 :            : #include <com/sun/star/frame/XComponentLoader.hpp>
      27                 :            : #include <com/sun/star/lang/XComponent.hpp>
      28                 :            : #include <comphelper/processfactory.hxx>
      29                 :            : #include <com/sun/star/awt/XWindow.hpp>
      30                 :            : #include <com/sun/star/awt/XTopWindow.hpp>
      31                 :            : #include <com/sun/star/awt/PosSize.hpp>
      32                 :            : #include <com/sun/star/frame/XDesktop.hpp>
      33                 :            : #include <com/sun/star/util/URLTransformer.hpp>
      34                 :            : #include <com/sun/star/util/XURLTransformer.hpp>
      35                 :            : #include <com/sun/star/frame/XDispatch.hpp>
      36                 :            : #include <com/sun/star/frame/XDispatchProvider.hpp>
      37                 :            : #include <com/sun/star/container/XNameAccess.hpp>
      38                 :            : #include <com/sun/star/beans/XPropertySet.hpp>
      39                 :            : #include <com/sun/star/frame/FrameSearchFlag.hpp>
      40                 :            : #include <toolkit/helper/vclunohelper.hxx>
      41                 :            : #include <com/sun/star/frame/XModuleManager.hpp>
      42                 :            : #include <com/sun/star/system/XSystemShellExecute.hpp>
      43                 :            : #include <com/sun/star/system/SystemShellExecuteFlags.hpp>
      44                 :            : #include <unotools/configmgr.hxx>
      45                 :            : #include <unotools/configitem.hxx>
      46                 :            : #include <svtools/helpopt.hxx>
      47                 :            : #include <unotools/moduleoptions.hxx>
      48                 :            : #include <tools/urlobj.hxx>
      49                 :            : #include <ucbhelper/content.hxx>
      50                 :            : #include <unotools/pathoptions.hxx>
      51                 :            : #include <rtl/ustring.hxx>
      52                 :            : #include <osl/process.h>
      53                 :            : #include <osl/file.hxx>
      54                 :            : #include <unotools/bootstrap.hxx>
      55                 :            : #include <rtl/uri.hxx>
      56                 :            : #include <vcl/msgbox.hxx>
      57                 :            : #include <svtools/ehdl.hxx>
      58                 :            : #include <svtools/sfxecode.hxx>
      59                 :            : 
      60                 :            : #include "newhelp.hxx"
      61                 :            : #include <sfx2/objsh.hxx>
      62                 :            : #include <sfx2/docfac.hxx>
      63                 :            : #include "sfx2/sfxresid.hxx"
      64                 :            : #include "helper.hxx"
      65                 :            : #include "app.hrc"
      66                 :            : #include <sfx2/sfxuno.hxx>
      67                 :            : #include <vcl/svapp.hxx>
      68                 :            : #include <sfx2/frame.hxx>
      69                 :            : #include <rtl/strbuf.hxx>
      70                 :            : #include <rtl/string.hxx>
      71                 :            : 
      72                 :            : using namespace ::com::sun::star::beans;
      73                 :            : using namespace ::com::sun::star::frame;
      74                 :            : using namespace ::com::sun::star::uno;
      75                 :            : using namespace ::com::sun::star::util;
      76                 :            : using namespace ::com::sun::star::frame;
      77                 :            : using namespace ::com::sun::star::lang;
      78                 :            : using namespace ::com::sun::star::system;
      79                 :            : 
      80         [ #  # ]:          0 : class NoHelpErrorBox : public ErrorBox
      81                 :            : {
      82                 :            : public:
      83                 :            :     NoHelpErrorBox( Window* _pParent );
      84                 :            : 
      85                 :            :     virtual void    RequestHelp( const HelpEvent& rHEvt );
      86                 :            : };
      87                 :            : 
      88                 :          0 : NoHelpErrorBox::NoHelpErrorBox( Window* _pParent ) :
      89                 :            : 
      90 [ #  # ][ #  # ]:          0 :     ErrorBox( _pParent, WB_OK, SfxResId( RID_STR_HLPFILENOTEXIST ).toString() )
         [ #  # ][ #  # ]
      91                 :            : {
      92                 :            :     // Error message: "No help available"
      93                 :          0 : }
      94                 :            : 
      95                 :          0 : void NoHelpErrorBox::RequestHelp( const HelpEvent& )
      96                 :            : {
      97                 :            :     // do nothing, because no help available
      98                 :          0 : }
      99                 :            : 
     100                 :            : #define STARTERLIST 0
     101                 :            : 
     102                 :            : static bool impl_hasHelpInstalled( const rtl::OUString &rLang );
     103                 :            : 
     104                 :            : /// Return the locale we prefer for displaying help
     105                 :        809 : static rtl::OUString HelpLocaleString()
     106                 :            : {
     107 [ +  + ][ +  - ]:        809 :     static rtl::OUString aLocaleStr;
     108         [ +  + ]:        809 :     if (aLocaleStr.isEmpty())
     109                 :            :     {
     110                 :        233 :         const rtl::OUString aEnglish( "en"  );
     111                 :            :         // detect installed locale
     112         [ +  - ]:        233 :         aLocaleStr = utl::ConfigManager::getLocale();
     113                 :        233 :         bool bOk = !aLocaleStr.isEmpty();
     114         [ +  + ]:        233 :         if ( !bOk )
     115                 :         75 :             aLocaleStr = aEnglish;
     116                 :            :         else
     117                 :            :         {
     118                 :        158 :             rtl::OUString aBaseInstallPath;
     119         [ +  - ]:        158 :             utl::Bootstrap::locateBaseInstallation(aBaseInstallPath);
     120                 :            :             static const char *szHelpPath = "/help/";
     121                 :            : 
     122                 :            :             rtl::OUString sHelpPath = aBaseInstallPath +
     123                 :        158 :                 rtl::OUString::createFromAscii(szHelpPath) + aLocaleStr;
     124                 :        158 :             osl::DirectoryItem aDirItem;
     125                 :            : 
     126 [ +  - ][ +  - ]:        158 :             if (!osl::DirectoryItem::get(sHelpPath, aDirItem) == osl::FileBase::E_None)
     127                 :            :             {
     128                 :        158 :                 bOk = false;
     129         [ +  - ]:        158 :                 String sLang(aLocaleStr);
     130         [ +  - ]:        158 :                 xub_StrLen nSepPos = sLang.Search( '-' );
     131         [ +  - ]:        158 :                 if (nSepPos != STRING_NOTFOUND)
     132                 :            :                 {
     133                 :        158 :                     bOk = true;
     134 [ +  - ][ +  - ]:        158 :                     sLang = sLang.Copy( 0, nSepPos );
                 [ +  - ]
     135                 :            :                     sHelpPath = aBaseInstallPath +
     136         [ +  - ]:        158 :                         rtl::OUString::createFromAscii(szHelpPath) + sLang;
     137 [ -  + ][ +  - ]:        158 :                     if (!osl::DirectoryItem::get(sHelpPath, aDirItem) == osl::FileBase::E_None)
     138                 :          0 :                         bOk = false;
     139         [ +  - ]:        158 :                 }
     140         [ +  - ]:        158 :             }
     141                 :            :         }
     142                 :            :         // if not OK, and not even English installed, we use online help, and
     143                 :            :         // have to preserve the full locale name
     144 [ +  + ][ +  - ]:        233 :         if ( !bOk && impl_hasHelpInstalled( aEnglish ) )
         [ -  + ][ -  + ]
     145                 :        233 :             aLocaleStr = aEnglish;
     146                 :            :     }
     147                 :        809 :     return aLocaleStr;
     148                 :            : }
     149                 :            : 
     150                 :        651 : void AppendConfigToken( String& rURL, sal_Bool bQuestionMark, const rtl::OUString &rLang )
     151                 :            : {
     152                 :        651 :     ::rtl::OUString aLocaleStr( rLang );
     153         [ +  + ]:        651 :     if ( aLocaleStr.isEmpty() )
     154         [ +  - ]:        576 :         aLocaleStr = HelpLocaleString();
     155                 :            : 
     156                 :            :     // query part exists?
     157         [ +  - ]:        651 :     if ( bQuestionMark )
     158                 :            :         // no, so start with '?'
     159         [ +  - ]:        651 :         rURL += '?';
     160                 :            :     else
     161                 :            :         // yes, so only append with '&'
     162         [ #  # ]:          0 :         rURL += '&';
     163                 :            : 
     164                 :            :     // set parameters
     165 [ +  - ][ +  - ]:        651 :     rURL += DEFINE_CONST_UNICODE("Language=");
                 [ +  - ]
     166 [ +  - ][ +  - ]:        651 :     rURL += String( aLocaleStr );
                 [ +  - ]
     167 [ +  - ][ +  - ]:        651 :     rURL += DEFINE_CONST_UNICODE("&System=");
                 [ +  - ]
     168 [ +  - ][ +  - ]:        651 :     rURL += SvtHelpOptions().GetSystem();
         [ +  - ][ +  - ]
                 [ +  - ]
     169 [ +  - ][ +  - ]:        651 :     rURL += DEFINE_CONST_UNICODE("&Version=");
                 [ +  - ]
     170 [ +  - ][ +  - ]:        651 :     rURL += utl::ConfigManager::getProductVersion();
     171                 :        651 : }
     172                 :            : 
     173                 :        190 : sal_Bool GetHelpAnchor_Impl( const String& _rURL, String& _rAnchor )
     174                 :            : {
     175                 :        190 :     sal_Bool bRet = sal_False;
     176                 :        190 :     ::rtl::OUString sAnchor;
     177                 :            : 
     178                 :            :     try
     179                 :            :     {
     180                 :            :         ::ucbhelper::Content aCnt( INetURLObject( _rURL ).GetMainURL( INetURLObject::NO_DECODE ),
     181 [ +  - ][ +  - ]:        190 :                              Reference< ::com::sun::star::ucb::XCommandEnvironment > () );
         [ +  - ][ +  - ]
                 [ +  - ]
     182 [ +  - ][ +  - ]:        190 :         if ( ( aCnt.getPropertyValue( ::rtl::OUString("AnchorName") ) >>= sAnchor ) )
     183                 :            :         {
     184                 :            : 
     185         [ +  + ]:        190 :             if ( !sAnchor.isEmpty() )
     186                 :            :             {
     187 [ +  - ][ +  - ]:         94 :                 _rAnchor = String( sAnchor );
                 [ +  - ]
     188                 :         94 :                 bRet = sal_True;
     189                 :            :             }
     190                 :            :         }
     191                 :            :         else
     192                 :            :         {
     193                 :            :             SAL_WARN( "sfx2.appl", "Property 'AnchorName' is missing" );
     194 [ +  - ][ #  # ]:        190 :         }
     195                 :            :     }
     196         [ #  # ]:          0 :     catch (const ::com::sun::star::uno::Exception&)
     197                 :            :     {
     198                 :            :     }
     199                 :            : 
     200                 :        190 :     return bRet;
     201                 :            : }
     202                 :            : 
     203                 :            : class SfxHelpOptions_Impl : public utl::ConfigItem
     204                 :            : {
     205                 :            : private:
     206                 :            :     std::set < rtl::OString > m_aIds;
     207                 :            : 
     208                 :            : public:
     209                 :            :                     SfxHelpOptions_Impl();
     210                 :            :                     ~SfxHelpOptions_Impl();
     211                 :            : 
     212 [ +  - ][ +  - ]:       2489 :     bool            HasId( const rtl::OString& rId ) { return m_aIds.size() ? m_aIds.find( rId ) != m_aIds.end() : false; }
         [ +  - ][ +  - ]
           [ #  #  #  # ]
     213                 :            :     virtual void            Notify( const com::sun::star::uno::Sequence< rtl::OUString >& aPropertyNames );
     214                 :            :     virtual void            Commit();
     215                 :            : };
     216                 :            : 
     217                 :        102 : static Sequence< ::rtl::OUString > GetPropertyNames()
     218                 :            : {
     219                 :            :     static const char* aPropNames[] =
     220                 :            :     {
     221                 :            :         "HelpAgentStarterList",
     222                 :            :     };
     223                 :            : 
     224                 :        102 :     const int nCount = sizeof( aPropNames ) / sizeof( const char* );
     225                 :        102 :     Sequence< ::rtl::OUString > aNames( nCount );
     226         [ +  - ]:        102 :     ::rtl::OUString* pNames = aNames.getArray();
     227                 :        102 :     ::rtl::OUString* pEnd   = pNames + aNames.getLength();
     228                 :        102 :     int i = 0;
     229         [ +  + ]:        204 :     for ( ; pNames != pEnd; ++pNames )
     230                 :        102 :         *pNames = ::rtl::OUString::createFromAscii( aPropNames[i++] );
     231                 :            : 
     232                 :        102 :     return aNames;
     233                 :            : }
     234                 :            : 
     235                 :        102 : SfxHelpOptions_Impl::SfxHelpOptions_Impl()
     236 [ +  - ][ +  - ]:        102 :     : ConfigItem( ::rtl::OUString("Office.SFX/Help") )
     237                 :            : {
     238         [ +  - ]:        102 :     Sequence< ::rtl::OUString > aNames = GetPropertyNames();
     239         [ +  - ]:        102 :     Sequence< Any > aValues = GetProperties( aNames );
     240         [ +  - ]:        102 :     EnableNotification( aNames );
     241                 :        102 :     const Any* pValues = aValues.getConstArray();
     242                 :            :     DBG_ASSERT( aValues.getLength() == aNames.getLength(), "GetProperties failed" );
     243         [ +  - ]:        102 :     if ( aValues.getLength() == aNames.getLength() )
     244                 :            :     {
     245         [ +  + ]:        204 :         for ( int nProp = 0; nProp < aNames.getLength(); nProp++ )
     246                 :            :         {
     247                 :            :             DBG_ASSERT( pValues[nProp].hasValue(), "property value missing" );
     248         [ +  - ]:        102 :             if ( pValues[nProp].hasValue() )
     249                 :            :             {
     250         [ +  - ]:        102 :                 switch ( nProp )
     251                 :            :                 {
     252                 :            :                     case STARTERLIST :
     253                 :            :                     {
     254                 :        102 :                         ::rtl::OUString aCodedList;
     255         [ +  - ]:        102 :                         if ( pValues[nProp] >>= aCodedList )
     256                 :            :                         {
     257                 :            :                             rtl::OString aTmp(
     258                 :            :                                 rtl::OUStringToOString(
     259         [ +  - ]:        102 :                                     aCodedList, RTL_TEXTENCODING_UTF8 ) );
     260                 :        102 :                             sal_Int32 nIndex = 0;
     261         [ +  + ]:       7548 :                             do
     262                 :            :                             {
     263                 :       7548 :                                 rtl::OString aToken = aTmp.getToken( 0, ',', nIndex );
     264         [ +  - ]:       7548 :                                 if ( !aToken.isEmpty() )
     265         [ +  - ]:       7548 :                                     m_aIds.insert( aToken );
     266                 :            :                             }
     267                 :        102 :                             while ( nIndex >= 0 );
     268                 :            :                         }
     269                 :            :                         else {
     270                 :            :                             SAL_WARN( "sfx2.appl", "Wrong property type!" );
     271                 :            :                         }
     272                 :            : 
     273                 :        102 :                         break;
     274                 :            :                     }
     275                 :            : 
     276                 :            :                     default:
     277                 :            :                         SAL_WARN( "sfx2.appl", "Wrong property!" );
     278                 :        102 :                         break;
     279                 :            :                 }
     280                 :            :             }
     281                 :            :         }
     282 [ +  - ][ +  - ]:        102 :     }
     283                 :        102 : }
     284                 :            : 
     285                 :         60 : SfxHelpOptions_Impl::~SfxHelpOptions_Impl()
     286                 :            : {
     287         [ -  + ]:        120 : }
     288                 :            : 
     289                 :            : 
     290                 :          0 : void SfxHelpOptions_Impl::Notify( const com::sun::star::uno::Sequence< rtl::OUString >& )
     291                 :            : {
     292                 :          0 : }
     293                 :            : 
     294                 :          0 : void SfxHelpOptions_Impl::Commit()
     295                 :            : {
     296                 :          0 : }
     297                 :            : 
     298                 :            : class SfxHelp_Impl
     299                 :            : {
     300                 :            : private:
     301                 :            :     SfxHelpOptions_Impl*                m_pOpt;         // the options
     302                 :            :     ::std::vector< ::rtl::OUString >    m_aModulesList; // list of all installed modules
     303                 :            : 
     304                 :            : public:
     305                 :            :     SfxHelp_Impl();
     306                 :            :     ~SfxHelp_Impl();
     307                 :            : 
     308                 :            :     SfxHelpOptions_Impl*    GetOptions();
     309                 :            :     static String           GetHelpText( const rtl::OUString& aCommandURL, const String& rModule );
     310                 :            : };
     311                 :            : 
     312                 :        233 : SfxHelp_Impl::SfxHelp_Impl() :
     313                 :            : 
     314                 :        233 :     m_pOpt          ( NULL )
     315                 :            : 
     316                 :            : {
     317                 :        233 : }
     318                 :            : 
     319                 :        158 : SfxHelp_Impl::~SfxHelp_Impl()
     320                 :            : {
     321 [ +  + ][ +  - ]:        158 :     delete m_pOpt;
     322                 :        158 : }
     323                 :            : 
     324                 :        386 : String SfxHelp_Impl::GetHelpText( const rtl::OUString& aCommandURL, const String& rModule )
     325                 :            : {
     326                 :            :     // create help url
     327 [ +  - ][ +  - ]:        386 :     String aHelpURL = SfxHelp::CreateHelpURL( aCommandURL, rModule );
                 [ +  - ]
     328                 :            :     // added 'active' parameter
     329 [ +  - ][ +  - ]:        386 :     aHelpURL.Insert( String( DEFINE_CONST_UNICODE("&Active=true") ), aHelpURL.SearchBackward( '#' ) );
         [ +  - ][ +  - ]
     330                 :            :     // load help string
     331 [ +  - ][ +  - ]:        386 :     return SfxContentHelper::GetActiveHelpString( aHelpURL );
     332                 :            : }
     333                 :            : 
     334                 :       2489 : SfxHelpOptions_Impl* SfxHelp_Impl::GetOptions()
     335                 :            : {
     336                 :            :     // create if not exists
     337         [ +  + ]:       2489 :     if ( !m_pOpt )
     338         [ +  - ]:        102 :         m_pOpt = new SfxHelpOptions_Impl;
     339                 :       2489 :     return m_pOpt;
     340                 :            : }
     341                 :            : 
     342                 :        233 : SfxHelp::SfxHelp() :
     343                 :            : 
     344                 :            :     bIsDebug( sal_False ),
     345 [ +  - ][ +  - ]:        233 :     pImp    ( NULL )
         [ +  - ][ +  - ]
     346                 :            : 
     347                 :            : {
     348                 :            :     // read the environment variable "HELP_DEBUG"
     349                 :            :     // if it's set, you will see debug output on active help
     350                 :            :     {
     351                 :        233 :         ::rtl::OUString sHelpDebug;
     352                 :        233 :         ::rtl::OUString sEnvVarName( "HELP_DEBUG"  );
     353         [ +  - ]:        233 :         osl_getEnvironment( sEnvVarName.pData, &sHelpDebug.pData );
     354                 :        233 :         bIsDebug = !sHelpDebug.isEmpty();
     355                 :            :     }
     356                 :            : 
     357 [ +  - ][ +  - ]:        233 :     pImp = new SfxHelp_Impl();
     358                 :            : 
     359         [ +  - ]:        233 :     ::rtl::OUString aLocaleStr = HelpLocaleString();
     360                 :            : 
     361                 :        233 :     sal_Int32 nSepPos = aLocaleStr.indexOf( '_' );
     362         [ -  + ]:        233 :     if ( nSepPos != -1 )
     363                 :            :     {
     364         [ #  # ]:          0 :         aLanguageStr = aLocaleStr.copy( 0, nSepPos );
     365         [ #  # ]:          0 :         aCountryStr = aLocaleStr.copy( nSepPos+1 );
     366                 :            :     }
     367                 :            :     else
     368                 :            :     {
     369                 :        233 :         nSepPos = aLocaleStr.indexOf( '-' );
     370         [ +  + ]:        233 :         if ( nSepPos != -1 )
     371                 :            :         {
     372         [ +  - ]:        158 :             aLanguageStr = aLocaleStr.copy( 0, nSepPos );
     373         [ +  - ]:        158 :             aCountryStr = aLocaleStr.copy( nSepPos+1 );
     374                 :            :         }
     375                 :            :         else
     376                 :            :         {
     377         [ +  - ]:         75 :             aLanguageStr = aLocaleStr;
     378                 :            :         }
     379                 :        233 :     }
     380                 :        233 : }
     381                 :            : 
     382 [ +  - ][ +  - ]:        158 : SfxHelp::~SfxHelp()
         [ +  - ][ +  - ]
     383                 :            : {
     384 [ +  - ][ +  - ]:        158 :     delete pImp;
     385         [ -  + ]:        316 : }
     386                 :            : 
     387                 :        190 : ::rtl::OUString getDefaultModule_Impl()
     388                 :            : {
     389                 :        190 :     rtl::OUString sDefaultModule;
     390         [ +  - ]:        190 :     SvtModuleOptions aModOpt;
     391 [ +  - ][ +  - ]:        190 :     if ( aModOpt.IsModuleInstalled( SvtModuleOptions::E_SWRITER ) )
     392 [ +  - ][ +  - ]:        190 :         sDefaultModule = DEFINE_CONST_UNICODE("swriter");
                 [ +  - ]
     393 [ #  # ][ #  # ]:          0 :     else if ( aModOpt.IsModuleInstalled( SvtModuleOptions::E_SCALC ) )
     394 [ #  # ][ #  # ]:          0 :         sDefaultModule = DEFINE_CONST_UNICODE("scalc");
                 [ #  # ]
     395 [ #  # ][ #  # ]:          0 :     else if ( aModOpt.IsModuleInstalled( SvtModuleOptions::E_SIMPRESS ) )
     396 [ #  # ][ #  # ]:          0 :         sDefaultModule = DEFINE_CONST_UNICODE("simpress");
                 [ #  # ]
     397 [ #  # ][ #  # ]:          0 :     else if ( aModOpt.IsModuleInstalled( SvtModuleOptions::E_SDRAW ) )
     398 [ #  # ][ #  # ]:          0 :         sDefaultModule = DEFINE_CONST_UNICODE("sdraw");
                 [ #  # ]
     399 [ #  # ][ #  # ]:          0 :     else if ( aModOpt.IsModuleInstalled( SvtModuleOptions::E_SMATH ) )
     400 [ #  # ][ #  # ]:          0 :         sDefaultModule = DEFINE_CONST_UNICODE("smath");
                 [ #  # ]
     401 [ #  # ][ #  # ]:          0 :     else if ( aModOpt.IsModuleInstalled( SvtModuleOptions::E_SCHART ) )
     402 [ #  # ][ #  # ]:          0 :         sDefaultModule = DEFINE_CONST_UNICODE("schart");
                 [ #  # ]
     403 [ #  # ][ #  # ]:          0 :     else if ( aModOpt.IsModuleInstalled( SvtModuleOptions::E_SBASIC ) )
     404 [ #  # ][ #  # ]:          0 :         sDefaultModule = DEFINE_CONST_UNICODE("sbasic");
                 [ #  # ]
     405 [ #  # ][ #  # ]:          0 :     else if ( aModOpt.IsModuleInstalled( SvtModuleOptions::E_SDATABASE ) )
     406 [ #  # ][ #  # ]:          0 :         sDefaultModule = DEFINE_CONST_UNICODE("sdatabase");
                 [ #  # ]
     407                 :            :     else
     408                 :            :     {
     409                 :            :         SAL_WARN( "sfx2.appl", "getDefaultModule_Impl(): no module installed" );
     410                 :            :     }
     411         [ +  - ]:        190 :     return sDefaultModule;
     412                 :            : }
     413                 :            : 
     414                 :        190 : ::rtl::OUString getCurrentModuleIdentifier_Impl()
     415                 :            : {
     416                 :        190 :     ::rtl::OUString sIdentifier;
     417                 :        190 :     Reference < XFrame > xCurrentFrame;
     418 [ +  - ][ +  - ]:        380 :     Reference < XModuleManager > xModuleManager( ::comphelper::getProcessServiceFactory()->createInstance(
     419 [ +  - ][ +  - ]:        190 :         DEFINE_CONST_UNICODE("com.sun.star.frame.ModuleManager") ), UNO_QUERY );
         [ +  - ][ +  - ]
                 [ +  - ]
     420 [ +  - ][ +  - ]:        380 :     Reference < XDesktop > xDesktop( ::comphelper::getProcessServiceFactory()->createInstance(
     421 [ +  - ][ +  - ]:        190 :         DEFINE_CONST_UNICODE("com.sun.star.frame.Desktop") ), UNO_QUERY );
         [ +  - ][ +  - ]
                 [ +  - ]
     422         [ +  - ]:        190 :     if ( xDesktop.is() )
     423 [ +  - ][ +  - ]:        190 :         xCurrentFrame = xDesktop->getCurrentFrame();
                 [ +  - ]
              [ #  #  # ]
     424                 :            : 
     425 [ +  - ][ +  - ]:        190 :     if ( xCurrentFrame.is() && xModuleManager.is() )
                 [ +  - ]
     426                 :            :     {
     427                 :            :         try
     428                 :            :         {
     429 [ +  - ][ +  - ]:        190 :             sIdentifier = xModuleManager->identify( xCurrentFrame );
     430                 :            :         }
     431         [ #  # ]:          0 :         catch (const ::com::sun::star::frame::UnknownModuleException&)
     432                 :            :         {
     433                 :            :             DBG_WARNING( "SfxHelp::getCurrentModuleIdentifier_Impl(): unknown module (help in help?)" );
     434                 :            :         }
     435         [ #  # ]:          0 :         catch (const Exception&)
     436                 :            :         {
     437                 :            :             SAL_WARN( "sfx2.appl", "SfxHelp::getCurrentModuleIdentifier_Impl(): exception of XModuleManager::identify()" );
     438                 :            :         }
     439                 :            :     }
     440                 :            : 
     441                 :        190 :     return sIdentifier;
     442                 :            : }
     443                 :            : 
     444                 :        190 : String SfxHelp::GetHelpModuleName_Impl()
     445                 :            : {
     446         [ +  - ]:        190 :     String sModuleName;
     447                 :        190 :     rtl::OUString aFactoryShortName;
     448         [ +  - ]:        190 :     rtl::OUString aModuleIdentifier = getCurrentModuleIdentifier_Impl();
     449                 :            : 
     450         [ +  - ]:        190 :     if ( !aModuleIdentifier.isEmpty() )
     451                 :            :     {
     452                 :            :         try
     453                 :            :         {
     454                 :            :             Reference < XModuleManager > xModuleManager(
     455 [ +  - ][ +  - ]:        380 :                 ::comphelper::getProcessServiceFactory()->createInstance(
     456 [ +  - ][ +  - ]:        190 :                     DEFINE_CONST_UNICODE("com.sun.star.frame.ModuleManager") ), UNO_QUERY );
         [ +  - ][ +  - ]
                 [ +  - ]
     457         [ +  - ]:        190 :             Sequence< PropertyValue > lProps;
     458         [ +  - ]:        190 :             Reference< ::com::sun::star::container::XNameAccess > xCont( xModuleManager, UNO_QUERY);
     459         [ +  - ]:        190 :             if ( xCont.is() )
     460 [ +  - ][ +  - ]:        190 :                 xCont->getByName( aModuleIdentifier ) >>= lProps;
                 [ +  - ]
     461         [ +  - ]:       1140 :             for ( sal_Int32 i = 0; i < lProps.getLength(); ++i )
     462                 :            :             {
     463 [ +  - ][ +  + ]:       1140 :                 if ( lProps[i].Name == "ooSetupFactoryShortName" )
     464                 :            :                 {
     465         [ +  - ]:        190 :                     lProps[i].Value >>= aFactoryShortName;
     466                 :        190 :                     break;
     467                 :            :                 }
     468 [ +  - ][ #  # ]:        190 :             }
     469                 :            :         }
     470         [ #  # ]:          0 :         catch (const Exception&)
     471                 :            :         {
     472                 :            :             SAL_WARN( "sfx2.appl", "SfxHelp::GetHelpModuleName_Impl(): exception of XNameAccess::getByName()" );
     473                 :            :         }
     474                 :            :     }
     475                 :            : 
     476         [ +  - ]:        190 :     rtl::OUString sDefaultModule = getDefaultModule_Impl();
     477         [ +  - ]:        190 :     if ( !aFactoryShortName.isEmpty() )
     478                 :            :     {
     479                 :            :         // Map some module identifiers to their "real" help module string.
     480         [ -  + ]:        190 :         if ( aFactoryShortName == "chart2" )
     481                 :          0 :             aFactoryShortName = rtl::OUString( "schart"  );
     482         [ -  + ]:        190 :         else if ( aFactoryShortName == "BasicIDE" )
     483                 :          0 :             aFactoryShortName = rtl::OUString( "sbasic"  );
     484   [ +  -  +  -  :        570 :         else if ( aFactoryShortName.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("sweb"))
           -  + ][ -  + ]
     485                 :        190 :                 || aFactoryShortName.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("sglobal"))
     486                 :        190 :                 || aFactoryShortName.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("swxform")) )
     487                 :          0 :             aFactoryShortName = rtl::OUString( "swriter"  );
     488   [ +  -  +  -  :       1710 :         else if ( aFactoryShortName.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("dbquery"))
          +  -  +  -  +  
          -  +  -  +  -  
             +  -  -  + ]
                 [ -  + ]
     489                 :        190 :                 || aFactoryShortName.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("dbbrowser"))
     490                 :        190 :                 || aFactoryShortName.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("dbrelation"))
     491                 :        190 :                 || aFactoryShortName.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("dbtable"))
     492                 :        190 :                 || aFactoryShortName.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("dbapp"))
     493                 :        190 :                 || aFactoryShortName.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("dbreport"))
     494                 :        190 :                 || aFactoryShortName.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("swreport"))
     495                 :        190 :                 || aFactoryShortName.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("dbbrowser"))
     496                 :        190 :                 || aFactoryShortName.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("swform")) )
     497                 :          0 :             aFactoryShortName = rtl::OUString( "sdatabase"  );
     498   [ +  -  -  + ]:        380 :         else if ( aFactoryShortName.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("sbibliography"))
                 [ -  + ]
     499                 :        190 :                 || aFactoryShortName.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("StartModule")) )
     500                 :          0 :             aFactoryShortName = sDefaultModule;
     501                 :            :     }
     502                 :            :     else
     503                 :          0 :         aFactoryShortName = sDefaultModule;
     504                 :            : 
     505 [ +  - ][ +  - ]:        190 :     sModuleName = String( aFactoryShortName );
                 [ +  - ]
     506                 :        190 :     return sModuleName;
     507                 :            : }
     508                 :            : 
     509                 :        386 : String  SfxHelp::CreateHelpURL_Impl( const String& aCommandURL, const String& rModuleName )
     510                 :            : {
     511                 :            :     // build up the help URL
     512         [ +  - ]:        386 :     String aHelpURL;
     513                 :        386 :     sal_Bool bHasAnchor = sal_False;
     514         [ +  - ]:        386 :     String aAnchor;
     515                 :            : 
     516         [ +  - ]:        386 :     String aModuleName( rModuleName );
     517         [ -  + ]:        386 :     if ( aModuleName.Len() == 0 )
     518 [ #  # ][ #  # ]:          0 :         aModuleName = getDefaultModule_Impl();
     519                 :            : 
     520         [ +  - ]:        386 :     aHelpURL = rtl::OUString("vnd.sun.star.help://");
     521         [ +  - ]:        386 :     aHelpURL += aModuleName;
     522                 :            : 
     523         [ +  + ]:        386 :     if ( !aCommandURL.Len() )
     524         [ +  - ]:        196 :         aHelpURL += rtl::OUString("/start");
     525                 :            :     else
     526                 :            :     {
     527         [ +  - ]:        190 :         aHelpURL += '/';
     528                 :            :         aHelpURL += String( rtl::Uri::encode( aCommandURL,
     529                 :            :                                               rtl_UriCharClassRelSegment,
     530                 :            :                                               rtl_UriEncodeKeepEscapes,
     531 [ +  - ][ +  - ]:        190 :                                               RTL_TEXTENCODING_UTF8 ));
         [ +  - ][ +  - ]
     532                 :            : 
     533         [ +  - ]:        190 :         String aTempURL = aHelpURL;
     534         [ +  - ]:        190 :         AppendConfigToken( aTempURL, sal_True );
     535 [ +  - ][ +  - ]:        190 :         bHasAnchor = GetHelpAnchor_Impl( aTempURL, aAnchor );
     536                 :            :     }
     537                 :            : 
     538         [ +  - ]:        386 :     AppendConfigToken( aHelpURL, sal_True );
     539                 :            : 
     540         [ +  + ]:        386 :     if ( bHasAnchor )
     541                 :            :     {
     542         [ +  - ]:         94 :         aHelpURL += '#';
     543         [ +  - ]:         94 :         aHelpURL += aAnchor;
     544                 :            :     }
     545                 :            : 
     546 [ +  - ][ +  - ]:        386 :     return aHelpURL;
     547                 :            : }
     548                 :            : 
     549                 :          0 : SfxHelpWindow_Impl* impl_createHelp(Reference< XFrame >& rHelpTask   ,
     550                 :            :                                     Reference< XFrame >& rHelpContent)
     551                 :            : {
     552 [ #  # ][ #  # ]:          0 :     Reference < XFrame > xDesktop( ::comphelper::getProcessServiceFactory()->createInstance(
     553 [ #  # ][ #  # ]:          0 :         DEFINE_CONST_UNICODE("com.sun.star.frame.Desktop") ), UNO_QUERY );
         [ #  # ][ #  # ]
                 [ #  # ]
     554                 :            : 
     555                 :            :     // otherwhise - create new help task
     556         [ #  # ]:          0 :     Reference< XFrame > xHelpTask = xDesktop->findFrame(
     557                 :            :         ::rtl::OUString(DEFINE_CONST_UNICODE("OFFICE_HELP_TASK")),
     558 [ #  # ][ #  # ]:          0 :         FrameSearchFlag::TASKS | FrameSearchFlag::CREATE);
         [ #  # ][ #  # ]
     559         [ #  # ]:          0 :     if (!xHelpTask.is())
     560                 :          0 :         return 0;
     561                 :            : 
     562                 :            :     // create all internal windows and sub frames ...
     563 [ #  # ][ #  # ]:          0 :     Reference< ::com::sun::star::awt::XWindow > xParentWindow = xHelpTask->getContainerWindow();
     564         [ #  # ]:          0 :     Window*                                     pParentWindow = VCLUnoHelper::GetWindow( xParentWindow );
     565 [ #  # ][ #  # ]:          0 :     SfxHelpWindow_Impl*                         pHelpWindow   = new SfxHelpWindow_Impl( xHelpTask, pParentWindow, WB_DOCKBORDER );
     566         [ #  # ]:          0 :     Reference< ::com::sun::star::awt::XWindow > xHelpWindow   = VCLUnoHelper::GetInterface( pHelpWindow );
     567                 :            : 
     568                 :          0 :     Reference< XFrame > xHelpContent;
     569 [ #  # ][ #  # ]:          0 :     if (xHelpTask->setComponent( xHelpWindow, Reference< XController >() ))
                 [ #  # ]
     570                 :            :     {
     571                 :            :         // Customize UI ...
     572 [ #  # ][ #  # ]:          0 :         xHelpTask->setName( ::rtl::OUString(DEFINE_CONST_UNICODE("OFFICE_HELP_TASK")) );
         [ #  # ][ #  # ]
                 [ #  # ]
     573                 :            : 
     574         [ #  # ]:          0 :         Reference< XPropertySet > xProps(xHelpTask, UNO_QUERY);
     575         [ #  # ]:          0 :         if (xProps.is())
     576         [ #  # ]:          0 :             xProps->setPropertyValue(
     577                 :            :                 DEFINE_CONST_UNICODE("Title"),
     578 [ #  # ][ #  # ]:          0 :                 makeAny(SfxResId(STR_HELP_WINDOW_TITLE).toString()));
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
     579                 :            : 
     580         [ #  # ]:          0 :         pHelpWindow->setContainerWindow( xParentWindow );
     581 [ #  # ][ #  # ]:          0 :         xParentWindow->setVisible(sal_True);
     582 [ #  # ][ #  # ]:          0 :         xHelpWindow->setVisible(sal_True);
     583                 :            : 
     584                 :            :         // This sub frame is created internaly (if we called new SfxHelpWindow_Impl() ...)
     585                 :            :         // It should exist :-)
     586 [ #  # ][ #  # ]:          0 :         xHelpContent = xHelpTask->findFrame(::rtl::OUString(DEFINE_CONST_UNICODE("OFFICE_HELP")), FrameSearchFlag::CHILDREN);
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     587                 :            :     }
     588                 :            : 
     589         [ #  # ]:          0 :     if (!xHelpContent.is())
     590 [ #  # ][ #  # ]:          0 :         delete pHelpWindow;
     591                 :            : 
     592 [ #  # ][ #  # ]:          0 :     xHelpContent->setName(::rtl::OUString(DEFINE_CONST_UNICODE("OFFICE_HELP")));
         [ #  # ][ #  # ]
                 [ #  # ]
     593                 :            : 
     594         [ #  # ]:          0 :     rHelpTask    = xHelpTask;
     595         [ #  # ]:          0 :     rHelpContent = xHelpContent;
     596                 :          0 :     return pHelpWindow;
     597                 :            : }
     598                 :            : 
     599                 :        190 : XubString SfxHelp::GetHelpText( const String& aCommandURL, const Window* pWindow )
     600                 :            : {
     601         [ +  - ]:        190 :     String sModuleName = GetHelpModuleName_Impl();
     602 [ +  - ][ +  - ]:        190 :     String sHelpText = pImp->GetHelpText( aCommandURL, sModuleName );
     603                 :            : 
     604                 :        190 :     rtl::OString aNewHelpId;
     605                 :            : 
     606 [ +  + ][ +  + ]:        190 :     if ( pWindow && !sHelpText.Len() )
                 [ +  + ]
     607                 :            :     {
     608                 :            :         // no help text found -> try with parent help id.
     609         [ +  - ]:         44 :         Window* pParent = pWindow->GetParent();
     610         [ +  + ]:        240 :         while ( pParent )
     611                 :            :         {
     612         [ +  - ]:        196 :             aNewHelpId = pParent->GetHelpId();
     613 [ +  - ][ +  - ]:        196 :             sHelpText = pImp->GetHelpText( rtl::OStringToOUString(aNewHelpId, RTL_TEXTENCODING_UTF8), sModuleName );
         [ +  - ][ +  - ]
     614         [ -  + ]:        196 :             if ( sHelpText.Len() > 0 )
     615                 :          0 :                 pParent = NULL;
     616                 :            :             else
     617         [ +  - ]:        196 :                 pParent = pParent->GetParent();
     618                 :            :         }
     619                 :            : 
     620 [ -  + ][ #  # ]:         44 :         if ( bIsDebug && !sHelpText.Len() )
                 [ -  + ]
     621                 :          0 :             aNewHelpId = rtl::OString();
     622                 :            :     }
     623                 :            : 
     624                 :            :     // add some debug information?
     625         [ -  + ]:        190 :     if ( bIsDebug )
     626                 :            :     {
     627 [ #  # ][ #  # ]:          0 :         sHelpText += DEFINE_CONST_UNICODE("\n-------------\n");
                 [ #  # ]
     628 [ #  # ][ #  # ]:          0 :         sHelpText += String( sModuleName );
                 [ #  # ]
     629 [ #  # ][ #  # ]:          0 :         sHelpText += DEFINE_CONST_UNICODE(": ");
                 [ #  # ]
     630         [ #  # ]:          0 :         sHelpText += aCommandURL;
     631         [ #  # ]:          0 :         if ( !aNewHelpId.isEmpty() )
     632                 :            :         {
     633 [ #  # ][ #  # ]:          0 :             sHelpText += DEFINE_CONST_UNICODE(" - ");
                 [ #  # ]
     634 [ #  # ][ #  # ]:          0 :             sHelpText += String(rtl::OStringToOUString(aNewHelpId, RTL_TEXTENCODING_UTF8));
         [ #  # ][ #  # ]
     635                 :            :         }
     636                 :            :     }
     637                 :            : 
     638         [ +  - ]:        190 :     return sHelpText;
     639                 :            : }
     640                 :            : 
     641                 :            : /// Check for built-in help
     642                 :         75 : static bool impl_hasHelpInstalled( const rtl::OUString &rLang = rtl::OUString() )
     643                 :            : {
     644 [ +  - ][ +  - ]:         75 :     String aHelpRootURL( DEFINE_CONST_OUSTRING("vnd.sun.star.help://") );
     645         [ +  - ]:         75 :     AppendConfigToken( aHelpRootURL, sal_True, rLang );
     646         [ +  - ]:         75 :     Sequence< ::rtl::OUString > aFactories = SfxContentHelper::GetResultSet( aHelpRootURL );
     647                 :            : 
     648 [ +  - ][ +  - ]:         75 :     return ( aFactories.getLength() != 0   );
     649                 :            : }
     650                 :            : 
     651                 :          0 : sal_Bool SfxHelp::SearchKeyword( const XubString& rKeyword )
     652                 :            : {
     653         [ #  # ]:          0 :     return Start_Impl( String(), NULL, rKeyword );
     654                 :            : }
     655                 :            : 
     656                 :          0 : sal_Bool SfxHelp::Start( const String& rURL, const Window* pWindow )
     657                 :            : {
     658         [ #  # ]:          0 :     return Start_Impl( rURL, pWindow, String() );
     659                 :            : }
     660                 :            : 
     661                 :            : /// Redirect the vnd.sun.star.help:// urls to http://help.libreoffice.org
     662                 :          0 : static bool impl_showOnlineHelp( const String& rURL )
     663                 :            : {
     664         [ #  # ]:          0 :     String aInternal( "vnd.sun.star.help://"  );
     665 [ #  # ][ #  # ]:          0 :     if ( rURL.Len() <= aInternal.Len() || rURL.Copy( 0, aInternal.Len() ) != aInternal )
         [ #  # ][ #  # ]
                 [ #  # ]
           [ #  #  #  # ]
                 [ #  # ]
     666                 :          0 :         return false;
     667                 :            : 
     668                 :          0 :     rtl::OUString aHelpLink( "http://help.libreoffice.org/"  );
     669 [ #  # ][ #  # ]:          0 :     aHelpLink += rURL.Copy( aInternal.Len() );
                 [ #  # ]
     670                 :            :     try
     671                 :            :     {
     672                 :            :         Reference< XSystemShellExecute > xSystemShell(
     673 [ #  # ][ #  # ]:          0 :                 ::comphelper::getProcessServiceFactory()->createInstance(
     674                 :          0 :                     rtl::OUString( "com.sun.star.system.SystemShellExecute"  ) ),
     675 [ #  # ][ #  # ]:          0 :                 UNO_QUERY );
     676                 :            : 
     677         [ #  # ]:          0 :         if ( xSystemShell.is() )
     678                 :            :         {
     679 [ #  # ][ #  # ]:          0 :             xSystemShell->execute( aHelpLink, rtl::OUString(), SystemShellExecuteFlags::URIS_ONLY );
     680                 :          0 :             return true;
     681 [ #  # ][ #  # ]:          0 :         }
     682                 :            :     }
     683         [ #  # ]:          0 :     catch (const Exception&)
     684                 :            :     {
     685                 :            :     }
     686         [ #  # ]:          0 :     return false;
     687                 :            : }
     688                 :            : 
     689                 :          0 : sal_Bool SfxHelp::Start_Impl( const String& rURL, const Window* pWindow, const String& rKeyword )
     690                 :            : {
     691 [ #  # ][ #  # ]:          0 :     String aHelpRootURL( DEFINE_CONST_OUSTRING("vnd.sun.star.help://") );
     692         [ #  # ]:          0 :     AppendConfigToken( aHelpRootURL, sal_True);
     693         [ #  # ]:          0 :     Sequence< ::rtl::OUString > aFactories = SfxContentHelper::GetResultSet( aHelpRootURL );
     694                 :            : 
     695                 :            :     /* rURL may be
     696                 :            :         - a "real" URL
     697                 :            :         - a HelpID (formerly a long, now a string)
     698                 :            :        If rURL is a URL, CreateHelpURL should be called for this URL
     699                 :            :        If rURL is an arbitrary string, the same should happen, but the URL should be tried out
     700                 :            :        if it delivers real help content. In case only the Help Error Document is returned, the
     701                 :            :        parent of the window for that help was called, is asked for its HelpID.
     702                 :            :        For compatibility reasons this upward search is not implemented for "real" URLs.
     703                 :            :        Help keyword search now is implemented as own method; in former versions it
     704                 :            :        was done via Help::Start, but this implementation conflicted with the upward search.
     705                 :            :     */
     706         [ #  # ]:          0 :     String aHelpURL;
     707 [ #  # ][ #  # ]:          0 :     INetURLObject aParser( rURL );
     708                 :          0 :     INetProtocol nProtocol = aParser.GetProtocol();
     709         [ #  # ]:          0 :     String aHelpModuleName( GetHelpModuleName_Impl() );
     710                 :            : 
     711         [ #  # ]:          0 :     switch ( nProtocol )
     712                 :            :     {
     713                 :            :         case INET_PROT_VND_SUN_STAR_HELP:
     714                 :            :             // already a vnd.sun.star.help URL -> nothing to do
     715         [ #  # ]:          0 :             aHelpURL = rURL;
     716                 :          0 :             break;
     717                 :            :         default:
     718                 :            :         {
     719                 :            :             // no URL, just a HelpID (maybe empty in case of keyword search)
     720 [ #  # ][ #  # ]:          0 :             aHelpURL = CreateHelpURL_Impl( rURL, aHelpModuleName );
                 [ #  # ]
     721                 :            : 
     722 [ #  # ][ #  # ]:          0 :             if ( impl_hasHelpInstalled() && pWindow && SfxContentHelper::IsHelpErrorDocument( aHelpURL ) )
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
           [ #  #  #  # ]
     723                 :            :             {
     724                 :            :                 // no help found -> try with parent help id.
     725         [ #  # ]:          0 :                 Window* pParent = pWindow->GetParent();
     726         [ #  # ]:          0 :                 while ( pParent )
     727                 :            :                 {
     728         [ #  # ]:          0 :                     rtl::OString aHelpId = pParent->GetHelpId();
     729 [ #  # ][ #  # ]:          0 :                     aHelpURL = CreateHelpURL( rtl::OStringToOUString(aHelpId, RTL_TEXTENCODING_UTF8), aHelpModuleName );
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     730 [ #  # ][ #  # ]:          0 :                     if ( !SfxContentHelper::IsHelpErrorDocument( aHelpURL ) )
     731                 :            :                         break;
     732                 :            :                     else
     733                 :            :                     {
     734         [ #  # ]:          0 :                         pParent = pParent->GetParent();
     735         [ #  # ]:          0 :                         if ( !pParent )
     736                 :            :                             // create help url of start page ( helpid == 0 -> start page)
     737 [ #  # ][ #  # ]:          0 :                             aHelpURL = CreateHelpURL( String(), aHelpModuleName );
         [ #  # ][ #  # ]
                 [ #  # ]
     738                 :            :                     }
     739         [ #  # ]:          0 :                 }
     740                 :            :             }
     741                 :          0 :             break;
     742                 :            :         }
     743                 :            :     }
     744                 :            : 
     745 [ #  # ][ #  # ]:          0 :     if ( !impl_hasHelpInstalled() )
     746                 :            :     {
     747 [ #  # ][ #  # ]:          0 :         if ( impl_showOnlineHelp( aHelpURL ) )
     748                 :          0 :             return sal_True;
     749                 :            :         else
     750                 :            :         {
     751         [ #  # ]:          0 :             NoHelpErrorBox aErrBox( const_cast< Window* >( pWindow ) );
     752         [ #  # ]:          0 :             aErrBox.Execute();
     753         [ #  # ]:          0 :             return sal_False;
     754                 :            :         }
     755                 :            :     }
     756                 :            : 
     757 [ #  # ][ #  # ]:          0 :     Reference < XFrame > xDesktop( ::comphelper::getProcessServiceFactory()->createInstance(
     758 [ #  # ][ #  # ]:          0 :         DEFINE_CONST_UNICODE("com.sun.star.frame.Desktop") ), UNO_QUERY );
         [ #  # ][ #  # ]
                 [ #  # ]
     759                 :            : 
     760                 :            :     // check if help window is still open
     761                 :            :     // If not, create a new one and return access directly to the internal sub frame showing the help content
     762                 :            :     // search must be done here; search one desktop level could return an arbitraty frame
     763         [ #  # ]:          0 :     Reference< XFrame > xHelp = xDesktop->findFrame(
     764                 :            :         ::rtl::OUString(DEFINE_CONST_UNICODE("OFFICE_HELP_TASK")),
     765 [ #  # ][ #  # ]:          0 :         FrameSearchFlag::CHILDREN);
         [ #  # ][ #  # ]
     766         [ #  # ]:          0 :     Reference< XFrame > xHelpContent = xDesktop->findFrame(
     767                 :            :         ::rtl::OUString(DEFINE_CONST_UNICODE("OFFICE_HELP")),
     768 [ #  # ][ #  # ]:          0 :         FrameSearchFlag::CHILDREN);
         [ #  # ][ #  # ]
     769                 :            : 
     770                 :          0 :     SfxHelpWindow_Impl* pHelpWindow = 0;
     771         [ #  # ]:          0 :     if (!xHelp.is())
     772         [ #  # ]:          0 :         pHelpWindow = impl_createHelp(xHelp, xHelpContent);
     773                 :            :     else
     774 [ #  # ][ #  # ]:          0 :         pHelpWindow = (SfxHelpWindow_Impl*)VCLUnoHelper::GetWindow(xHelp->getComponentWindow());
                 [ #  # ]
     775 [ #  # ][ #  # ]:          0 :     if (!xHelp.is() || !xHelpContent.is() || !pHelpWindow)
         [ #  # ][ #  # ]
     776                 :          0 :         return sal_False;
     777                 :            : 
     778                 :            : #ifdef DBG_UTIL
     779                 :            :     rtl::OStringBuffer aTmp(RTL_CONSTASCII_STRINGPARAM("SfxHelp: HelpId = "));
     780                 :            :     aTmp.append(rtl::OUStringToOString(aHelpURL, RTL_TEXTENCODING_UTF8));
     781                 :            :     OSL_TRACE( aTmp.getStr() );
     782                 :            : #endif
     783                 :            : 
     784         [ #  # ]:          0 :     pHelpWindow->SetHelpURL( aHelpURL );
     785 [ #  # ][ #  # ]:          0 :     pHelpWindow->loadHelpContent(aHelpURL);
     786         [ #  # ]:          0 :     if ( rKeyword.Len() )
     787         [ #  # ]:          0 :         pHelpWindow->OpenKeyword( rKeyword );
     788                 :            : 
     789 [ #  # ][ #  # ]:          0 :     Reference < ::com::sun::star::awt::XTopWindow > xTopWindow( xHelp->getContainerWindow(), UNO_QUERY );
                 [ #  # ]
     790         [ #  # ]:          0 :     if ( xTopWindow.is() )
     791 [ #  # ][ #  # ]:          0 :         xTopWindow->toFront();
     792                 :            : 
     793 [ #  # ][ #  # ]:          0 :     return sal_True;
         [ #  # ][ #  # ]
                 [ #  # ]
     794                 :            : }
     795                 :            : 
     796                 :        386 : String SfxHelp::CreateHelpURL( const String& aCommandURL, const String& rModuleName )
     797                 :            : {
     798                 :        386 :     String aURL;
     799         [ +  - ]:        386 :     SfxHelp* pHelp = (static_cast< SfxHelp* >(Application::GetHelp()) );
     800         [ +  - ]:        386 :     if ( pHelp )
     801 [ +  - ][ +  - ]:        386 :         aURL = pHelp->CreateHelpURL_Impl( aCommandURL, rModuleName );
                 [ +  - ]
     802                 :        386 :     return aURL;
     803                 :            : }
     804                 :            : 
     805                 :       2489 : void SfxHelp::OpenHelpAgent( SfxFrame*, const rtl::OString& sHelpId )
     806                 :            : {
     807                 :       2489 :     SfxHelp* pHelp = (static_cast< SfxHelp* >(Application::GetHelp()) );
     808         [ +  - ]:       2489 :     if ( pHelp )
     809                 :       2489 :         pHelp->OpenHelpAgent( sHelpId );
     810                 :       2489 : }
     811                 :            : 
     812                 :       2489 : void SfxHelp::OpenHelpAgent( const rtl::OString& sHelpId )
     813                 :            : {
     814 [ +  - ][ +  - ]:       2489 :     if ( SvtHelpOptions().IsHelpAgentAutoStartMode() )
     815                 :            :     {
     816                 :       2489 :             SfxHelpOptions_Impl *pOpt = pImp->GetOptions();
     817         [ +  - ]:       2489 :             if ( !pOpt->HasId( sHelpId ) )
     818                 :       2489 :                 return;
     819                 :            : 
     820                 :            :             try
     821                 :            :             {
     822                 :          0 :                 URL aURL;
     823 [ #  # ][ #  # ]:          0 :                 aURL.Complete = CreateHelpURL_Impl( rtl::OStringToOUString(sHelpId, RTL_TEXTENCODING_UTF8), GetHelpModuleName_Impl() );
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     824 [ #  # ][ #  # ]:          0 :                 Reference< XURLTransformer > xTrans( URLTransformer::create( ::comphelper::getProcessComponentContext() ) );
     825 [ #  # ][ #  # ]:          0 :                 xTrans->parseStrict(aURL);
     826                 :            : 
     827                 :          0 :                 Reference < XFrame > xCurrentFrame;
     828 [ #  # ][ #  # ]:          0 :                 Reference < XDesktop > xDesktop( ::comphelper::getProcessServiceFactory()->createInstance(
     829 [ #  # ][ #  # ]:          0 :                     DEFINE_CONST_UNICODE("com.sun.star.frame.Desktop") ), UNO_QUERY );
         [ #  # ][ #  # ]
                 [ #  # ]
     830         [ #  # ]:          0 :                 if ( xDesktop.is() )
     831 [ #  # ][ #  # ]:          0 :                     xCurrentFrame = xDesktop->getCurrentFrame();
                 [ #  # ]
     832                 :            : 
     833         [ #  # ]:          0 :                 Reference< XDispatchProvider > xDispProv( xCurrentFrame, UNO_QUERY );
     834                 :          0 :                 Reference< XDispatch > xHelpDispatch;
     835         [ #  # ]:          0 :                 if ( xDispProv.is() )
     836         [ #  # ]:          0 :                     xHelpDispatch = xDispProv->queryDispatch(
     837                 :            :                         aURL, ::rtl::OUString("_helpagent"),
     838 [ #  # ][ #  # ]:          0 :                         FrameSearchFlag::PARENT | FrameSearchFlag::SELF );
     839                 :            : 
     840                 :            :                 DBG_ASSERT( xHelpDispatch.is(), "OpenHelpAgent: could not get a dispatcher!" );
     841         [ #  # ]:          0 :                 if ( xHelpDispatch.is() )
     842 [ #  # ][ #  # ]:          0 :                     xHelpDispatch->dispatch( aURL, Sequence< PropertyValue >() );
         [ #  # ][ #  # ]
                 [ #  # ]
     843                 :            :             }
     844                 :          0 :             catch (const Exception&)
     845                 :            :             {
     846                 :            :                 SAL_WARN( "sfx2.appl", "OpenHelpAgent: caught an exception while executing the dispatch!" );
     847                 :            :             }
     848                 :            :     }
     849                 :            : }
     850                 :            : 
     851                 :          0 : String SfxHelp::GetDefaultHelpModule()
     852                 :            : {
     853         [ #  # ]:          0 :     return getDefaultModule_Impl();
     854                 :            : }
     855                 :            : 
     856                 :          0 : ::rtl::OUString SfxHelp::GetCurrentModuleIdentifier()
     857                 :            : {
     858                 :          0 :     return getCurrentModuleIdentifier_Impl();
     859                 :            : }
     860                 :            : 
     861                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10