xref: /aoo41x/main/sfx2/source/appl/sfxhelp.cxx (revision d119d52d)
1*d119d52dSAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*d119d52dSAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*d119d52dSAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*d119d52dSAndrew Rist  * distributed with this work for additional information
6*d119d52dSAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*d119d52dSAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*d119d52dSAndrew Rist  * "License"); you may not use this file except in compliance
9*d119d52dSAndrew Rist  * with the License.  You may obtain a copy of the License at
10*d119d52dSAndrew Rist  *
11*d119d52dSAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*d119d52dSAndrew Rist  *
13*d119d52dSAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*d119d52dSAndrew Rist  * software distributed under the License is distributed on an
15*d119d52dSAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*d119d52dSAndrew Rist  * KIND, either express or implied.  See the License for the
17*d119d52dSAndrew Rist  * specific language governing permissions and limitations
18*d119d52dSAndrew Rist  * under the License.
19*d119d52dSAndrew Rist  *
20*d119d52dSAndrew Rist  *************************************************************/
21*d119d52dSAndrew Rist 
22*d119d52dSAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_sfx2.hxx"
26cdf0e10cSrcweir 
27cdf0e10cSrcweir #include "sfx2/sfxhelp.hxx"
28cdf0e10cSrcweir 
29cdf0e10cSrcweir #include <set>
30cdf0e10cSrcweir #include <algorithm>
31cdf0e10cSrcweir #include <com/sun/star/uno/Reference.h>
32cdf0e10cSrcweir #include <com/sun/star/frame/XFrame.hpp>
33cdf0e10cSrcweir #include <com/sun/star/frame/XComponentLoader.hpp>
34cdf0e10cSrcweir #include <com/sun/star/lang/XComponent.hpp>
35cdf0e10cSrcweir #include <comphelper/processfactory.hxx>
36cdf0e10cSrcweir #include <com/sun/star/awt/XWindow.hpp>
37cdf0e10cSrcweir #include <com/sun/star/awt/XTopWindow.hpp>
38cdf0e10cSrcweir #include <com/sun/star/awt/PosSize.hpp>
39cdf0e10cSrcweir #include <com/sun/star/frame/XDesktop.hpp>
40cdf0e10cSrcweir #include <com/sun/star/util/XURLTransformer.hpp>
41cdf0e10cSrcweir #include <com/sun/star/frame/XDispatch.hpp>
42cdf0e10cSrcweir #include <com/sun/star/frame/XDispatchProvider.hpp>
43cdf0e10cSrcweir #include <com/sun/star/container/XNameAccess.hpp>
44cdf0e10cSrcweir #include <com/sun/star/beans/XPropertySet.hpp>
45cdf0e10cSrcweir #include <com/sun/star/frame/FrameSearchFlag.hpp>
46cdf0e10cSrcweir #include <toolkit/helper/vclunohelper.hxx>
47cdf0e10cSrcweir #include <com/sun/star/frame/XModuleManager.hpp>
48cdf0e10cSrcweir #include <unotools/configmgr.hxx>
49cdf0e10cSrcweir #include <unotools/configitem.hxx>
50cdf0e10cSrcweir #include <svtools/helpopt.hxx>
51cdf0e10cSrcweir #include <unotools/moduleoptions.hxx>
52cdf0e10cSrcweir #include <tools/urlobj.hxx>
53cdf0e10cSrcweir #include <unotools/configmgr.hxx>
54cdf0e10cSrcweir #include <ucbhelper/content.hxx>
55cdf0e10cSrcweir #include <unotools/pathoptions.hxx>
56cdf0e10cSrcweir #include <rtl/ustring.hxx>
57cdf0e10cSrcweir #include <osl/process.h>
58cdf0e10cSrcweir #include <osl/file.hxx>
59cdf0e10cSrcweir #include <unotools/bootstrap.hxx>
60cdf0e10cSrcweir #include <rtl/uri.hxx>
61cdf0e10cSrcweir #include <vcl/msgbox.hxx>
62cdf0e10cSrcweir #include <svtools/ehdl.hxx>
63cdf0e10cSrcweir #include <svtools/sfxecode.hxx>
64cdf0e10cSrcweir 
65cdf0e10cSrcweir #define _SVSTDARR_STRINGSDTOR
66cdf0e10cSrcweir #define _SVSTDARR_ULONGSSORT
67cdf0e10cSrcweir #include <svl/svstdarr.hxx>
68cdf0e10cSrcweir 
69cdf0e10cSrcweir #include "newhelp.hxx"
70cdf0e10cSrcweir #include <sfx2/objsh.hxx>
71cdf0e10cSrcweir #include <sfx2/docfac.hxx>
72cdf0e10cSrcweir #include "sfx2/sfxresid.hxx"
73cdf0e10cSrcweir #include "helper.hxx"
74cdf0e10cSrcweir #include "app.hrc"
75cdf0e10cSrcweir #include <sfx2/sfxuno.hxx>
76cdf0e10cSrcweir #include <vcl/svapp.hxx>
77cdf0e10cSrcweir #include <sfx2/frame.hxx>
78cdf0e10cSrcweir #include <rtl/string.hxx>
79cdf0e10cSrcweir 
80cdf0e10cSrcweir using namespace ::com::sun::star::beans;
81cdf0e10cSrcweir using namespace ::com::sun::star::frame;
82cdf0e10cSrcweir using namespace ::com::sun::star::uno;
83cdf0e10cSrcweir using namespace ::com::sun::star::util;
84cdf0e10cSrcweir using namespace ::com::sun::star::frame;
85cdf0e10cSrcweir using namespace ::com::sun::star::lang;
86cdf0e10cSrcweir 
87cdf0e10cSrcweir #define ERROR_TAG	String( DEFINE_CONST_UNICODE("Error: ") )
88cdf0e10cSrcweir #define PATH_TAG	String( DEFINE_CONST_UNICODE("\nPath: ") )
89cdf0e10cSrcweir 
90cdf0e10cSrcweir // class NoHelpErrorBox --------------------------------------------------
91cdf0e10cSrcweir 
92cdf0e10cSrcweir class NoHelpErrorBox : public ErrorBox
93cdf0e10cSrcweir {
94cdf0e10cSrcweir public:
95cdf0e10cSrcweir     NoHelpErrorBox( Window* _pParent );
96cdf0e10cSrcweir 
97cdf0e10cSrcweir     virtual void    RequestHelp( const HelpEvent& rHEvt );
98cdf0e10cSrcweir };
99cdf0e10cSrcweir 
100cdf0e10cSrcweir NoHelpErrorBox::NoHelpErrorBox( Window* _pParent ) :
101cdf0e10cSrcweir 
102cdf0e10cSrcweir     ErrorBox( _pParent, WB_OK, String( SfxResId( RID_STR_HLPFILENOTEXIST ) ) )
103cdf0e10cSrcweir {
104cdf0e10cSrcweir     // Error message: "No help available"
105cdf0e10cSrcweir }
106cdf0e10cSrcweir 
107cdf0e10cSrcweir void NoHelpErrorBox::RequestHelp( const HelpEvent& )
108cdf0e10cSrcweir {
109cdf0e10cSrcweir     // do nothing, because no help available
110cdf0e10cSrcweir }
111cdf0e10cSrcweir 
112cdf0e10cSrcweir // -----------------------------------------------------------------------
113cdf0e10cSrcweir 
114cdf0e10cSrcweir #define STARTERLIST 0
115cdf0e10cSrcweir 
116cdf0e10cSrcweir rtl::OUString HelpLocaleString()
117cdf0e10cSrcweir {
118cdf0e10cSrcweir 	static rtl::OUString aLocaleStr;
119cdf0e10cSrcweir 	if (!aLocaleStr.getLength())
120cdf0e10cSrcweir 	{
121cdf0e10cSrcweir 		// detect installed locale
122cdf0e10cSrcweir 		Any aLocale =
123cdf0e10cSrcweir 			::utl::ConfigManager::GetConfigManager()->GetDirectConfigProperty(
124cdf0e10cSrcweir 			   ::utl::ConfigManager::LOCALE );
125cdf0e10cSrcweir         aLocale >>= aLocaleStr;
126cdf0e10cSrcweir         bool bOk = aLocaleStr.getLength() != 0;
127cdf0e10cSrcweir 		if ( bOk )
128cdf0e10cSrcweir 		{
129cdf0e10cSrcweir 			rtl::OUString aBaseInstallPath;
130cdf0e10cSrcweir 			// utl::Bootstrap::PathStatus aBaseLocateResult =
131cdf0e10cSrcweir 			utl::Bootstrap::locateBaseInstallation(aBaseInstallPath);
132cdf0e10cSrcweir 			static const char *szHelpPath = "/help/";
133cdf0e10cSrcweir 
134cdf0e10cSrcweir 			rtl::OUString sHelpPath = aBaseInstallPath +
135cdf0e10cSrcweir 				rtl::OUString::createFromAscii(szHelpPath) + aLocaleStr;
136cdf0e10cSrcweir 			osl::DirectoryItem aDirItem;
137cdf0e10cSrcweir 
138cdf0e10cSrcweir 			if (!osl::DirectoryItem::get(sHelpPath, aDirItem) == osl::FileBase::E_None)
139cdf0e10cSrcweir 			{
140cdf0e10cSrcweir 				bOk = false;
141cdf0e10cSrcweir 				String sLang(aLocaleStr);
142cdf0e10cSrcweir 				xub_StrLen nSepPos = sLang.Search( '-' );
143cdf0e10cSrcweir 				if (nSepPos != STRING_NOTFOUND)
144cdf0e10cSrcweir 				{
145cdf0e10cSrcweir 					bOk = true;
146cdf0e10cSrcweir         			sLang = sLang.Copy( 0, nSepPos );
147cdf0e10cSrcweir 					sHelpPath = aBaseInstallPath +
148cdf0e10cSrcweir 						rtl::OUString::createFromAscii(szHelpPath) + sLang;
149cdf0e10cSrcweir 					if (!osl::DirectoryItem::get(sHelpPath, aDirItem) == osl::FileBase::E_None)
150cdf0e10cSrcweir 						bOk = false;
151cdf0e10cSrcweir 				}
152cdf0e10cSrcweir 			}
153cdf0e10cSrcweir 		}
154cdf0e10cSrcweir 		if (!bOk)
155cdf0e10cSrcweir 			aLocaleStr = rtl::OUString( DEFINE_CONST_UNICODE("en") );
156cdf0e10cSrcweir 	}
157cdf0e10cSrcweir 	return aLocaleStr;
158cdf0e10cSrcweir }
159cdf0e10cSrcweir 
160cdf0e10cSrcweir void AppendConfigToken_Impl( String& rURL, sal_Bool bQuestionMark )
161cdf0e10cSrcweir {
162cdf0e10cSrcweir 	::rtl::OUString aLocaleStr(HelpLocaleString());
163cdf0e10cSrcweir 
164cdf0e10cSrcweir 	// query part exists?
165cdf0e10cSrcweir 	if ( bQuestionMark )
166cdf0e10cSrcweir 		// no, so start with '?'
167cdf0e10cSrcweir 		rURL += '?';
168cdf0e10cSrcweir 	else
169cdf0e10cSrcweir 		// yes, so only append with '&'
170cdf0e10cSrcweir 		rURL += '&';
171cdf0e10cSrcweir 
172cdf0e10cSrcweir 	// set parameters
173cdf0e10cSrcweir 	rURL += DEFINE_CONST_UNICODE("Language=");
174cdf0e10cSrcweir 	rURL += String( aLocaleStr );
175cdf0e10cSrcweir 	rURL += DEFINE_CONST_UNICODE("&System=");
176cdf0e10cSrcweir 	rURL += SvtHelpOptions().GetSystem();
177cdf0e10cSrcweir 
178cdf0e10cSrcweir }
179cdf0e10cSrcweir 
180cdf0e10cSrcweir // -----------------------------------------------------------------------
181cdf0e10cSrcweir 
182cdf0e10cSrcweir sal_Bool GetHelpAnchor_Impl( const String& _rURL, String& _rAnchor )
183cdf0e10cSrcweir {
184cdf0e10cSrcweir 	sal_Bool bRet = sal_False;
185cdf0e10cSrcweir 	::rtl::OUString sAnchor;
186cdf0e10cSrcweir 
187cdf0e10cSrcweir     // --> OD 2009-07-01 #159496#
188cdf0e10cSrcweir     // do not release solar mutex due to crash regarding accessibility
189cdf0e10cSrcweir //    sal_uIntPtr nSolarCount = Application::ReleaseSolarMutex();
190cdf0e10cSrcweir     // <--
191cdf0e10cSrcweir 	try
192cdf0e10cSrcweir 	{
193cdf0e10cSrcweir 		::ucbhelper::Content aCnt( INetURLObject( _rURL ).GetMainURL( INetURLObject::NO_DECODE ),
194cdf0e10cSrcweir 							 Reference< ::com::sun::star::ucb::XCommandEnvironment > () );
195cdf0e10cSrcweir 		if ( ( aCnt.getPropertyValue( ::rtl::OUString::createFromAscii( "AnchorName" ) ) >>= sAnchor ) )
196cdf0e10cSrcweir 		{
197cdf0e10cSrcweir 
198cdf0e10cSrcweir 			if ( sAnchor.getLength() > 0 )
199cdf0e10cSrcweir 			{
200cdf0e10cSrcweir 				_rAnchor = String( sAnchor );
201cdf0e10cSrcweir 				bRet = sal_True;
202cdf0e10cSrcweir 			}
203cdf0e10cSrcweir 		}
204cdf0e10cSrcweir 		else
205cdf0e10cSrcweir 		{
206cdf0e10cSrcweir 			DBG_ERRORFILE( "Property 'AnchorName' is missing" );
207cdf0e10cSrcweir 		}
208cdf0e10cSrcweir 	}
209cdf0e10cSrcweir 	catch( ::com::sun::star::uno::Exception& )
210cdf0e10cSrcweir 	{
211cdf0e10cSrcweir 	}
212cdf0e10cSrcweir     // --> OD 2009-07-01 #159496#
213cdf0e10cSrcweir //    Application::AcquireSolarMutex( nSolarCount );
214cdf0e10cSrcweir     // <--
215cdf0e10cSrcweir 
216cdf0e10cSrcweir 	return bRet;
217cdf0e10cSrcweir }
218cdf0e10cSrcweir 
219cdf0e10cSrcweir // -----------------------------------------------------------------------
220cdf0e10cSrcweir 
221cdf0e10cSrcweir class SfxHelpOptions_Impl : public utl::ConfigItem
222cdf0e10cSrcweir {
223cdf0e10cSrcweir private:
224cdf0e10cSrcweir     std::set < rtl::OString > m_aIds;
225cdf0e10cSrcweir 
226cdf0e10cSrcweir public:
227cdf0e10cSrcweir                     SfxHelpOptions_Impl();
228cdf0e10cSrcweir                     ~SfxHelpOptions_Impl();
229cdf0e10cSrcweir 
230cdf0e10cSrcweir     bool            HasId( const rtl::OString& rId ) { return m_aIds.size() ? m_aIds.find( rId ) != m_aIds.end() : false; }
231cdf0e10cSrcweir     virtual void            Notify( const com::sun::star::uno::Sequence< rtl::OUString >& aPropertyNames );
232cdf0e10cSrcweir     virtual void            Commit();
233cdf0e10cSrcweir };
234cdf0e10cSrcweir 
235cdf0e10cSrcweir static Sequence< ::rtl::OUString > GetPropertyNames()
236cdf0e10cSrcweir {
237cdf0e10cSrcweir 	static const char* aPropNames[] =
238cdf0e10cSrcweir 	{
239cdf0e10cSrcweir         "HelpAgentStarterList",
240cdf0e10cSrcweir 	};
241cdf0e10cSrcweir 
242cdf0e10cSrcweir     const int nCount = sizeof( aPropNames ) / sizeof( const char* );
243cdf0e10cSrcweir 	Sequence< ::rtl::OUString > aNames( nCount );
244cdf0e10cSrcweir 	::rtl::OUString* pNames = aNames.getArray();
245cdf0e10cSrcweir 	::rtl::OUString* pEnd	= pNames + aNames.getLength();
246cdf0e10cSrcweir 	int i = 0;
247cdf0e10cSrcweir 	for ( ; pNames != pEnd; ++pNames )
248cdf0e10cSrcweir 		*pNames = ::rtl::OUString::createFromAscii( aPropNames[i++] );
249cdf0e10cSrcweir 
250cdf0e10cSrcweir 	return aNames;
251cdf0e10cSrcweir }
252cdf0e10cSrcweir 
253cdf0e10cSrcweir // -----------------------------------------------------------------------
254cdf0e10cSrcweir 
255cdf0e10cSrcweir SfxHelpOptions_Impl::SfxHelpOptions_Impl()
256cdf0e10cSrcweir     : ConfigItem( ::rtl::OUString::createFromAscii("Office.SFX/Help") )
257cdf0e10cSrcweir {
258cdf0e10cSrcweir 	Sequence< ::rtl::OUString > aNames = GetPropertyNames();
259cdf0e10cSrcweir 	Sequence< Any > aValues = GetProperties( aNames );
260cdf0e10cSrcweir 	EnableNotification( aNames );
261cdf0e10cSrcweir 	const Any* pValues = aValues.getConstArray();
262cdf0e10cSrcweir 	DBG_ASSERT( aValues.getLength() == aNames.getLength(), "GetProperties failed" );
263cdf0e10cSrcweir 	if ( aValues.getLength() == aNames.getLength() )
264cdf0e10cSrcweir 	{
265cdf0e10cSrcweir 		for ( int nProp = 0; nProp < aNames.getLength(); nProp++ )
266cdf0e10cSrcweir 		{
267cdf0e10cSrcweir 			DBG_ASSERT( pValues[nProp].hasValue(), "property value missing" );
268cdf0e10cSrcweir 			if ( pValues[nProp].hasValue() )
269cdf0e10cSrcweir 			{
270cdf0e10cSrcweir 				switch ( nProp )
271cdf0e10cSrcweir 				{
272cdf0e10cSrcweir                     case STARTERLIST :
273cdf0e10cSrcweir                     {
274cdf0e10cSrcweir                         ::rtl::OUString aCodedList;
275cdf0e10cSrcweir                         if ( pValues[nProp] >>= aCodedList )
276cdf0e10cSrcweir                         {
277cdf0e10cSrcweir                             rtl::OString aTmp( aCodedList, aCodedList.getLength(), RTL_TEXTENCODING_UTF8 );
278cdf0e10cSrcweir                             sal_Int32 nIndex = 0;
279cdf0e10cSrcweir                             do
280cdf0e10cSrcweir                             {
281cdf0e10cSrcweir                                 rtl::OString aToken = aTmp.getToken( 0, ',', nIndex );
282cdf0e10cSrcweir                                 if ( aToken.getLength() )
283cdf0e10cSrcweir                                     m_aIds.insert( aToken );
284cdf0e10cSrcweir                             }
285cdf0e10cSrcweir                             while ( nIndex >= 0 );
286cdf0e10cSrcweir                         }
287cdf0e10cSrcweir                         else {
288cdf0e10cSrcweir                             DBG_ERRORFILE( "Wrong property type!" );
289cdf0e10cSrcweir                         }
290cdf0e10cSrcweir 
291cdf0e10cSrcweir                         break;
292cdf0e10cSrcweir                     }
293cdf0e10cSrcweir 
294cdf0e10cSrcweir 					default:
295cdf0e10cSrcweir                         DBG_ERRORFILE( "Wrong property!" );
296cdf0e10cSrcweir                         break;
297cdf0e10cSrcweir 				}
298cdf0e10cSrcweir 			}
299cdf0e10cSrcweir 		}
300cdf0e10cSrcweir 	}
301cdf0e10cSrcweir }
302cdf0e10cSrcweir 
303cdf0e10cSrcweir SfxHelpOptions_Impl::~SfxHelpOptions_Impl()
304cdf0e10cSrcweir {
305cdf0e10cSrcweir }
306cdf0e10cSrcweir 
307cdf0e10cSrcweir 
308cdf0e10cSrcweir void SfxHelpOptions_Impl::Notify( const com::sun::star::uno::Sequence< rtl::OUString >& )
309cdf0e10cSrcweir {
310cdf0e10cSrcweir }
311cdf0e10cSrcweir 
312cdf0e10cSrcweir void SfxHelpOptions_Impl::Commit()
313cdf0e10cSrcweir {
314cdf0e10cSrcweir }
315cdf0e10cSrcweir 
316cdf0e10cSrcweir // class SfxHelp_Impl ----------------------------------------------------
317cdf0e10cSrcweir 
318cdf0e10cSrcweir class SfxHelp_Impl
319cdf0e10cSrcweir {
320cdf0e10cSrcweir private:
321cdf0e10cSrcweir 	sal_Bool							m_bIsDebug;		// environment variable "help_debug=1"
322cdf0e10cSrcweir     SfxHelpOptions_Impl*				m_pOpt;			// the options
323cdf0e10cSrcweir 	::std::vector< ::rtl::OUString >	m_aModulesList;	// list of all installed modules
324cdf0e10cSrcweir 	void					Load();
325cdf0e10cSrcweir 
326cdf0e10cSrcweir public:
327cdf0e10cSrcweir     SfxHelp_Impl( sal_Bool bDebug );
328cdf0e10cSrcweir     ~SfxHelp_Impl();
329cdf0e10cSrcweir 
330cdf0e10cSrcweir     SfxHelpOptions_Impl*	GetOptions();
331cdf0e10cSrcweir     static String           GetHelpText( const rtl::OUString& aCommandURL, const String& rModule );
332cdf0e10cSrcweir 	sal_Bool				HasModule( const ::rtl::OUString& rModule );			// module installed
333cdf0e10cSrcweir 	sal_Bool				IsHelpInstalled();										// module list not empty
334cdf0e10cSrcweir };
335cdf0e10cSrcweir 
336cdf0e10cSrcweir SfxHelp_Impl::SfxHelp_Impl( sal_Bool bDebug ) :
337cdf0e10cSrcweir 
338cdf0e10cSrcweir 	m_bIsDebug		( bDebug ),
339cdf0e10cSrcweir     m_pOpt      	( NULL )
340cdf0e10cSrcweir 
341cdf0e10cSrcweir {
342cdf0e10cSrcweir }
343cdf0e10cSrcweir 
344cdf0e10cSrcweir SfxHelp_Impl::~SfxHelp_Impl()
345cdf0e10cSrcweir {
346cdf0e10cSrcweir     delete m_pOpt;
347cdf0e10cSrcweir }
348cdf0e10cSrcweir 
349cdf0e10cSrcweir void SfxHelp_Impl::Load()
350cdf0e10cSrcweir {
351cdf0e10cSrcweir 	// fill modules list
352cdf0e10cSrcweir 	// create the help url (empty, without module and helpid)
353cdf0e10cSrcweir 	String sHelpURL( DEFINE_CONST_UNICODE("vnd.sun.star.help://") );
354cdf0e10cSrcweir 	AppendConfigToken_Impl( sHelpURL, sal_True );
355cdf0e10cSrcweir 
356cdf0e10cSrcweir 	// open ucb content and get the list of the help modules
357cdf0e10cSrcweir 	// the list contains strings with three tokens "ui title \t type \t url"
358cdf0e10cSrcweir 	Sequence< ::rtl::OUString > aAllModulesList = SfxContentHelper::GetResultSet( sHelpURL );
359cdf0e10cSrcweir 	sal_Int32 nLen = aAllModulesList.getLength();
360cdf0e10cSrcweir 	m_aModulesList.reserve( nLen + 1 );
361cdf0e10cSrcweir 	const ::rtl::OUString* pBegin = aAllModulesList.getConstArray();
362cdf0e10cSrcweir 	const ::rtl::OUString* pEnd	= pBegin + nLen;
363cdf0e10cSrcweir 	for ( ; pBegin != pEnd; ++pBegin )
364cdf0e10cSrcweir 	{
365cdf0e10cSrcweir 		// get one module string
366cdf0e10cSrcweir 		String sModule( *pBegin );
367cdf0e10cSrcweir 		// extract the url
368cdf0e10cSrcweir 		String sURL = sModule.GetToken( 2, '\t' );
369cdf0e10cSrcweir 		// insert the module (the host part of the "vnd.sun.star.help" url)
370cdf0e10cSrcweir 		m_aModulesList.push_back( ::rtl::OUString( INetURLObject( sURL ).GetHost() ) );
371cdf0e10cSrcweir 	}
372cdf0e10cSrcweir }
373cdf0e10cSrcweir 
374cdf0e10cSrcweir String SfxHelp_Impl::GetHelpText( const rtl::OUString& aCommandURL, const String& rModule )
375cdf0e10cSrcweir {
376cdf0e10cSrcweir 	// create help url
377cdf0e10cSrcweir     String aHelpURL = SfxHelp::CreateHelpURL( aCommandURL, rModule );
378cdf0e10cSrcweir 	// added 'active' parameter
379cdf0e10cSrcweir 	aHelpURL.Insert( String( DEFINE_CONST_UNICODE("&Active=true") ), aHelpURL.SearchBackward( '#' ) );
380cdf0e10cSrcweir 	// load help string
381cdf0e10cSrcweir 	return SfxContentHelper::GetActiveHelpString( aHelpURL );
382cdf0e10cSrcweir }
383cdf0e10cSrcweir 
384cdf0e10cSrcweir SfxHelpOptions_Impl* SfxHelp_Impl::GetOptions()
385cdf0e10cSrcweir {
386cdf0e10cSrcweir 	// create if not exists
387cdf0e10cSrcweir     if ( !m_pOpt )
388cdf0e10cSrcweir         m_pOpt = new SfxHelpOptions_Impl;
389cdf0e10cSrcweir     return m_pOpt;
390cdf0e10cSrcweir }
391cdf0e10cSrcweir 
392cdf0e10cSrcweir sal_Bool SfxHelp_Impl::HasModule( const ::rtl::OUString& rModule )
393cdf0e10cSrcweir {
394cdf0e10cSrcweir 	if ( !m_aModulesList.size() )
395cdf0e10cSrcweir 		Load();
396cdf0e10cSrcweir 	return ( ::std::find( m_aModulesList.begin(), m_aModulesList.end(), rModule ) != m_aModulesList.end() );
397cdf0e10cSrcweir }
398cdf0e10cSrcweir 
399cdf0e10cSrcweir sal_Bool SfxHelp_Impl::IsHelpInstalled()
400cdf0e10cSrcweir {
401cdf0e10cSrcweir 	if ( !m_aModulesList.size() )
402cdf0e10cSrcweir 		Load();
403cdf0e10cSrcweir 	return ( m_aModulesList.begin() != m_aModulesList.end() );
404cdf0e10cSrcweir }
405cdf0e10cSrcweir 
406cdf0e10cSrcweir // class SfxHelp ---------------------------------------------------------
407cdf0e10cSrcweir /* some test code for HID conversion - please don't remove
408cdf0e10cSrcweir 
409cdf0e10cSrcweir #include <tools/stream.hxx>
410cdf0e10cSrcweir void TestHids()
411cdf0e10cSrcweir {
412cdf0e10cSrcweir     static const char* aModules[] =
413cdf0e10cSrcweir     {
414cdf0e10cSrcweir         "swriter",
415cdf0e10cSrcweir         "scalc",
416cdf0e10cSrcweir         "simpress",
417cdf0e10cSrcweir         "sdraw",
418cdf0e10cSrcweir         "sdatabase",
419cdf0e10cSrcweir         "smath",
420cdf0e10cSrcweir         "schart",
421cdf0e10cSrcweir         "sbasic"
422cdf0e10cSrcweir     };
423cdf0e10cSrcweir 
424cdf0e10cSrcweir     SvFileStream* pOut[] =
425cdf0e10cSrcweir     {
426cdf0e10cSrcweir         0,0,0,0,0,0,0,0,0
427cdf0e10cSrcweir     };
428cdf0e10cSrcweir 
429cdf0e10cSrcweir     String aIn = String::CreateFromAscii("/data/OOo/replacer/hidsin.lst");
430cdf0e10cSrcweir     String aOut = String::CreateFromAscii("/data/OOo/replacer/");
431cdf0e10cSrcweir     SvFileStream aInStrm( aIn, STREAM_READ );
432cdf0e10cSrcweir     ByteString aBuffer;
433cdf0e10cSrcweir     while ( aInStrm.ReadLine( aBuffer ) )
434cdf0e10cSrcweir     {
435cdf0e10cSrcweir         ByteString aHid = aBuffer.GetToken(0, ' ');
436cdf0e10cSrcweir         ByteString aNr  = aBuffer.GetToken(1, ' ');
437cdf0e10cSrcweir         bool bFound=false;
438cdf0e10cSrcweir         for (sal_Int32 n= 0; n<8; n++)
439cdf0e10cSrcweir         {
440cdf0e10cSrcweir             bFound = false;
441cdf0e10cSrcweir 	        String aHelpURL = SfxHelp::CreateHelpURL( String( aNr, RTL_TEXTENCODING_UTF8 ), String( aModules[n], RTL_TEXTENCODING_UTF8 ) );
442cdf0e10cSrcweir             if ( !SfxContentHelper::IsHelpErrorDocument( aHelpURL ) )
443cdf0e10cSrcweir             {
444cdf0e10cSrcweir                 if (!pOut[n])
445cdf0e10cSrcweir                 {
446cdf0e10cSrcweir                     String aTmp( aOut );
447cdf0e10cSrcweir                     aTmp += String( aModules[n], RTL_TEXTENCODING_UTF8 );
448cdf0e10cSrcweir                     aTmp += String::CreateFromAscii(".lst");
449cdf0e10cSrcweir                     pOut[n] = new SvFileStream( aTmp, STREAM_WRITE | STREAM_TRUNC );
450cdf0e10cSrcweir                 }
451cdf0e10cSrcweir                 pOut[n]->WriteLine( aHid );
452cdf0e10cSrcweir                 bFound = true;
453cdf0e10cSrcweir                 break;
454cdf0e10cSrcweir             }
455cdf0e10cSrcweir         }
456cdf0e10cSrcweir 
457cdf0e10cSrcweir         if (!bFound)
458cdf0e10cSrcweir         {
459cdf0e10cSrcweir             if (!pOut[8])
460cdf0e10cSrcweir             {
461cdf0e10cSrcweir                 String aTmp( aOut );
462cdf0e10cSrcweir                 aTmp += String( "notfound", RTL_TEXTENCODING_UTF8 );
463cdf0e10cSrcweir                 aTmp += String::CreateFromAscii(".lst");
464cdf0e10cSrcweir                 pOut[8] = new SvFileStream( aTmp, STREAM_WRITE | STREAM_TRUNC );
465cdf0e10cSrcweir             }
466cdf0e10cSrcweir             pOut[8]->WriteLine( aHid );
467cdf0e10cSrcweir         }
468cdf0e10cSrcweir     }
469cdf0e10cSrcweir 
470cdf0e10cSrcweir     for (sal_Int32 n= 0; n<9; n++)
471cdf0e10cSrcweir         DELETEZ( pOut[n] );
472cdf0e10cSrcweir }
473cdf0e10cSrcweir 
474cdf0e10cSrcweir void TestHids2()
475cdf0e10cSrcweir {
476cdf0e10cSrcweir     static const char* aModules[] =
477cdf0e10cSrcweir     {
478cdf0e10cSrcweir         "swriter",
479cdf0e10cSrcweir         "scalc",
480cdf0e10cSrcweir         "simpress",
481cdf0e10cSrcweir         "smath",
482cdf0e10cSrcweir         "sbasic"
483cdf0e10cSrcweir     };
484cdf0e10cSrcweir 
485cdf0e10cSrcweir     String aOut = String::CreateFromAscii("/data/OOo/replacer/");
486cdf0e10cSrcweir     aOut += String::CreateFromAscii("lost.lst");
487cdf0e10cSrcweir     SvFileStream aOutStrm( aOut, STREAM_WRITE | STREAM_TRUNC );
488cdf0e10cSrcweir     for (sal_Int32 n= 0; n<5; n++)
489cdf0e10cSrcweir     {
490cdf0e10cSrcweir         String aIn = String::CreateFromAscii("/data/OOo/replacer/help/");
491cdf0e10cSrcweir         aIn += String::CreateFromAscii( aModules[n] );
492cdf0e10cSrcweir         aIn += String::CreateFromAscii(".lst");
493cdf0e10cSrcweir         SvFileStream aInStrm( aIn, STREAM_READ );
494cdf0e10cSrcweir         ByteString aBuffer;
495cdf0e10cSrcweir         while ( aInStrm.ReadLine( aBuffer ) )
496cdf0e10cSrcweir         {
497cdf0e10cSrcweir             String aHelpURL = SfxHelp::CreateHelpURL( String( aBuffer, RTL_TEXTENCODING_UTF8 ), String( aModules[n], RTL_TEXTENCODING_UTF8 ) );
498cdf0e10cSrcweir             if ( SfxContentHelper::IsHelpErrorDocument( aHelpURL ) )
499cdf0e10cSrcweir                 aOutStrm.WriteLine( aBuffer );
500cdf0e10cSrcweir         }
501cdf0e10cSrcweir     }
502cdf0e10cSrcweir }
503cdf0e10cSrcweir 
504cdf0e10cSrcweir #include <tools/stream.hxx>
505cdf0e10cSrcweir void TestHids3()
506cdf0e10cSrcweir {
507cdf0e10cSrcweir     static const char* aModules[] =
508cdf0e10cSrcweir     {
509cdf0e10cSrcweir         "swriter",
510cdf0e10cSrcweir         "scalc",
511cdf0e10cSrcweir         "simpress",
512cdf0e10cSrcweir         "sdraw",
513cdf0e10cSrcweir         "sdatabase",
514cdf0e10cSrcweir         "smath",
515cdf0e10cSrcweir         "schart",
516cdf0e10cSrcweir         "sbasic"
517cdf0e10cSrcweir     };
518cdf0e10cSrcweir 
519cdf0e10cSrcweir     SvFileStream* pOut[] =
520cdf0e10cSrcweir     {
521cdf0e10cSrcweir         0,0,0,0,0,0,0,0,0
522cdf0e10cSrcweir     };
523cdf0e10cSrcweir 
524cdf0e10cSrcweir     String aIn = String::CreateFromAscii("/data/OOo/replacer/hidsin.lst");
525cdf0e10cSrcweir     String aOut = String::CreateFromAscii("/data/OOo/replacer/quickhelp/");
526cdf0e10cSrcweir     SvFileStream aInStrm( aIn, STREAM_READ );
527cdf0e10cSrcweir     ByteString aBuffer;
528cdf0e10cSrcweir     while ( aInStrm.ReadLine( aBuffer ) )
529cdf0e10cSrcweir     {
530cdf0e10cSrcweir         ByteString aHid = aBuffer.GetToken(0, ' ');
531cdf0e10cSrcweir         ByteString aNr  = aBuffer.GetToken(1, ' ');
532cdf0e10cSrcweir         bool bFound=false;
533cdf0e10cSrcweir         for (sal_Int32 n= 0; n<8; n++)
534cdf0e10cSrcweir         {
535cdf0e10cSrcweir             bFound = false;
536cdf0e10cSrcweir             String aHelpURL = SfxHelp::CreateHelpURL( String( aNr, RTL_TEXTENCODING_UTF8 ), String( aModules[n], RTL_TEXTENCODING_UTF8 ) );
537cdf0e10cSrcweir 	        if ( SfxContentHelper::GetActiveHelpString( aHelpURL ).Len() )
538cdf0e10cSrcweir //            if ( SfxHelp_Impl::GetHelpText( String( aNr, RTL_TEXTENCODING_UTF8 ), String( aModules[n], RTL_TEXTENCODING_UTF8 ) ).Len() )
539cdf0e10cSrcweir             {
540cdf0e10cSrcweir                 if (!pOut[n])
541cdf0e10cSrcweir                 {
542cdf0e10cSrcweir                     String aTmp( aOut );
543cdf0e10cSrcweir                     aTmp += String( aModules[n], RTL_TEXTENCODING_UTF8 );
544cdf0e10cSrcweir                     aTmp += String::CreateFromAscii(".lst");
545cdf0e10cSrcweir                     pOut[n] = new SvFileStream( aTmp, STREAM_WRITE | STREAM_TRUNC );
546cdf0e10cSrcweir                 }
547cdf0e10cSrcweir                 pOut[n]->WriteLine( aHid );
548cdf0e10cSrcweir                 bFound = true;
549cdf0e10cSrcweir                 break;
550cdf0e10cSrcweir             }
551cdf0e10cSrcweir         }
552cdf0e10cSrcweir 
553cdf0e10cSrcweir         if (!bFound)
554cdf0e10cSrcweir         {
555cdf0e10cSrcweir             if (!pOut[8])
556cdf0e10cSrcweir             {
557cdf0e10cSrcweir                 String aTmp( aOut );
558cdf0e10cSrcweir                 aTmp += String( "notfound", RTL_TEXTENCODING_UTF8 );
559cdf0e10cSrcweir                 aTmp += String::CreateFromAscii(".lst");
560cdf0e10cSrcweir                 pOut[8] = new SvFileStream( aTmp, STREAM_WRITE | STREAM_TRUNC );
561cdf0e10cSrcweir             }
562cdf0e10cSrcweir             pOut[8]->WriteLine( aHid );
563cdf0e10cSrcweir         }
564cdf0e10cSrcweir     }
565cdf0e10cSrcweir 
566cdf0e10cSrcweir     for (sal_Int32 n= 0; n<9; n++)
567cdf0e10cSrcweir         DELETEZ( pOut[n] );
568cdf0e10cSrcweir }
569cdf0e10cSrcweir 
570cdf0e10cSrcweir void TestHids4()
571cdf0e10cSrcweir {
572cdf0e10cSrcweir     static const char* aModules[] =
573cdf0e10cSrcweir     {
574cdf0e10cSrcweir         "swriter",
575cdf0e10cSrcweir         "scalc",
576cdf0e10cSrcweir         "simpress",
577cdf0e10cSrcweir         "smath",
578cdf0e10cSrcweir         "sbasic"
579cdf0e10cSrcweir     };
580cdf0e10cSrcweir 
581cdf0e10cSrcweir     String aOut = String::CreateFromAscii("/data/OOo/replacer/quickhelp/");
582cdf0e10cSrcweir     aOut += String::CreateFromAscii("lost.lst");
583cdf0e10cSrcweir     SvFileStream aOutStrm( aOut, STREAM_WRITE | STREAM_TRUNC );
584cdf0e10cSrcweir     for (sal_Int32 n= 0; n<5; n++)
585cdf0e10cSrcweir     {
586cdf0e10cSrcweir         String aIn = String::CreateFromAscii("/data/OOo/replacer/quickhelp/");
587cdf0e10cSrcweir         aIn += String::CreateFromAscii( aModules[n] );
588cdf0e10cSrcweir         aIn += String::CreateFromAscii(".lst");
589cdf0e10cSrcweir         SvFileStream aInStrm( aIn, STREAM_READ );
590cdf0e10cSrcweir         ByteString aBuffer;
591cdf0e10cSrcweir         while ( aInStrm.ReadLine( aBuffer ) )
592cdf0e10cSrcweir         {
593cdf0e10cSrcweir             String aHelpURL = SfxHelp::CreateHelpURL( String( aBuffer, RTL_TEXTENCODING_UTF8 ), String( aModules[n], RTL_TEXTENCODING_UTF8 ) );
594cdf0e10cSrcweir 	        if ( !SfxContentHelper::GetActiveHelpString( aHelpURL ).Len() )
595cdf0e10cSrcweir                 aOutStrm.WriteLine( aBuffer );
596cdf0e10cSrcweir         }
597cdf0e10cSrcweir     }
598cdf0e10cSrcweir }
599cdf0e10cSrcweir */
600cdf0e10cSrcweir 
601cdf0e10cSrcweir SfxHelp::SfxHelp() :
602cdf0e10cSrcweir 
603cdf0e10cSrcweir 	bIsDebug( sal_False ),
604cdf0e10cSrcweir     pImp	( NULL )
605cdf0e10cSrcweir 
606cdf0e10cSrcweir {
607cdf0e10cSrcweir 	// read the environment variable "HELP_DEBUG"
608cdf0e10cSrcweir 	// if it's set, you will see debug output on active help
609cdf0e10cSrcweir 	{
610cdf0e10cSrcweir 		::rtl::OUString sHelpDebug;
611cdf0e10cSrcweir 		::rtl::OUString sEnvVarName( RTL_CONSTASCII_USTRINGPARAM( "HELP_DEBUG" ) );
612cdf0e10cSrcweir 		osl_getEnvironment( sEnvVarName.pData, &sHelpDebug.pData );
613cdf0e10cSrcweir 		bIsDebug = ( 0 != sHelpDebug.getLength() );
614cdf0e10cSrcweir 	}
615cdf0e10cSrcweir 
616cdf0e10cSrcweir 	pImp = new SfxHelp_Impl( bIsDebug );
617cdf0e10cSrcweir 
618cdf0e10cSrcweir     ::rtl::OUString aLocaleStr = HelpLocaleString();
619cdf0e10cSrcweir 
620cdf0e10cSrcweir     sal_Int32 nSepPos = aLocaleStr.indexOf( '_' );
621cdf0e10cSrcweir     if ( nSepPos != -1 )
622cdf0e10cSrcweir     {
623cdf0e10cSrcweir         aLanguageStr = aLocaleStr.copy( 0, nSepPos );
624cdf0e10cSrcweir         aCountryStr = aLocaleStr.copy( nSepPos+1 );
625cdf0e10cSrcweir     }
626cdf0e10cSrcweir     else
627cdf0e10cSrcweir     {
628cdf0e10cSrcweir         nSepPos = aLocaleStr.indexOf( '-' );
629cdf0e10cSrcweir         if ( nSepPos != -1 )
630cdf0e10cSrcweir         {
631cdf0e10cSrcweir             aLanguageStr = aLocaleStr.copy( 0, nSepPos );
632cdf0e10cSrcweir             aCountryStr = aLocaleStr.copy( nSepPos+1 );
633cdf0e10cSrcweir         }
634cdf0e10cSrcweir         else
635cdf0e10cSrcweir         {
636cdf0e10cSrcweir             aLanguageStr = aLocaleStr;
637cdf0e10cSrcweir         }
638cdf0e10cSrcweir     }
639cdf0e10cSrcweir }
640cdf0e10cSrcweir 
641cdf0e10cSrcweir SfxHelp::~SfxHelp()
642cdf0e10cSrcweir {
643cdf0e10cSrcweir     delete pImp;
644cdf0e10cSrcweir }
645cdf0e10cSrcweir 
646cdf0e10cSrcweir ::rtl::OUString getDefaultModule_Impl()
647cdf0e10cSrcweir {
648cdf0e10cSrcweir     rtl::OUString sDefaultModule;
649cdf0e10cSrcweir     SvtModuleOptions aModOpt;
650cdf0e10cSrcweir     if ( aModOpt.IsModuleInstalled( SvtModuleOptions::E_SWRITER ) )
651cdf0e10cSrcweir         sDefaultModule = DEFINE_CONST_UNICODE("swriter");
652cdf0e10cSrcweir     else if ( aModOpt.IsModuleInstalled( SvtModuleOptions::E_SCALC ) )
653cdf0e10cSrcweir         sDefaultModule = DEFINE_CONST_UNICODE("scalc");
654cdf0e10cSrcweir     else if ( aModOpt.IsModuleInstalled( SvtModuleOptions::E_SIMPRESS ) )
655cdf0e10cSrcweir         sDefaultModule = DEFINE_CONST_UNICODE("simpress");
656cdf0e10cSrcweir     else if ( aModOpt.IsModuleInstalled( SvtModuleOptions::E_SDRAW ) )
657cdf0e10cSrcweir         sDefaultModule = DEFINE_CONST_UNICODE("sdraw");
658cdf0e10cSrcweir     else if ( aModOpt.IsModuleInstalled( SvtModuleOptions::E_SMATH ) )
659cdf0e10cSrcweir         sDefaultModule = DEFINE_CONST_UNICODE("smath");
660cdf0e10cSrcweir     else if ( aModOpt.IsModuleInstalled( SvtModuleOptions::E_SCHART ) )
661cdf0e10cSrcweir         sDefaultModule = DEFINE_CONST_UNICODE("schart");
662cdf0e10cSrcweir     else if ( aModOpt.IsModuleInstalled( SvtModuleOptions::E_SBASIC ) )
663cdf0e10cSrcweir         sDefaultModule = DEFINE_CONST_UNICODE("sbasic");
664cdf0e10cSrcweir     else if ( aModOpt.IsModuleInstalled( SvtModuleOptions::E_SDATABASE ) )
665cdf0e10cSrcweir         sDefaultModule = DEFINE_CONST_UNICODE("sdatabase");
666cdf0e10cSrcweir     else
667cdf0e10cSrcweir     {
668cdf0e10cSrcweir         DBG_ERRORFILE( "getDefaultModule_Impl(): no module installed" );
669cdf0e10cSrcweir     }
670cdf0e10cSrcweir     return sDefaultModule;
671cdf0e10cSrcweir }
672cdf0e10cSrcweir 
673cdf0e10cSrcweir ::rtl::OUString getCurrentModuleIdentifier_Impl()
674cdf0e10cSrcweir {
675cdf0e10cSrcweir     ::rtl::OUString sIdentifier;
676cdf0e10cSrcweir     Reference < XFrame > xCurrentFrame;
677cdf0e10cSrcweir     Reference < XModuleManager > xModuleManager( ::comphelper::getProcessServiceFactory()->createInstance(
678cdf0e10cSrcweir         DEFINE_CONST_UNICODE("com.sun.star.frame.ModuleManager") ), UNO_QUERY );
679cdf0e10cSrcweir     Reference < XDesktop > xDesktop( ::comphelper::getProcessServiceFactory()->createInstance(
680cdf0e10cSrcweir         DEFINE_CONST_UNICODE("com.sun.star.frame.Desktop") ), UNO_QUERY );
681cdf0e10cSrcweir     if ( xDesktop.is() )
682cdf0e10cSrcweir         xCurrentFrame = xDesktop->getCurrentFrame();
683cdf0e10cSrcweir 
684cdf0e10cSrcweir     if ( xCurrentFrame.is() && xModuleManager.is() )
685cdf0e10cSrcweir     {
686cdf0e10cSrcweir         try
687cdf0e10cSrcweir         {
688cdf0e10cSrcweir             sIdentifier = xModuleManager->identify( xCurrentFrame );
689cdf0e10cSrcweir         }
690cdf0e10cSrcweir         catch ( ::com::sun::star::frame::UnknownModuleException& )
691cdf0e10cSrcweir         {
692cdf0e10cSrcweir             DBG_WARNING( "SfxHelp::getCurrentModuleIdentifier_Impl(): unknown module (help in help?)" );
693cdf0e10cSrcweir         }
694cdf0e10cSrcweir         catch ( Exception& )
695cdf0e10cSrcweir         {
696cdf0e10cSrcweir             DBG_ERRORFILE( "SfxHelp::getCurrentModuleIdentifier_Impl(): exception of XModuleManager::identify()" );
697cdf0e10cSrcweir         }
698cdf0e10cSrcweir     }
699cdf0e10cSrcweir 
700cdf0e10cSrcweir     return sIdentifier;
701cdf0e10cSrcweir }
702cdf0e10cSrcweir 
703cdf0e10cSrcweir String SfxHelp::GetHelpModuleName_Impl()
704cdf0e10cSrcweir {
705cdf0e10cSrcweir     String sModuleName;
706cdf0e10cSrcweir     rtl::OUString aFactoryShortName;
707cdf0e10cSrcweir     rtl::OUString aModuleIdentifier = getCurrentModuleIdentifier_Impl();
708cdf0e10cSrcweir 
709cdf0e10cSrcweir     if ( aModuleIdentifier.getLength() > 0 )
710cdf0e10cSrcweir     {
711cdf0e10cSrcweir         try
712cdf0e10cSrcweir         {
713cdf0e10cSrcweir             Reference < XModuleManager > xModuleManager(
714cdf0e10cSrcweir                 ::comphelper::getProcessServiceFactory()->createInstance(
715cdf0e10cSrcweir                     DEFINE_CONST_UNICODE("com.sun.star.frame.ModuleManager") ), UNO_QUERY );
716cdf0e10cSrcweir             Sequence< PropertyValue > lProps;
717cdf0e10cSrcweir             Reference< ::com::sun::star::container::XNameAccess > xCont( xModuleManager, UNO_QUERY);
718cdf0e10cSrcweir             if ( xCont.is() )
719cdf0e10cSrcweir                 xCont->getByName( aModuleIdentifier ) >>= lProps;
720cdf0e10cSrcweir             for ( sal_Int32 i = 0; i < lProps.getLength(); ++i )
721cdf0e10cSrcweir             {
722cdf0e10cSrcweir                 if ( lProps[i].Name.equalsAscii("ooSetupFactoryShortName") )
723cdf0e10cSrcweir                 {
724cdf0e10cSrcweir                     lProps[i].Value >>= aFactoryShortName;
725cdf0e10cSrcweir                     break;
726cdf0e10cSrcweir                 }
727cdf0e10cSrcweir             }
728cdf0e10cSrcweir         }
729cdf0e10cSrcweir         catch ( Exception& )
730cdf0e10cSrcweir         {
731cdf0e10cSrcweir             DBG_ERRORFILE( "SfxHelp::GetHelpModuleName_Impl(): exception of XNameAccess::getByName()" );
732cdf0e10cSrcweir         }
733cdf0e10cSrcweir     }
734cdf0e10cSrcweir 
735cdf0e10cSrcweir     rtl::OUString sDefaultModule = getDefaultModule_Impl();
736cdf0e10cSrcweir     if ( aFactoryShortName.getLength() > 0 )
737cdf0e10cSrcweir     {
738cdf0e10cSrcweir         // Map some module identifiers to their "real" help module string.
739cdf0e10cSrcweir         if ( aFactoryShortName.equalsAscii( "chart2" ) )
740cdf0e10cSrcweir             aFactoryShortName = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "schart" ) );
741cdf0e10cSrcweir         else if ( aFactoryShortName.equalsAscii( "BasicIDE" ) )
742cdf0e10cSrcweir             aFactoryShortName = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "sbasic" ) );
743cdf0e10cSrcweir         else if ( aFactoryShortName.equalsAscii( "sweb" )
744cdf0e10cSrcweir                 || aFactoryShortName.equalsAscii( "sglobal" )
745cdf0e10cSrcweir                 || aFactoryShortName.equalsAscii( "swxform" ) )
746cdf0e10cSrcweir             aFactoryShortName = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "swriter" ) );
747cdf0e10cSrcweir         else if ( aFactoryShortName.equalsAscii( "dbquery" )
748cdf0e10cSrcweir                 || aFactoryShortName.equalsAscii( "dbbrowser" )
749cdf0e10cSrcweir                 || aFactoryShortName.equalsAscii( "dbrelation" )
750cdf0e10cSrcweir                 || aFactoryShortName.equalsAscii( "dbtable" )
751cdf0e10cSrcweir                 || aFactoryShortName.equalsAscii( "dbapp" )
752cdf0e10cSrcweir                 || aFactoryShortName.equalsAscii( "dbreport" )
753cdf0e10cSrcweir                 || aFactoryShortName.equalsAscii( "swreport" )
754cdf0e10cSrcweir                 || aFactoryShortName.equalsAscii( "dbbrowser" )
755cdf0e10cSrcweir                 || aFactoryShortName.equalsAscii( "swform" ) )
756cdf0e10cSrcweir             aFactoryShortName = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "sdatabase" ) );
757cdf0e10cSrcweir         else if ( aFactoryShortName.equalsAscii( "sbibliography" )
758cdf0e10cSrcweir                 || aFactoryShortName.equalsAscii( "StartModule" ) )
759cdf0e10cSrcweir             aFactoryShortName = sDefaultModule;
760cdf0e10cSrcweir     }
761cdf0e10cSrcweir     else
762cdf0e10cSrcweir         aFactoryShortName = sDefaultModule;
763cdf0e10cSrcweir 
764cdf0e10cSrcweir     sModuleName = String( aFactoryShortName );
765cdf0e10cSrcweir     return sModuleName;
766cdf0e10cSrcweir }
767cdf0e10cSrcweir 
768cdf0e10cSrcweir String	SfxHelp::CreateHelpURL_Impl( const String& aCommandURL, const String& rModuleName )
769cdf0e10cSrcweir {
770cdf0e10cSrcweir 	// build up the help URL
771cdf0e10cSrcweir     String aHelpURL;
772cdf0e10cSrcweir 	sal_Bool bHasAnchor = sal_False;
773cdf0e10cSrcweir 	String aAnchor;
774cdf0e10cSrcweir 
775cdf0e10cSrcweir 	String aModuleName( rModuleName );
776cdf0e10cSrcweir 	if ( aModuleName.Len() == 0 )
777cdf0e10cSrcweir         aModuleName = getDefaultModule_Impl();
778cdf0e10cSrcweir 
779cdf0e10cSrcweir     aHelpURL = String::CreateFromAscii("vnd.sun.star.help://");
780cdf0e10cSrcweir     aHelpURL += aModuleName;
781cdf0e10cSrcweir 
782cdf0e10cSrcweir     if ( !aCommandURL.Len() )
783cdf0e10cSrcweir         aHelpURL += String::CreateFromAscii("/start");
784cdf0e10cSrcweir     else
785cdf0e10cSrcweir     {
786cdf0e10cSrcweir         aHelpURL += '/';
787cdf0e10cSrcweir         aHelpURL += String( rtl::Uri::encode( aCommandURL,
788cdf0e10cSrcweir                                               rtl_UriCharClassRelSegment,
789cdf0e10cSrcweir                                               rtl_UriEncodeKeepEscapes,
790cdf0e10cSrcweir                                               RTL_TEXTENCODING_UTF8 ));
791cdf0e10cSrcweir 
792cdf0e10cSrcweir 		String aTempURL = aHelpURL;
793cdf0e10cSrcweir 	    AppendConfigToken_Impl( aTempURL, sal_True );
794cdf0e10cSrcweir 		bHasAnchor = GetHelpAnchor_Impl( aTempURL, aAnchor );
795cdf0e10cSrcweir 	}
796cdf0e10cSrcweir 
797cdf0e10cSrcweir     AppendConfigToken_Impl( aHelpURL, sal_True );
798cdf0e10cSrcweir 
799cdf0e10cSrcweir 	if ( bHasAnchor )
800cdf0e10cSrcweir 	{
801cdf0e10cSrcweir 		aHelpURL += '#';
802cdf0e10cSrcweir 		aHelpURL += aAnchor;
803cdf0e10cSrcweir 	}
804cdf0e10cSrcweir 
805cdf0e10cSrcweir     return aHelpURL;
806cdf0e10cSrcweir }
807cdf0e10cSrcweir 
808cdf0e10cSrcweir SfxHelpWindow_Impl* impl_createHelp(Reference< XFrame >& rHelpTask   ,
809cdf0e10cSrcweir                                     Reference< XFrame >& rHelpContent)
810cdf0e10cSrcweir {
811cdf0e10cSrcweir     Reference < XFrame > xDesktop( ::comphelper::getProcessServiceFactory()->createInstance(
812cdf0e10cSrcweir 		DEFINE_CONST_UNICODE("com.sun.star.frame.Desktop") ), UNO_QUERY );
813cdf0e10cSrcweir 
814cdf0e10cSrcweir     // otherwhise - create new help task
815cdf0e10cSrcweir     Reference< XFrame > xHelpTask = xDesktop->findFrame(
816cdf0e10cSrcweir         ::rtl::OUString(DEFINE_CONST_UNICODE("OFFICE_HELP_TASK")),
817cdf0e10cSrcweir         FrameSearchFlag::TASKS | FrameSearchFlag::CREATE);
818cdf0e10cSrcweir     if (!xHelpTask.is())
819cdf0e10cSrcweir         return 0;
820cdf0e10cSrcweir 
821cdf0e10cSrcweir     // create all internal windows and sub frames ...
822cdf0e10cSrcweir     Reference< ::com::sun::star::awt::XWindow > xParentWindow = xHelpTask->getContainerWindow();
823cdf0e10cSrcweir     Window*                                     pParentWindow = VCLUnoHelper::GetWindow( xParentWindow );
824cdf0e10cSrcweir     SfxHelpWindow_Impl*                         pHelpWindow   = new SfxHelpWindow_Impl( xHelpTask, pParentWindow, WB_DOCKBORDER );
825cdf0e10cSrcweir     Reference< ::com::sun::star::awt::XWindow > xHelpWindow   = VCLUnoHelper::GetInterface( pHelpWindow );
826cdf0e10cSrcweir 
827cdf0e10cSrcweir     Reference< XFrame > xHelpContent;
828cdf0e10cSrcweir     if (xHelpTask->setComponent( xHelpWindow, Reference< XController >() ))
829cdf0e10cSrcweir     {
830cdf0e10cSrcweir         // Customize UI ...
831cdf0e10cSrcweir         xHelpTask->setName( ::rtl::OUString(DEFINE_CONST_UNICODE("OFFICE_HELP_TASK")) );
832cdf0e10cSrcweir 
833cdf0e10cSrcweir         Reference< XPropertySet > xProps(xHelpTask, UNO_QUERY);
834cdf0e10cSrcweir         if (xProps.is())
835cdf0e10cSrcweir             xProps->setPropertyValue(
836cdf0e10cSrcweir                 DEFINE_CONST_UNICODE("Title"),
837cdf0e10cSrcweir                 makeAny(::rtl::OUString(String(SfxResId(STR_HELP_WINDOW_TITLE)))));
838cdf0e10cSrcweir 
839cdf0e10cSrcweir         pHelpWindow->setContainerWindow( xParentWindow );
840cdf0e10cSrcweir         xParentWindow->setVisible(sal_True);
841cdf0e10cSrcweir         xHelpWindow->setVisible(sal_True);
842cdf0e10cSrcweir 
843cdf0e10cSrcweir         // This sub frame is created internaly (if we called new SfxHelpWindow_Impl() ...)
844cdf0e10cSrcweir         // It should exist :-)
845cdf0e10cSrcweir         xHelpContent = xHelpTask->findFrame(::rtl::OUString(DEFINE_CONST_UNICODE("OFFICE_HELP")), FrameSearchFlag::CHILDREN);
846cdf0e10cSrcweir     }
847cdf0e10cSrcweir 
848cdf0e10cSrcweir     if (!xHelpContent.is())
849cdf0e10cSrcweir         delete pHelpWindow;
850cdf0e10cSrcweir 
851cdf0e10cSrcweir     xHelpContent->setName(::rtl::OUString(DEFINE_CONST_UNICODE("OFFICE_HELP")));
852cdf0e10cSrcweir 
853cdf0e10cSrcweir     rHelpTask    = xHelpTask;
854cdf0e10cSrcweir     rHelpContent = xHelpContent;
855cdf0e10cSrcweir     return pHelpWindow;
856cdf0e10cSrcweir }
857cdf0e10cSrcweir 
858cdf0e10cSrcweir XubString SfxHelp::GetHelpText( const String& aCommandURL, const Window* pWindow )
859cdf0e10cSrcweir {
860cdf0e10cSrcweir     String sModuleName = GetHelpModuleName_Impl();
861cdf0e10cSrcweir     String sHelpText = pImp->GetHelpText( aCommandURL, sModuleName );
862cdf0e10cSrcweir 
863cdf0e10cSrcweir 	ByteString aNewHelpId;
864cdf0e10cSrcweir 
865cdf0e10cSrcweir 	if ( pWindow && !sHelpText.Len() )
866cdf0e10cSrcweir 	{
867cdf0e10cSrcweir 		// no help text found -> try with parent help id.
868cdf0e10cSrcweir 		Window* pParent = pWindow->GetParent();
869cdf0e10cSrcweir 		while ( pParent )
870cdf0e10cSrcweir 		{
871cdf0e10cSrcweir 			aNewHelpId = pParent->GetHelpId();
872cdf0e10cSrcweir 			sHelpText = pImp->GetHelpText( String( aNewHelpId, RTL_TEXTENCODING_UTF8 ), sModuleName );
873cdf0e10cSrcweir 			if ( sHelpText.Len() > 0 )
874cdf0e10cSrcweir 				pParent = NULL;
875cdf0e10cSrcweir 			else
876cdf0e10cSrcweir 				pParent = pParent->GetParent();
877cdf0e10cSrcweir 		}
878cdf0e10cSrcweir 
879cdf0e10cSrcweir 		if ( bIsDebug && !sHelpText.Len() )
880cdf0e10cSrcweir 			aNewHelpId.Erase();
881cdf0e10cSrcweir 	}
882cdf0e10cSrcweir 
883cdf0e10cSrcweir     // add some debug information?
884cdf0e10cSrcweir     if ( bIsDebug )
885cdf0e10cSrcweir     {
886cdf0e10cSrcweir         sHelpText += DEFINE_CONST_UNICODE("\n-------------\n");
887cdf0e10cSrcweir         sHelpText += String( sModuleName );
888cdf0e10cSrcweir         sHelpText += DEFINE_CONST_UNICODE(": ");
889cdf0e10cSrcweir         sHelpText += aCommandURL;
890cdf0e10cSrcweir 		if ( aNewHelpId.Len() )
891cdf0e10cSrcweir 		{
892cdf0e10cSrcweir 			sHelpText += DEFINE_CONST_UNICODE(" - ");
893cdf0e10cSrcweir 			sHelpText += String( aNewHelpId, RTL_TEXTENCODING_UTF8 );
894cdf0e10cSrcweir 		}
895cdf0e10cSrcweir     }
896cdf0e10cSrcweir 
897cdf0e10cSrcweir     return sHelpText;
898cdf0e10cSrcweir }
899cdf0e10cSrcweir 
900cdf0e10cSrcweir sal_Bool SfxHelp::SearchKeyword( const XubString& rKeyword )
901cdf0e10cSrcweir {
902cdf0e10cSrcweir 	return Start_Impl( String(), NULL, rKeyword );
903cdf0e10cSrcweir }
904cdf0e10cSrcweir 
905cdf0e10cSrcweir sal_Bool SfxHelp::Start( const String& rURL, const Window* pWindow )
906cdf0e10cSrcweir {
907cdf0e10cSrcweir     return Start_Impl( rURL, pWindow, String() );
908cdf0e10cSrcweir }
909cdf0e10cSrcweir 
910cdf0e10cSrcweir sal_Bool SfxHelp::Start_Impl( const String& rURL, const Window* pWindow, const String& rKeyword )
911cdf0e10cSrcweir {
912cdf0e10cSrcweir     // check if help is available
913cdf0e10cSrcweir     String aHelpRootURL( DEFINE_CONST_OUSTRING("vnd.sun.star.help://") );
914cdf0e10cSrcweir     AppendConfigToken_Impl( aHelpRootURL, sal_True );
915cdf0e10cSrcweir     Sequence< ::rtl::OUString > aFactories = SfxContentHelper::GetResultSet( aHelpRootURL );
916cdf0e10cSrcweir     if ( 0 == aFactories.getLength() )
917cdf0e10cSrcweir     {
918cdf0e10cSrcweir         // no factories -> no help -> error message and return
919cdf0e10cSrcweir         NoHelpErrorBox aErrBox( const_cast< Window* >( pWindow ) );
920cdf0e10cSrcweir         aErrBox.Execute();
921cdf0e10cSrcweir         return sal_False;
922cdf0e10cSrcweir     }
923cdf0e10cSrcweir 
924cdf0e10cSrcweir 	/* rURL may be
925cdf0e10cSrcweir 		- a "real" URL
926cdf0e10cSrcweir 		- a HelpID (formerly a long, now a string)
927cdf0e10cSrcweir 	   If rURL is a URL, CreateHelpURL should be called for this URL
928cdf0e10cSrcweir 	   If rURL is an arbitrary string, the same should happen, but the URL should be tried out
929cdf0e10cSrcweir 	   if it delivers real help content. In case only the Help Error Document is returned, the
930cdf0e10cSrcweir 	   parent of the window for that help was called, is asked for its HelpID.
931cdf0e10cSrcweir 	   For compatibility reasons this upward search is not implemented for "real" URLs.
932cdf0e10cSrcweir 	   Help keyword search now is implemented as own method; in former versions it
933cdf0e10cSrcweir 	   was done via Help::Start, but this implementation conflicted with the upward search.
934cdf0e10cSrcweir 	*/
935cdf0e10cSrcweir 	String aHelpURL;
936cdf0e10cSrcweir 	INetURLObject aParser( rURL );
937cdf0e10cSrcweir     INetProtocol nProtocol = aParser.GetProtocol();
938cdf0e10cSrcweir 	String aHelpModuleName( GetHelpModuleName_Impl() );
939cdf0e10cSrcweir 	switch ( nProtocol )
940cdf0e10cSrcweir 	{
941cdf0e10cSrcweir 		case INET_PROT_VND_SUN_STAR_HELP:
942cdf0e10cSrcweir 			// already a vnd.sun.star.help URL -> nothing to do
943cdf0e10cSrcweir 			aHelpURL = rURL;
944cdf0e10cSrcweir 			break;
945cdf0e10cSrcweir 		default:
946cdf0e10cSrcweir 		{
947cdf0e10cSrcweir 			// no URL, just a HelpID (maybe empty in case of keyword search)
948cdf0e10cSrcweir 			aHelpURL  = CreateHelpURL_Impl( rURL, aHelpModuleName );
949cdf0e10cSrcweir 			if ( pWindow && SfxContentHelper::IsHelpErrorDocument( aHelpURL ) )
950cdf0e10cSrcweir 			{
951cdf0e10cSrcweir 				// no help found -> try with parent help id.
952cdf0e10cSrcweir 				Window* pParent = pWindow->GetParent();
953cdf0e10cSrcweir 				while ( pParent )
954cdf0e10cSrcweir 				{
955cdf0e10cSrcweir 					ByteString aHelpId = pParent->GetHelpId();
956cdf0e10cSrcweir 					aHelpURL = CreateHelpURL( String( aHelpId, RTL_TEXTENCODING_UTF8 ), aHelpModuleName );
957cdf0e10cSrcweir 					if ( !SfxContentHelper::IsHelpErrorDocument( aHelpURL ) )
958cdf0e10cSrcweir 						break;
959cdf0e10cSrcweir 					else
960cdf0e10cSrcweir 					{
961cdf0e10cSrcweir 						pParent = pParent->GetParent();
962cdf0e10cSrcweir 						if ( !pParent )
963cdf0e10cSrcweir 							// create help url of start page ( helpid == 0 -> start page)
964cdf0e10cSrcweir 							aHelpURL = CreateHelpURL( String(), aHelpModuleName );
965cdf0e10cSrcweir 					}
966cdf0e10cSrcweir 				}
967cdf0e10cSrcweir 			}
968cdf0e10cSrcweir 			break;
969cdf0e10cSrcweir 		}
970cdf0e10cSrcweir 	}
971cdf0e10cSrcweir 
972cdf0e10cSrcweir     Reference < XFrame > xDesktop( ::comphelper::getProcessServiceFactory()->createInstance(
973cdf0e10cSrcweir 		DEFINE_CONST_UNICODE("com.sun.star.frame.Desktop") ), UNO_QUERY );
974cdf0e10cSrcweir 
975cdf0e10cSrcweir     // check if help window is still open
976cdf0e10cSrcweir     // If not, create a new one and return access directly to the internal sub frame showing the help content
977cdf0e10cSrcweir 	// search must be done here; search one desktop level could return an arbitraty frame
978cdf0e10cSrcweir     Reference< XFrame > xHelp = xDesktop->findFrame(
979cdf0e10cSrcweir         ::rtl::OUString(DEFINE_CONST_UNICODE("OFFICE_HELP_TASK")),
980cdf0e10cSrcweir         FrameSearchFlag::CHILDREN);
981cdf0e10cSrcweir     Reference< XFrame > xHelpContent = xDesktop->findFrame(
982cdf0e10cSrcweir         ::rtl::OUString(DEFINE_CONST_UNICODE("OFFICE_HELP")),
983cdf0e10cSrcweir         FrameSearchFlag::CHILDREN);
984cdf0e10cSrcweir 
985cdf0e10cSrcweir     SfxHelpWindow_Impl* pHelpWindow = 0;
986cdf0e10cSrcweir     if (!xHelp.is())
987cdf0e10cSrcweir         pHelpWindow = impl_createHelp(xHelp, xHelpContent);
988cdf0e10cSrcweir     else
989cdf0e10cSrcweir         pHelpWindow = (SfxHelpWindow_Impl*)VCLUnoHelper::GetWindow(xHelp->getComponentWindow());
990cdf0e10cSrcweir     if (!xHelp.is() || !xHelpContent.is() || !pHelpWindow)
991cdf0e10cSrcweir         return sal_False;
992cdf0e10cSrcweir 
993cdf0e10cSrcweir #ifdef DBG_UTIL
994cdf0e10cSrcweir     ByteString aTmp("SfxHelp: HelpId = ");
995cdf0e10cSrcweir     aTmp += ByteString( aHelpURL, RTL_TEXTENCODING_UTF8 );
996cdf0e10cSrcweir     DBG_TRACE( aTmp.GetBuffer() );
997cdf0e10cSrcweir #endif
998cdf0e10cSrcweir 
999cdf0e10cSrcweir     pHelpWindow->SetHelpURL( aHelpURL );
1000cdf0e10cSrcweir     pHelpWindow->loadHelpContent(aHelpURL);
1001cdf0e10cSrcweir     if ( rKeyword.Len() )
1002cdf0e10cSrcweir 		pHelpWindow->OpenKeyword( rKeyword );
1003cdf0e10cSrcweir 
1004cdf0e10cSrcweir 	Reference < ::com::sun::star::awt::XTopWindow > xTopWindow( xHelp->getContainerWindow(), UNO_QUERY );
1005cdf0e10cSrcweir     if ( xTopWindow.is() )
1006cdf0e10cSrcweir         xTopWindow->toFront();
1007cdf0e10cSrcweir 
1008cdf0e10cSrcweir     return sal_True;
1009cdf0e10cSrcweir }
1010cdf0e10cSrcweir 
1011cdf0e10cSrcweir String SfxHelp::CreateHelpURL( const String& aCommandURL, const String& rModuleName )
1012cdf0e10cSrcweir {
1013cdf0e10cSrcweir 	String aURL;
1014cdf0e10cSrcweir 	SfxHelp* pHelp = SAL_STATIC_CAST( SfxHelp*, Application::GetHelp() );
1015cdf0e10cSrcweir 	if ( pHelp )
1016cdf0e10cSrcweir 		aURL = pHelp->CreateHelpURL_Impl( aCommandURL, rModuleName );
1017cdf0e10cSrcweir 	return aURL;
1018cdf0e10cSrcweir }
1019cdf0e10cSrcweir 
1020cdf0e10cSrcweir void SfxHelp::OpenHelpAgent( SfxFrame*, const rtl::OString& sHelpId )
1021cdf0e10cSrcweir {
1022cdf0e10cSrcweir 	SfxHelp* pHelp = SAL_STATIC_CAST( SfxHelp*, Application::GetHelp() );
1023cdf0e10cSrcweir 	if ( pHelp )
1024cdf0e10cSrcweir 		pHelp->OpenHelpAgent( sHelpId );
1025cdf0e10cSrcweir }
1026cdf0e10cSrcweir 
1027cdf0e10cSrcweir void SfxHelp::OpenHelpAgent( const rtl::OString& sHelpId )
1028cdf0e10cSrcweir {
1029cdf0e10cSrcweir 	if ( SvtHelpOptions().IsHelpAgentAutoStartMode() )
1030cdf0e10cSrcweir 	{
1031cdf0e10cSrcweir 			SfxHelpOptions_Impl *pOpt = pImp->GetOptions();
1032cdf0e10cSrcweir     		if ( !pOpt->HasId( sHelpId ) )
1033cdf0e10cSrcweir         		return;
1034cdf0e10cSrcweir 
1035cdf0e10cSrcweir 			try
1036cdf0e10cSrcweir 			{
1037cdf0e10cSrcweir 				URL aURL;
1038cdf0e10cSrcweir                 aURL.Complete = CreateHelpURL_Impl( String( ByteString(sHelpId), RTL_TEXTENCODING_UTF8 ), GetHelpModuleName_Impl() );
1039cdf0e10cSrcweir         		Reference < XURLTransformer > xTrans( ::comphelper::getProcessServiceFactory()->createInstance(
1040cdf0e10cSrcweir 					::rtl::OUString::createFromAscii("com.sun.star.util.URLTransformer" ) ), UNO_QUERY );
1041cdf0e10cSrcweir         		xTrans->parseStrict(aURL);
1042cdf0e10cSrcweir 
1043cdf0e10cSrcweir 				Reference < XFrame > xCurrentFrame;
1044cdf0e10cSrcweir 				Reference < XDesktop > xDesktop( ::comphelper::getProcessServiceFactory()->createInstance(
1045cdf0e10cSrcweir 					DEFINE_CONST_UNICODE("com.sun.star.frame.Desktop") ), UNO_QUERY );
1046cdf0e10cSrcweir 				if ( xDesktop.is() )
1047cdf0e10cSrcweir 					xCurrentFrame = xDesktop->getCurrentFrame();
1048cdf0e10cSrcweir 
1049cdf0e10cSrcweir         		Reference< XDispatchProvider > xDispProv( xCurrentFrame, UNO_QUERY );
1050cdf0e10cSrcweir 				Reference< XDispatch > xHelpDispatch;
1051cdf0e10cSrcweir 				if ( xDispProv.is() )
1052cdf0e10cSrcweir 					xHelpDispatch = xDispProv->queryDispatch(
1053cdf0e10cSrcweir 						aURL, ::rtl::OUString::createFromAscii("_helpagent"),
1054cdf0e10cSrcweir 						FrameSearchFlag::PARENT | FrameSearchFlag::SELF );
1055cdf0e10cSrcweir 
1056cdf0e10cSrcweir         		DBG_ASSERT( xHelpDispatch.is(), "OpenHelpAgent: could not get a dispatcher!" );
1057cdf0e10cSrcweir 				if ( xHelpDispatch.is() )
1058cdf0e10cSrcweir 					xHelpDispatch->dispatch( aURL, Sequence< PropertyValue >() );
1059cdf0e10cSrcweir 			}
1060cdf0e10cSrcweir 			catch( const Exception& )
1061cdf0e10cSrcweir 			{
1062cdf0e10cSrcweir         		DBG_ERRORFILE( "OpenHelpAgent: caught an exception while executing the dispatch!" );
1063cdf0e10cSrcweir 			}
1064cdf0e10cSrcweir 	}
1065cdf0e10cSrcweir }
1066cdf0e10cSrcweir 
1067cdf0e10cSrcweir String SfxHelp::GetDefaultHelpModule()
1068cdf0e10cSrcweir {
1069cdf0e10cSrcweir     return getDefaultModule_Impl();
1070cdf0e10cSrcweir }
1071cdf0e10cSrcweir 
1072cdf0e10cSrcweir ::rtl::OUString SfxHelp::GetCurrentModuleIdentifier()
1073cdf0e10cSrcweir {
1074cdf0e10cSrcweir     return getCurrentModuleIdentifier_Impl();
1075cdf0e10cSrcweir }
1076cdf0e10cSrcweir 
1077