diff options
author | Peter Burow <pb@openoffice.org> | 2001-06-21 07:27:19 +0000 |
---|---|---|
committer | Peter Burow <pb@openoffice.org> | 2001-06-21 07:27:19 +0000 |
commit | 21b8dc9f96df1b05f47d9e3256b19aabcd25b5cc (patch) | |
tree | c9797c4dde4ba6d2c688c54e198316a8b14fa6e9 /sfx2 | |
parent | e8acb9de3224351cfd8f1bcf4596674805298155 (diff) |
fix: #87292# CreateHelpURL() and OpenHelpAgent() now static, GetHelp() removed
Diffstat (limited to 'sfx2')
-rw-r--r-- | sfx2/inc/sfxhelp.hxx | 14 | ||||
-rw-r--r-- | sfx2/source/appl/sfxhelp.cxx | 177 |
2 files changed, 102 insertions, 89 deletions
diff --git a/sfx2/inc/sfxhelp.hxx b/sfx2/inc/sfxhelp.hxx index 85b2c0b3326b..404cac74dcc1 100644 --- a/sfx2/inc/sfxhelp.hxx +++ b/sfx2/inc/sfxhelp.hxx @@ -2,9 +2,9 @@ * * $RCSfile: sfxhelp.hxx,v $ * - * $Revision: 1.13 $ + * $Revision: 1.14 $ * - * last change: $Author: mba $ $Date: 2001-06-19 07:18:52 $ + * last change: $Author: pb $ $Date: 2001-06-21 08:24:59 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -81,11 +81,12 @@ class SfxHelp : public Help private: virtual BOOL Start( ULONG nHelpId, const Window* pWindow ); virtual BOOL Start( const String& rURL, const Window* pWindow ); - String GetHelpModuleName( ULONG nHelpId ); + + String GetHelpModuleName_Impl( ULONG nHelpId ); + String CreateHelpURL_Impl( ULONG nHelpId, const String& rModuleName ); public: - static SfxHelp* GetHelp(); SfxHelp(); ~SfxHelp(); void SetTicket( const String& rTicket ) @@ -94,8 +95,9 @@ public: { aUser = rUser;} virtual XubString GetHelpText( ULONG nHelpId, const Window* pWindow ); - void OpenHelpAgent( SfxFrame* pFrame, ULONG nHelpId ); - String CreateHelpURL( ULONG nHelpId, const String& rModuleName ); + + static String CreateHelpURL( ULONG nHelpId, const String& rModuleName ); + static void OpenHelpAgent( SfxFrame* pFrame, ULONG nHelpId ); }; #endif // #ifndef _SFX_HELP_HXX diff --git a/sfx2/source/appl/sfxhelp.cxx b/sfx2/source/appl/sfxhelp.cxx index b2c32d7ec134..39e8e454199e 100644 --- a/sfx2/source/appl/sfxhelp.cxx +++ b/sfx2/source/appl/sfxhelp.cxx @@ -2,9 +2,9 @@ * * $RCSfile: sfxhelp.cxx,v $ * - * $Revision: 1.34 $ + * $Revision: 1.35 $ * - * last change: $Author: mba $ $Date: 2001-06-19 07:20:37 $ + * last change: $Author: pb $ $Date: 2001-06-21 08:27:19 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -208,7 +208,7 @@ SfxHelpOptions_Impl::SfxHelpOptions_Impl() } default: - DBG_ERROR( "Wrong Type!" ); + DBG_ERROR( "Wrong Property!" ); break; } } @@ -406,7 +406,7 @@ SfxHelp::~SfxHelp() delete pImp; } -String SfxHelp::GetHelpModuleName( ULONG nHelpId ) +String SfxHelp::GetHelpModuleName_Impl( ULONG nHelpId ) { String aModuleName; SfxViewFrame *pViewFrame = SfxViewFrame::Current(); @@ -437,6 +437,60 @@ String SfxHelp::GetHelpModuleName( ULONG nHelpId ) return aModuleName; } +String SfxHelp::CreateHelpURL_Impl( ULONG nHelpId, const String& rModuleName ) +{ + // build up the help URL + String aHelpURL; + if ( aTicket.Len() ) + { + // if there is a ticket, we are inside a plugin, so a special Help URL must be sent + aHelpURL = DEFINE_CONST_UNICODE("vnd.sun.star.cmd:help?"); + aHelpURL += DEFINE_CONST_UNICODE("HELP_Request_Mode=contextIndex&HELP_Session_Mode=context&HELP_CallMode=portal&HELP_Device=html"); + + if ( !nHelpId ) + { + aHelpURL += DEFINE_CONST_UNICODE("&startId=go"); + } + else + { + aHelpURL += DEFINE_CONST_UNICODE("&HELP_ContextID=-"); + aHelpURL += String::CreateFromInt64( nHelpId ); + } + + aHelpURL += DEFINE_CONST_UNICODE("&HELP_ProgramID="); + aHelpURL += rModuleName; + aHelpURL += DEFINE_CONST_UNICODE("&HELP_User="); + aHelpURL += aUser; + aHelpURL += DEFINE_CONST_UNICODE("&HELP_Ticket="); + aHelpURL += aTicket; + aHelpURL += DEFINE_CONST_UNICODE("&HELP_Language="); + aHelpURL += aLanguageStr; + if ( aCountryStr.Len() ) + { + aHelpURL += DEFINE_CONST_UNICODE("&HELP_Country="); + aHelpURL += aCountryStr; + } + } + else + { + aHelpURL = String::CreateFromAscii("vnd.sun.star.help://"); + aHelpURL += rModuleName; + + if ( !nHelpId ) + { + aHelpURL += String( DEFINE_CONST_UNICODE("/start") ); + } + else + { + aHelpURL += '/'; + aHelpURL += String::CreateFromInt64( nHelpId ); + } + + AppendConfigToken_Impl( aHelpURL, sal_True ); + } + + return aHelpURL; +} BOOL SfxHelp::Start( const String& rURL, const Window* pWindow ) { Reference < XTasksSupplier > xDesktop( ::comphelper::getProcessServiceFactory()->createInstance( @@ -503,14 +557,14 @@ BOOL SfxHelp::Start( const String& rURL, const Window* pWindow ) BOOL SfxHelp::Start( ULONG nHelpId, const Window* pWindow ) { - String aHelpModuleName( GetHelpModuleName( nHelpId ) ); + String aHelpModuleName( GetHelpModuleName_Impl( nHelpId ) ); String aHelpURL = CreateHelpURL( nHelpId, aHelpModuleName ); return Start( aHelpURL, pWindow ); } XubString SfxHelp::GetHelpText( ULONG nHelpId, const Window* pWindow ) { - String aModuleName = GetHelpModuleName( nHelpId ); + String aModuleName = GetHelpModuleName_Impl( nHelpId ); XubString aHelpText = pImp->GetHelpText( nHelpId, aModuleName );; if ( bIsDebug ) { @@ -525,88 +579,45 @@ XubString SfxHelp::GetHelpText( ULONG nHelpId, const Window* pWindow ) String SfxHelp::CreateHelpURL( ULONG nHelpId, const String& rModuleName ) { - // build up the help URL - String aHelpURL; - if ( aTicket.Len() ) - { - // if there is a ticket, we are inside a plugin, so a special Help URL must be sent - aHelpURL = DEFINE_CONST_UNICODE("vnd.sun.star.cmd:help?"); - aHelpURL += DEFINE_CONST_UNICODE("HELP_Request_Mode=contextIndex&HELP_Session_Mode=context&HELP_CallMode=portal&HELP_Device=html"); - - if ( !nHelpId ) - { - aHelpURL += DEFINE_CONST_UNICODE("&startId=go"); - } - else - { - aHelpURL += DEFINE_CONST_UNICODE("&HELP_ContextID=-"); - aHelpURL += String::CreateFromInt64( nHelpId ); - } - - aHelpURL += DEFINE_CONST_UNICODE("&HELP_ProgramID="); - aHelpURL += rModuleName; - aHelpURL += DEFINE_CONST_UNICODE("&HELP_User="); - aHelpURL += aUser; - aHelpURL += DEFINE_CONST_UNICODE("&HELP_Ticket="); - aHelpURL += aTicket; - aHelpURL += DEFINE_CONST_UNICODE("&HELP_Language="); - aHelpURL += aLanguageStr; - if ( aCountryStr.Len() ) - { - aHelpURL += DEFINE_CONST_UNICODE("&HELP_Country="); - aHelpURL += aCountryStr; - } - } - else - { - aHelpURL = String::CreateFromAscii("vnd.sun.star.help://"); - aHelpURL += rModuleName; - - if ( !nHelpId ) - { - aHelpURL += String( DEFINE_CONST_UNICODE("/start") ); - } - else - { - aHelpURL += '/'; - aHelpURL += String::CreateFromInt64( nHelpId ); - } - - AppendConfigToken_Impl( aHelpURL, sal_True ); - } - - return aHelpURL; + String aURL; + SfxHelp* pHelp = SAL_STATIC_CAST( SfxHelp*, Application::GetHelp() ); + if ( pHelp ) + aURL = pHelp->CreateHelpURL_Impl( nHelpId, rModuleName ); + return aURL; } void SfxHelp::OpenHelpAgent( SfxFrame *pFrame, ULONG nHelpId ) { - SfxHelpOptions_Impl *pOpt = pImp->GetOptions(); - if ( !pOpt->HasId( nHelpId ) ) - return; - - try + if ( SvtHelpOptions().IsHelpAgentAutoStartMode() ) { - URL aURL; - aURL.Complete = CreateHelpURL( nHelpId, GetHelpModuleName( nHelpId ) ); - Reference < XURLTransformer > xTrans( ::comphelper::getProcessServiceFactory()->createInstance( rtl::OUString::createFromAscii("com.sun.star.util.URLTransformer" )), UNO_QUERY ); - xTrans->parseStrict(aURL); - - Reference< XDispatchProvider > xDispProv( pFrame->GetTopFrame()->GetFrameInterface(), UNO_QUERY ); - Reference< XDispatch > xHelpDispatch; - if (xDispProv.is()) - xHelpDispatch = xDispProv->queryDispatch(aURL, ::rtl::OUString::createFromAscii("_helpagent"), FrameSearchFlag::PARENT | FrameSearchFlag::SELF); - - DBG_ASSERT( xHelpDispatch.is(), "OpenHelpAgent: could not get a dispatcher!" ); - if ( xHelpDispatch.is() ) - xHelpDispatch->dispatch( aURL, Sequence< PropertyValue >() ); - } - catch( const Exception& ) - { - DBG_ASSERT( sal_False, "OpenHelpAgent: caught an exception while executing the dispatch!" ); + SfxHelp* pHelp = SAL_STATIC_CAST( SfxHelp*, Application::GetHelp() ); + if ( pHelp ) + { + SfxHelpOptions_Impl *pOpt = pHelp->pImp->GetOptions(); + if ( !pOpt->HasId( nHelpId ) ) + return; + + try + { + URL aURL; + aURL.Complete = pHelp->CreateHelpURL_Impl( nHelpId, pHelp->GetHelpModuleName_Impl( nHelpId ) ); + Reference < XURLTransformer > xTrans( ::comphelper::getProcessServiceFactory()->createInstance( rtl::OUString::createFromAscii("com.sun.star.util.URLTransformer" )), UNO_QUERY ); + xTrans->parseStrict(aURL); + + Reference< XDispatchProvider > xDispProv( pFrame->GetTopFrame()->GetFrameInterface(), UNO_QUERY ); + Reference< XDispatch > xHelpDispatch; + if (xDispProv.is()) + xHelpDispatch = xDispProv->queryDispatch(aURL, ::rtl::OUString::createFromAscii("_helpagent"), FrameSearchFlag::PARENT | FrameSearchFlag::SELF); + + DBG_ASSERT( xHelpDispatch.is(), "OpenHelpAgent: could not get a dispatcher!" ); + if ( xHelpDispatch.is() ) + xHelpDispatch->dispatch( aURL, Sequence< PropertyValue >() ); + } + catch( const Exception& ) + { + DBG_ASSERT( sal_False, "OpenHelpAgent: caught an exception while executing the dispatch!" ); + } + } } } -SfxHelp* SfxHelp::GetHelp() -{ - return (SfxHelp*) Application::GetHelp(); -} |