Kaydet (Commit) 21b8dc9f authored tarafından Peter Burow's avatar Peter Burow

fix: #87292# CreateHelpURL() and OpenHelpAgent() now static, GetHelp() removed

üst e8acb9de
...@@ -2,9 +2,9 @@ ...@@ -2,9 +2,9 @@
* *
* $RCSfile: sfxhelp.hxx,v $ * $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 * The Contents of this file are made available subject to the terms of
* either of the following licenses * either of the following licenses
...@@ -81,11 +81,12 @@ class SfxHelp : public Help ...@@ -81,11 +81,12 @@ class SfxHelp : public Help
private: private:
virtual BOOL Start( ULONG nHelpId, const Window* pWindow ); virtual BOOL Start( ULONG nHelpId, const Window* pWindow );
virtual BOOL Start( const String& rURL, 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: public:
static SfxHelp* GetHelp();
SfxHelp(); SfxHelp();
~SfxHelp(); ~SfxHelp();
void SetTicket( const String& rTicket ) void SetTicket( const String& rTicket )
...@@ -94,8 +95,9 @@ public: ...@@ -94,8 +95,9 @@ public:
{ aUser = rUser;} { aUser = rUser;}
virtual XubString GetHelpText( ULONG nHelpId, const Window* pWindow ); 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 #endif // #ifndef _SFX_HELP_HXX
......
...@@ -2,9 +2,9 @@ ...@@ -2,9 +2,9 @@
* *
* $RCSfile: sfxhelp.cxx,v $ * $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 * The Contents of this file are made available subject to the terms of
* either of the following licenses * either of the following licenses
...@@ -208,7 +208,7 @@ SfxHelpOptions_Impl::SfxHelpOptions_Impl() ...@@ -208,7 +208,7 @@ SfxHelpOptions_Impl::SfxHelpOptions_Impl()
} }
default: default:
DBG_ERROR( "Wrong Type!" ); DBG_ERROR( "Wrong Property!" );
break; break;
} }
} }
...@@ -406,7 +406,7 @@ SfxHelp::~SfxHelp() ...@@ -406,7 +406,7 @@ SfxHelp::~SfxHelp()
delete pImp; delete pImp;
} }
String SfxHelp::GetHelpModuleName( ULONG nHelpId ) String SfxHelp::GetHelpModuleName_Impl( ULONG nHelpId )
{ {
String aModuleName; String aModuleName;
SfxViewFrame *pViewFrame = SfxViewFrame::Current(); SfxViewFrame *pViewFrame = SfxViewFrame::Current();
...@@ -437,6 +437,60 @@ String SfxHelp::GetHelpModuleName( ULONG nHelpId ) ...@@ -437,6 +437,60 @@ String SfxHelp::GetHelpModuleName( ULONG nHelpId )
return aModuleName; 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 ) BOOL SfxHelp::Start( const String& rURL, const Window* pWindow )
{ {
Reference < XTasksSupplier > xDesktop( ::comphelper::getProcessServiceFactory()->createInstance( Reference < XTasksSupplier > xDesktop( ::comphelper::getProcessServiceFactory()->createInstance(
...@@ -503,14 +557,14 @@ BOOL SfxHelp::Start( const String& rURL, const Window* pWindow ) ...@@ -503,14 +557,14 @@ BOOL SfxHelp::Start( const String& rURL, const Window* pWindow )
BOOL SfxHelp::Start( ULONG nHelpId, 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 ); String aHelpURL = CreateHelpURL( nHelpId, aHelpModuleName );
return Start( aHelpURL, pWindow ); return Start( aHelpURL, pWindow );
} }
XubString SfxHelp::GetHelpText( ULONG nHelpId, const Window* pWindow ) XubString SfxHelp::GetHelpText( ULONG nHelpId, const Window* pWindow )
{ {
String aModuleName = GetHelpModuleName( nHelpId ); String aModuleName = GetHelpModuleName_Impl( nHelpId );
XubString aHelpText = pImp->GetHelpText( nHelpId, aModuleName );; XubString aHelpText = pImp->GetHelpText( nHelpId, aModuleName );;
if ( bIsDebug ) if ( bIsDebug )
{ {
...@@ -525,88 +579,45 @@ XubString SfxHelp::GetHelpText( ULONG nHelpId, const Window* pWindow ) ...@@ -525,88 +579,45 @@ XubString SfxHelp::GetHelpText( ULONG nHelpId, const Window* pWindow )
String SfxHelp::CreateHelpURL( ULONG nHelpId, const String& rModuleName ) String SfxHelp::CreateHelpURL( ULONG nHelpId, const String& rModuleName )
{ {
// build up the help URL String aURL;
String aHelpURL; SfxHelp* pHelp = SAL_STATIC_CAST( SfxHelp*, Application::GetHelp() );
if ( aTicket.Len() ) if ( pHelp )
{ aURL = pHelp->CreateHelpURL_Impl( nHelpId, rModuleName );
// if there is a ticket, we are inside a plugin, so a special Help URL must be sent return aURL;
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;
} }
void SfxHelp::OpenHelpAgent( SfxFrame *pFrame, ULONG nHelpId ) void SfxHelp::OpenHelpAgent( SfxFrame *pFrame, ULONG nHelpId )
{ {
SfxHelpOptions_Impl *pOpt = pImp->GetOptions(); if ( SvtHelpOptions().IsHelpAgentAutoStartMode() )
if ( !pOpt->HasId( nHelpId ) )
return;
try
{ {
URL aURL; SfxHelp* pHelp = SAL_STATIC_CAST( SfxHelp*, Application::GetHelp() );
aURL.Complete = CreateHelpURL( nHelpId, GetHelpModuleName( nHelpId ) ); if ( pHelp )
Reference < XURLTransformer > xTrans( ::comphelper::getProcessServiceFactory()->createInstance( rtl::OUString::createFromAscii("com.sun.star.util.URLTransformer" )), UNO_QUERY ); {
xTrans->parseStrict(aURL); SfxHelpOptions_Impl *pOpt = pHelp->pImp->GetOptions();
if ( !pOpt->HasId( nHelpId ) )
Reference< XDispatchProvider > xDispProv( pFrame->GetTopFrame()->GetFrameInterface(), UNO_QUERY ); return;
Reference< XDispatch > xHelpDispatch;
if (xDispProv.is()) try
xHelpDispatch = xDispProv->queryDispatch(aURL, ::rtl::OUString::createFromAscii("_helpagent"), FrameSearchFlag::PARENT | FrameSearchFlag::SELF); {
URL aURL;
DBG_ASSERT( xHelpDispatch.is(), "OpenHelpAgent: could not get a dispatcher!" ); aURL.Complete = pHelp->CreateHelpURL_Impl( nHelpId, pHelp->GetHelpModuleName_Impl( nHelpId ) );
if ( xHelpDispatch.is() ) Reference < XURLTransformer > xTrans( ::comphelper::getProcessServiceFactory()->createInstance( rtl::OUString::createFromAscii("com.sun.star.util.URLTransformer" )), UNO_QUERY );
xHelpDispatch->dispatch( aURL, Sequence< PropertyValue >() ); xTrans->parseStrict(aURL);
}
catch( const Exception& ) Reference< XDispatchProvider > xDispProv( pFrame->GetTopFrame()->GetFrameInterface(), UNO_QUERY );
{ Reference< XDispatch > xHelpDispatch;
DBG_ASSERT( sal_False, "OpenHelpAgent: caught an exception while executing the dispatch!" ); 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();
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment