xref: /trunk/main/sfx2/source/appl/newhelp.cxx (revision cdf0e10c)
1*cdf0e10cSrcweir /*************************************************************************
2*cdf0e10cSrcweir  *
3*cdf0e10cSrcweir  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4*cdf0e10cSrcweir  *
5*cdf0e10cSrcweir  * Copyright 2000, 2010 Oracle and/or its affiliates.
6*cdf0e10cSrcweir  *
7*cdf0e10cSrcweir  * OpenOffice.org - a multi-platform office productivity suite
8*cdf0e10cSrcweir  *
9*cdf0e10cSrcweir  * This file is part of OpenOffice.org.
10*cdf0e10cSrcweir  *
11*cdf0e10cSrcweir  * OpenOffice.org is free software: you can redistribute it and/or modify
12*cdf0e10cSrcweir  * it under the terms of the GNU Lesser General Public License version 3
13*cdf0e10cSrcweir  * only, as published by the Free Software Foundation.
14*cdf0e10cSrcweir  *
15*cdf0e10cSrcweir  * OpenOffice.org is distributed in the hope that it will be useful,
16*cdf0e10cSrcweir  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17*cdf0e10cSrcweir  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18*cdf0e10cSrcweir  * GNU Lesser General Public License version 3 for more details
19*cdf0e10cSrcweir  * (a copy is included in the LICENSE file that accompanied this code).
20*cdf0e10cSrcweir  *
21*cdf0e10cSrcweir  * You should have received a copy of the GNU Lesser General Public License
22*cdf0e10cSrcweir  * version 3 along with OpenOffice.org.  If not, see
23*cdf0e10cSrcweir  * <http://www.openoffice.org/license.html>
24*cdf0e10cSrcweir  * for a copy of the LGPLv3 License.
25*cdf0e10cSrcweir  *
26*cdf0e10cSrcweir  ************************************************************************/
27*cdf0e10cSrcweir 
28*cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
29*cdf0e10cSrcweir #include "precompiled_sfx2.hxx"
30*cdf0e10cSrcweir 
31*cdf0e10cSrcweir #include "newhelp.hxx"
32*cdf0e10cSrcweir #include <sfx2/sfxuno.hxx>
33*cdf0e10cSrcweir #include "sfx2/sfxresid.hxx"
34*cdf0e10cSrcweir #include "helpinterceptor.hxx"
35*cdf0e10cSrcweir #include "helper.hxx"
36*cdf0e10cSrcweir #include <sfx2/msgpool.hxx>
37*cdf0e10cSrcweir #include <sfx2/app.hxx>
38*cdf0e10cSrcweir #include "sfxtypes.hxx"
39*cdf0e10cSrcweir #include "panelist.hxx"
40*cdf0e10cSrcweir #include "sfx2/imgmgr.hxx"
41*cdf0e10cSrcweir #include "srchdlg.hxx"
42*cdf0e10cSrcweir #include "sfx2/sfxhelp.hxx"
43*cdf0e10cSrcweir 
44*cdf0e10cSrcweir #include "app.hrc"
45*cdf0e10cSrcweir #include "newhelp.hrc"
46*cdf0e10cSrcweir #include "helpid.hrc"
47*cdf0e10cSrcweir 
48*cdf0e10cSrcweir #include <hash_map>
49*cdf0e10cSrcweir #include <rtl/ustrbuf.hxx>
50*cdf0e10cSrcweir #include <comphelper/processfactory.hxx>
51*cdf0e10cSrcweir #include <comphelper/configurationhelper.hxx>
52*cdf0e10cSrcweir #include <toolkit/helper/vclunohelper.hxx>
53*cdf0e10cSrcweir #include <com/sun/star/util/XModifiable.hpp>
54*cdf0e10cSrcweir #include <com/sun/star/frame/XComponentLoader.hpp>
55*cdf0e10cSrcweir #include <com/sun/star/util/XCloseable.hpp>
56*cdf0e10cSrcweir #include <com/sun/star/util/CloseVetoException.hpp>
57*cdf0e10cSrcweir #include <com/sun/star/lang/XComponent.hpp>
58*cdf0e10cSrcweir #include <com/sun/star/lang/DisposedException.hpp>
59*cdf0e10cSrcweir #include <com/sun/star/awt/PosSize.hpp>
60*cdf0e10cSrcweir #include <com/sun/star/awt/XWindow.hpp>
61*cdf0e10cSrcweir #include <com/sun/star/beans/Property.hpp>
62*cdf0e10cSrcweir #include <com/sun/star/beans/PropertyValue.hpp>
63*cdf0e10cSrcweir #include <com/sun/star/beans/XPropertySetInfo.hpp>
64*cdf0e10cSrcweir #include <com/sun/star/container/XIndexAccess.hpp>
65*cdf0e10cSrcweir #include <com/sun/star/frame/XTitle.hpp>
66*cdf0e10cSrcweir #include <com/sun/star/frame/XLayoutManager.hpp>
67*cdf0e10cSrcweir #include <com/sun/star/frame/DispatchResultState.hpp>
68*cdf0e10cSrcweir #include <com/sun/star/frame/XController.hpp>
69*cdf0e10cSrcweir #include <com/sun/star/frame/XDispatch.hpp>
70*cdf0e10cSrcweir #include <com/sun/star/frame/XDispatchProvider.hpp>
71*cdf0e10cSrcweir #include <com/sun/star/frame/XDispatchProviderInterception.hpp>
72*cdf0e10cSrcweir #include <com/sun/star/frame/XFrame.hpp>
73*cdf0e10cSrcweir #ifndef _COM_SUN_STAR_TEXT_XBREAKITERATOR_HPP_
74*cdf0e10cSrcweir #include <com/sun/star/i18n/XBreakIterator.hpp>
75*cdf0e10cSrcweir #endif
76*cdf0e10cSrcweir #include <com/sun/star/i18n/WordType.hpp>
77*cdf0e10cSrcweir #include <com/sun/star/lang/XComponent.hpp>
78*cdf0e10cSrcweir #include <com/sun/star/style/XStyle.hpp>
79*cdf0e10cSrcweir #include <com/sun/star/style/XStyleFamiliesSupplier.hpp>
80*cdf0e10cSrcweir #include <com/sun/star/text/XText.hpp>
81*cdf0e10cSrcweir #include <com/sun/star/text/XTextCursor.hpp>
82*cdf0e10cSrcweir #include <com/sun/star/text/XTextDocument.hpp>
83*cdf0e10cSrcweir #include <com/sun/star/text/XTextRange.hpp>
84*cdf0e10cSrcweir #include <com/sun/star/text/XTextViewCursor.hpp>
85*cdf0e10cSrcweir #include <com/sun/star/text/XTextViewCursorSupplier.hpp>
86*cdf0e10cSrcweir #include <com/sun/star/ucb/CommandAbortedException.hpp>
87*cdf0e10cSrcweir #include <com/sun/star/util/URL.hpp>
88*cdf0e10cSrcweir #include <com/sun/star/util/XSearchable.hpp>
89*cdf0e10cSrcweir #include <com/sun/star/util/XSearchDescriptor.hpp>
90*cdf0e10cSrcweir #include <com/sun/star/util/XURLTransformer.hpp>
91*cdf0e10cSrcweir #include <com/sun/star/view/XSelectionSupplier.hpp>
92*cdf0e10cSrcweir #include <com/sun/star/view/XViewSettingsSupplier.hpp>
93*cdf0e10cSrcweir #include <com/sun/star/ui/XDockingAreaAcceptor.hpp>
94*cdf0e10cSrcweir #include <svtools/helpopt.hxx>
95*cdf0e10cSrcweir #include <unotools/historyoptions.hxx>
96*cdf0e10cSrcweir #include <svtools/menuoptions.hxx>
97*cdf0e10cSrcweir #include <unotools/pathoptions.hxx>
98*cdf0e10cSrcweir #include <unotools/viewoptions.hxx>
99*cdf0e10cSrcweir #include <svtools/svtdata.hxx>
100*cdf0e10cSrcweir #include <tools/urlobj.hxx>
101*cdf0e10cSrcweir #include <tools/cachestr.hxx>
102*cdf0e10cSrcweir #include <unotools/streamhelper.hxx>
103*cdf0e10cSrcweir #include <svtools/imagemgr.hxx>
104*cdf0e10cSrcweir #include <svtools/miscopt.hxx>
105*cdf0e10cSrcweir #include <svtools/imgdef.hxx>
106*cdf0e10cSrcweir #include <vcl/unohelp.hxx>
107*cdf0e10cSrcweir #include <vcl/i18nhelp.hxx>
108*cdf0e10cSrcweir 
109*cdf0e10cSrcweir #include <ucbhelper/content.hxx>
110*cdf0e10cSrcweir #include <vcl/msgbox.hxx>
111*cdf0e10cSrcweir #include <vcl/waitobj.hxx>
112*cdf0e10cSrcweir #include <unotools/ucbhelper.hxx>
113*cdf0e10cSrcweir 
114*cdf0e10cSrcweir #include <sfx2/viewfrm.hxx>
115*cdf0e10cSrcweir #include <sfx2/objsh.hxx>
116*cdf0e10cSrcweir #include <sfx2/docfac.hxx>
117*cdf0e10cSrcweir 
118*cdf0e10cSrcweir using namespace ::ucbhelper;
119*cdf0e10cSrcweir using namespace ::com::sun::star::ucb;
120*cdf0e10cSrcweir 
121*cdf0e10cSrcweir using namespace ::com::sun::star;
122*cdf0e10cSrcweir using namespace ::com::sun::star::beans;
123*cdf0e10cSrcweir using namespace ::com::sun::star::container;
124*cdf0e10cSrcweir using namespace ::com::sun::star::frame;
125*cdf0e10cSrcweir using namespace ::com::sun::star::i18n;
126*cdf0e10cSrcweir using namespace ::com::sun::star::lang;
127*cdf0e10cSrcweir using namespace ::com::sun::star::style;
128*cdf0e10cSrcweir using namespace ::com::sun::star::text;
129*cdf0e10cSrcweir using namespace ::com::sun::star::uno;
130*cdf0e10cSrcweir using namespace ::com::sun::star::util;
131*cdf0e10cSrcweir using namespace ::com::sun::star::view;
132*cdf0e10cSrcweir using namespace ::com::sun::star::ui;
133*cdf0e10cSrcweir 
134*cdf0e10cSrcweir using namespace ::comphelper;
135*cdf0e10cSrcweir 
136*cdf0e10cSrcweir extern void AppendConfigToken_Impl( String& rURL, sal_Bool bQuestionMark ); // sfxhelp.cxx
137*cdf0e10cSrcweir 
138*cdf0e10cSrcweir // defines ---------------------------------------------------------------
139*cdf0e10cSrcweir 
140*cdf0e10cSrcweir #define SPLITSET_ID			0
141*cdf0e10cSrcweir #define COLSET_ID			1
142*cdf0e10cSrcweir #define INDEXWIN_ID			2
143*cdf0e10cSrcweir #define TEXTWIN_ID			3
144*cdf0e10cSrcweir 
145*cdf0e10cSrcweir #define TOOLBOX_OFFSET		3
146*cdf0e10cSrcweir 
147*cdf0e10cSrcweir #define TBI_INDEX			1001
148*cdf0e10cSrcweir #define TBI_BACKWARD		1002
149*cdf0e10cSrcweir #define TBI_FORWARD			1003
150*cdf0e10cSrcweir #define TBI_START			1004
151*cdf0e10cSrcweir #define TBI_PRINT			1005
152*cdf0e10cSrcweir #define TBI_COPY			1006
153*cdf0e10cSrcweir #define TBI_BOOKMARKS		1007
154*cdf0e10cSrcweir #define TBI_SEARCHDIALOG	1008
155*cdf0e10cSrcweir #define TBI_SOURCEVIEW		1009
156*cdf0e10cSrcweir #define TBI_SELECTIONMODE   1010
157*cdf0e10cSrcweir #define TBI_ONSTARTUP		1011
158*cdf0e10cSrcweir 
159*cdf0e10cSrcweir #define CONFIGNAME_HELPWIN		DEFINE_CONST_UNICODE("OfficeHelp")
160*cdf0e10cSrcweir #define CONFIGNAME_INDEXWIN		DEFINE_CONST_UNICODE("OfficeHelpIndex")
161*cdf0e10cSrcweir #define CONFIGNAME_SEARCHPAGE	DEFINE_CONST_UNICODE("OfficeHelpSearch")
162*cdf0e10cSrcweir #define IMAGE_URL				DEFINE_CONST_UNICODE("private:factory/")
163*cdf0e10cSrcweir 
164*cdf0e10cSrcweir #define PROPERTY_KEYWORDLIST	DEFINE_CONST_OUSTRING("KeywordList")
165*cdf0e10cSrcweir #define PROPERTY_KEYWORDREF		DEFINE_CONST_OUSTRING("KeywordRef")
166*cdf0e10cSrcweir #define PROPERTY_ANCHORREF		DEFINE_CONST_OUSTRING("KeywordAnchorForRef")
167*cdf0e10cSrcweir #define PROPERTY_TITLEREF		DEFINE_CONST_OUSTRING("KeywordTitleForRef")
168*cdf0e10cSrcweir #define PROPERTY_TITLE			DEFINE_CONST_OUSTRING("Title")
169*cdf0e10cSrcweir #define HELP_URL				DEFINE_CONST_OUSTRING("vnd.sun.star.help://")
170*cdf0e10cSrcweir #define HELP_SEARCH_TAG			DEFINE_CONST_OUSTRING("/?Query=")
171*cdf0e10cSrcweir #define USERITEM_NAME           DEFINE_CONST_OUSTRING("UserItem")
172*cdf0e10cSrcweir 
173*cdf0e10cSrcweir #define PACKAGE_SETUP           DEFINE_CONST_OUSTRING("/org.openoffice.Setup")
174*cdf0e10cSrcweir #define PATH_OFFICE_FACTORIES   DEFINE_CONST_OUSTRING("Office/Factories/")
175*cdf0e10cSrcweir #define KEY_HELP_ON_OPEN        DEFINE_CONST_OUSTRING("ooSetupFactoryHelpOnOpen")
176*cdf0e10cSrcweir #define KEY_UI_NAME             DEFINE_CONST_OUSTRING("ooSetupFactoryUIName")
177*cdf0e10cSrcweir 
178*cdf0e10cSrcweir #define PARSE_URL( aURL ) \
179*cdf0e10cSrcweir     Reference < XURLTransformer > xTrans( ::comphelper::getProcessServiceFactory()->createInstance( \
180*cdf0e10cSrcweir             DEFINE_CONST_UNICODE("com.sun.star.util.URLTransformer" )), UNO_QUERY ); \
181*cdf0e10cSrcweir     xTrans->parseStrict( aURL )
182*cdf0e10cSrcweir 
183*cdf0e10cSrcweir //.........................................................................
184*cdf0e10cSrcweir namespace sfx2
185*cdf0e10cSrcweir {
186*cdf0e10cSrcweir //.........................................................................
187*cdf0e10cSrcweir 
188*cdf0e10cSrcweir 	void HandleTaskPaneList( Window* pWindow, sal_Bool bAddToList )
189*cdf0e10cSrcweir 	{
190*cdf0e10cSrcweir 		Window* pParent = pWindow->GetParent();
191*cdf0e10cSrcweir 		DBG_ASSERT( pParent, "HandleTaskPaneList(): every window here should have a parent" );
192*cdf0e10cSrcweir 
193*cdf0e10cSrcweir 		SystemWindow* pSysWin = pParent->GetSystemWindow();
194*cdf0e10cSrcweir 		if( pSysWin )
195*cdf0e10cSrcweir 		{
196*cdf0e10cSrcweir 			TaskPaneList* pTaskPaneList = pSysWin->GetTaskPaneList();
197*cdf0e10cSrcweir 			if( pTaskPaneList )
198*cdf0e10cSrcweir 			{
199*cdf0e10cSrcweir 				if( bAddToList )
200*cdf0e10cSrcweir 					pTaskPaneList->AddWindow( pWindow );
201*cdf0e10cSrcweir 				else
202*cdf0e10cSrcweir 					pTaskPaneList->RemoveWindow( pWindow );
203*cdf0e10cSrcweir 			}
204*cdf0e10cSrcweir 		}
205*cdf0e10cSrcweir 	}
206*cdf0e10cSrcweir 
207*cdf0e10cSrcweir 	/** Prepare a search string for searching or selecting.
208*cdf0e10cSrcweir 		For searching every search word needs the postfix '*' and the delimiter ' ' if necessary.
209*cdf0e10cSrcweir 		For selecting the delimiter '|' is required to search with regular expressions.
210*cdf0e10cSrcweir 		Samples:
211*cdf0e10cSrcweir 		search string | output for searching | output for selecting
212*cdf0e10cSrcweir 		-----------------------------------------------------------
213*cdf0e10cSrcweir 		"text"        | "text*"              | "text"
214*cdf0e10cSrcweir 		"text*"       | "text*"              | "text"
215*cdf0e10cSrcweir 		"text menu"   | "text* menu*"        | "text|menu"
216*cdf0e10cSrcweir 	*/
217*cdf0e10cSrcweir 	String PrepareSearchString( const String& rSearchString,
218*cdf0e10cSrcweir 								Reference< XBreakIterator > xBreak, bool bForSearch )
219*cdf0e10cSrcweir 	{
220*cdf0e10cSrcweir 		String sSearchStr;
221*cdf0e10cSrcweir 		sal_Int32 nStartPos = 0;
222*cdf0e10cSrcweir 		const Locale aLocale = Application::GetSettings().GetUILocale();
223*cdf0e10cSrcweir 		Boundary aBoundary = xBreak->getWordBoundary(
224*cdf0e10cSrcweir 			rSearchString, nStartPos, aLocale, WordType::ANYWORD_IGNOREWHITESPACES, sal_True );
225*cdf0e10cSrcweir 
226*cdf0e10cSrcweir 		while ( aBoundary.startPos != aBoundary.endPos )
227*cdf0e10cSrcweir 		{
228*cdf0e10cSrcweir 			nStartPos = aBoundary.endPos;
229*cdf0e10cSrcweir 			String sSearchToken( rSearchString.Copy(
230*cdf0e10cSrcweir 				(sal_uInt16)aBoundary.startPos, (sal_uInt16)aBoundary.endPos - (sal_uInt16)aBoundary.startPos ) );
231*cdf0e10cSrcweir             if ( sSearchToken.Len() > 0 && ( sSearchToken.Len() > 1 || sSearchToken.GetChar(0) != '.' ) )
232*cdf0e10cSrcweir             {
233*cdf0e10cSrcweir                 if ( bForSearch && sSearchToken.GetChar( sSearchToken.Len() - 1 ) != '*' )
234*cdf0e10cSrcweir                     sSearchToken += '*';
235*cdf0e10cSrcweir 
236*cdf0e10cSrcweir                 if ( sSearchToken.Len() > 1 ||
237*cdf0e10cSrcweir                      ( sSearchToken.Len() > 0 && sSearchToken.GetChar( 0 ) != '*' ) )
238*cdf0e10cSrcweir                 {
239*cdf0e10cSrcweir                     if ( sSearchStr.Len() > 0 )
240*cdf0e10cSrcweir                     {
241*cdf0e10cSrcweir                         if ( bForSearch )
242*cdf0e10cSrcweir                             sSearchStr += ' ';
243*cdf0e10cSrcweir                         else
244*cdf0e10cSrcweir                             sSearchStr += '|';
245*cdf0e10cSrcweir                     }
246*cdf0e10cSrcweir                     sSearchStr += sSearchToken;
247*cdf0e10cSrcweir                 }
248*cdf0e10cSrcweir             }
249*cdf0e10cSrcweir 			aBoundary = xBreak->nextWord( rSearchString, nStartPos,
250*cdf0e10cSrcweir 										  aLocale, WordType::ANYWORD_IGNOREWHITESPACES );
251*cdf0e10cSrcweir 		}
252*cdf0e10cSrcweir 
253*cdf0e10cSrcweir 		return sSearchStr;
254*cdf0e10cSrcweir 	}
255*cdf0e10cSrcweir //.........................................................................
256*cdf0e10cSrcweir // namespace sfx2
257*cdf0e10cSrcweir }
258*cdf0e10cSrcweir //.........................................................................
259*cdf0e10cSrcweir 
260*cdf0e10cSrcweir // struct IndexEntry_Impl ------------------------------------------------
261*cdf0e10cSrcweir 
262*cdf0e10cSrcweir struct IndexEntry_Impl
263*cdf0e10cSrcweir {
264*cdf0e10cSrcweir 	sal_Bool		m_bSubEntry;
265*cdf0e10cSrcweir 	String			m_aURL;
266*cdf0e10cSrcweir 
267*cdf0e10cSrcweir 	IndexEntry_Impl( const String& rURL, sal_Bool bSubEntry ) :
268*cdf0e10cSrcweir 		m_bSubEntry( bSubEntry ), m_aURL( rURL ) {}
269*cdf0e10cSrcweir };
270*cdf0e10cSrcweir 
271*cdf0e10cSrcweir #define NEW_ENTRY( url, bool ) \
272*cdf0e10cSrcweir 	(void*)(sal_uIntPtr)( new IndexEntry_Impl( url, bool ) )
273*cdf0e10cSrcweir 
274*cdf0e10cSrcweir // struct ContentEntry_Impl ----------------------------------------------
275*cdf0e10cSrcweir 
276*cdf0e10cSrcweir struct ContentEntry_Impl
277*cdf0e10cSrcweir {
278*cdf0e10cSrcweir 	String		aURL;
279*cdf0e10cSrcweir 	sal_Bool	bIsFolder;
280*cdf0e10cSrcweir 
281*cdf0e10cSrcweir 	ContentEntry_Impl( const String& rURL, sal_Bool bFolder ) :
282*cdf0e10cSrcweir 		aURL( rURL ), bIsFolder( bFolder ) {}
283*cdf0e10cSrcweir };
284*cdf0e10cSrcweir 
285*cdf0e10cSrcweir // ContentListBox_Impl ---------------------------------------------------
286*cdf0e10cSrcweir 
287*cdf0e10cSrcweir ContentListBox_Impl::ContentListBox_Impl( Window* pParent, const ResId& rResId ) :
288*cdf0e10cSrcweir 
289*cdf0e10cSrcweir 	SvTreeListBox( pParent, rResId ),
290*cdf0e10cSrcweir 
291*cdf0e10cSrcweir 	aOpenBookImage		( SfxResId( IMG_HELP_CONTENT_BOOK_OPEN ) ),
292*cdf0e10cSrcweir 	aClosedBookImage	( SfxResId( IMG_HELP_CONTENT_BOOK_CLOSED ) ),
293*cdf0e10cSrcweir 	aDocumentImage		( SfxResId( IMG_HELP_CONTENT_DOC ) )
294*cdf0e10cSrcweir 
295*cdf0e10cSrcweir {
296*cdf0e10cSrcweir     if ( GetSettings().GetStyleSettings().GetHighContrastMode() )
297*cdf0e10cSrcweir     {
298*cdf0e10cSrcweir         aOpenBookImage = Image( SfxResId( IMG_HELP_CONTENT_BOOK_OPEN_HC ) );
299*cdf0e10cSrcweir         aClosedBookImage = Image( SfxResId( IMG_HELP_CONTENT_BOOK_CLOSED_HC ) );
300*cdf0e10cSrcweir         aDocumentImage = Image( SfxResId( IMG_HELP_CONTENT_DOC_HC ) );
301*cdf0e10cSrcweir     }
302*cdf0e10cSrcweir 
303*cdf0e10cSrcweir 	SetStyle( GetStyle() | WB_HIDESELECTION | WB_HSCROLL );
304*cdf0e10cSrcweir 
305*cdf0e10cSrcweir 	SetEntryHeight( 16 );
306*cdf0e10cSrcweir 	SetSelectionMode( SINGLE_SELECTION );
307*cdf0e10cSrcweir 	SetSpaceBetweenEntries( 2 );
308*cdf0e10cSrcweir 	SetNodeBitmaps( aClosedBookImage, aOpenBookImage );
309*cdf0e10cSrcweir 
310*cdf0e10cSrcweir 	SetSublistOpenWithReturn();
311*cdf0e10cSrcweir 	SetSublistOpenWithLeftRight();
312*cdf0e10cSrcweir 
313*cdf0e10cSrcweir 	InitRoot();
314*cdf0e10cSrcweir }
315*cdf0e10cSrcweir 
316*cdf0e10cSrcweir // -----------------------------------------------------------------------
317*cdf0e10cSrcweir 
318*cdf0e10cSrcweir ContentListBox_Impl::~ContentListBox_Impl()
319*cdf0e10cSrcweir {
320*cdf0e10cSrcweir 	sal_uInt16 nPos = 0;
321*cdf0e10cSrcweir 	SvLBoxEntry* pEntry = GetEntry( nPos++ );
322*cdf0e10cSrcweir 	while ( pEntry )
323*cdf0e10cSrcweir 	{
324*cdf0e10cSrcweir 		::rtl::OUString aTemp( GetEntryText( pEntry ) );
325*cdf0e10cSrcweir 		ClearChildren( pEntry );
326*cdf0e10cSrcweir 		delete (ContentEntry_Impl*)pEntry->GetUserData();
327*cdf0e10cSrcweir 		pEntry = GetEntry( nPos++ );
328*cdf0e10cSrcweir 	}
329*cdf0e10cSrcweir }
330*cdf0e10cSrcweir 
331*cdf0e10cSrcweir // -----------------------------------------------------------------------
332*cdf0e10cSrcweir 
333*cdf0e10cSrcweir void ContentListBox_Impl::InitRoot()
334*cdf0e10cSrcweir {
335*cdf0e10cSrcweir 	String aHelpTreeviewURL( DEFINE_CONST_UNICODE("vnd.sun.star.hier://com.sun.star.help.TreeView/") );
336*cdf0e10cSrcweir 	::com::sun::star::uno::Sequence< ::rtl::OUString > aList =
337*cdf0e10cSrcweir 		SfxContentHelper::GetHelpTreeViewContents( aHelpTreeviewURL );
338*cdf0e10cSrcweir 
339*cdf0e10cSrcweir 	const ::rtl::OUString* pEntries  = aList.getConstArray();
340*cdf0e10cSrcweir 	sal_uInt32 i, nCount = aList.getLength();
341*cdf0e10cSrcweir 	for ( i = 0; i < nCount; ++i )
342*cdf0e10cSrcweir 	{
343*cdf0e10cSrcweir 		String aRow( pEntries[i] );
344*cdf0e10cSrcweir 		String aTitle, aURL;
345*cdf0e10cSrcweir 		xub_StrLen nIdx = 0;
346*cdf0e10cSrcweir 		aTitle = aRow.GetToken( 0, '\t', nIdx );
347*cdf0e10cSrcweir 		aURL = aRow.GetToken( 0, '\t', nIdx );
348*cdf0e10cSrcweir 		sal_Unicode cFolder = aRow.GetToken( 0, '\t', nIdx ).GetChar(0);
349*cdf0e10cSrcweir 		sal_Bool bIsFolder = ( '1' == cFolder );
350*cdf0e10cSrcweir 		SvLBoxEntry* pEntry = InsertEntry( aTitle, aOpenBookImage, aClosedBookImage, NULL, sal_True );
351*cdf0e10cSrcweir 		if ( bIsFolder )
352*cdf0e10cSrcweir 			pEntry->SetUserData( new ContentEntry_Impl( aURL, sal_True ) );
353*cdf0e10cSrcweir 	}
354*cdf0e10cSrcweir }
355*cdf0e10cSrcweir 
356*cdf0e10cSrcweir // -----------------------------------------------------------------------
357*cdf0e10cSrcweir 
358*cdf0e10cSrcweir void ContentListBox_Impl::ClearChildren( SvLBoxEntry* pParent )
359*cdf0e10cSrcweir {
360*cdf0e10cSrcweir 	SvLBoxEntry* pEntry = FirstChild( pParent );
361*cdf0e10cSrcweir 	while ( pEntry )
362*cdf0e10cSrcweir 	{
363*cdf0e10cSrcweir 		::rtl::OUString aTemp( GetEntryText( pEntry ) );
364*cdf0e10cSrcweir 		ClearChildren( pEntry );
365*cdf0e10cSrcweir 		delete (ContentEntry_Impl*)pEntry->GetUserData();
366*cdf0e10cSrcweir 		pEntry = NextSibling( pEntry );
367*cdf0e10cSrcweir 	}
368*cdf0e10cSrcweir }
369*cdf0e10cSrcweir 
370*cdf0e10cSrcweir // -----------------------------------------------------------------------
371*cdf0e10cSrcweir 
372*cdf0e10cSrcweir void ContentListBox_Impl::RequestingChilds( SvLBoxEntry* pParent )
373*cdf0e10cSrcweir {
374*cdf0e10cSrcweir 	try
375*cdf0e10cSrcweir 	{
376*cdf0e10cSrcweir 		if ( !pParent->HasChilds() )
377*cdf0e10cSrcweir 		{
378*cdf0e10cSrcweir 			if ( pParent->GetUserData() )
379*cdf0e10cSrcweir 			{
380*cdf0e10cSrcweir 				String aTmpURL( ( (ContentEntry_Impl*)pParent->GetUserData()  )->aURL );
381*cdf0e10cSrcweir 				::com::sun::star::uno::Sequence< ::rtl::OUString > aList =
382*cdf0e10cSrcweir 					SfxContentHelper::GetHelpTreeViewContents( aTmpURL );
383*cdf0e10cSrcweir 
384*cdf0e10cSrcweir 				const ::rtl::OUString* pEntries  = aList.getConstArray();
385*cdf0e10cSrcweir 				sal_uInt32 i, nCount = aList.getLength();
386*cdf0e10cSrcweir 				for ( i = 0; i < nCount; ++i )
387*cdf0e10cSrcweir 				{
388*cdf0e10cSrcweir 					String aRow( pEntries[i] );
389*cdf0e10cSrcweir 					String aTitle, aURL;
390*cdf0e10cSrcweir 					xub_StrLen nIdx = 0;
391*cdf0e10cSrcweir 					aTitle = aRow.GetToken( 0, '\t', nIdx );
392*cdf0e10cSrcweir 					aURL = aRow.GetToken( 0, '\t', nIdx );
393*cdf0e10cSrcweir 					sal_Unicode cFolder = aRow.GetToken( 0, '\t', nIdx ).GetChar(0);
394*cdf0e10cSrcweir 					sal_Bool bIsFolder = ( '1' == cFolder );
395*cdf0e10cSrcweir 					SvLBoxEntry* pEntry = NULL;
396*cdf0e10cSrcweir 					if ( bIsFolder )
397*cdf0e10cSrcweir 					{
398*cdf0e10cSrcweir                         pEntry = InsertEntry( aTitle, aOpenBookImage, aClosedBookImage, pParent, sal_True );
399*cdf0e10cSrcweir 						pEntry->SetUserData( new ContentEntry_Impl( aURL, sal_True ) );
400*cdf0e10cSrcweir 					}
401*cdf0e10cSrcweir 					else
402*cdf0e10cSrcweir 					{
403*cdf0e10cSrcweir 						pEntry = InsertEntry( aTitle, aDocumentImage, aDocumentImage, pParent );
404*cdf0e10cSrcweir                     	Any aAny( ::utl::UCBContentHelper::GetProperty( aURL, String(RTL_CONSTASCII_USTRINGPARAM("TargetURL" ) ) ) );
405*cdf0e10cSrcweir 						rtl::OUString aTargetURL;
406*cdf0e10cSrcweir 						if ( aAny >>=  aTargetURL )
407*cdf0e10cSrcweir 							pEntry->SetUserData( new ContentEntry_Impl( aTargetURL, sal_False ) );
408*cdf0e10cSrcweir 					}
409*cdf0e10cSrcweir 				}
410*cdf0e10cSrcweir 			}
411*cdf0e10cSrcweir 		}
412*cdf0e10cSrcweir 	}
413*cdf0e10cSrcweir 	catch( Exception& )
414*cdf0e10cSrcweir 	{
415*cdf0e10cSrcweir 		DBG_ERROR( "ContentListBox_Impl::RequestingChilds(): unexpected exception" );
416*cdf0e10cSrcweir 	}
417*cdf0e10cSrcweir }
418*cdf0e10cSrcweir 
419*cdf0e10cSrcweir // -----------------------------------------------------------------------
420*cdf0e10cSrcweir 
421*cdf0e10cSrcweir long ContentListBox_Impl::Notify( NotifyEvent& rNEvt )
422*cdf0e10cSrcweir {
423*cdf0e10cSrcweir 	sal_Bool bHandled = sal_False;
424*cdf0e10cSrcweir 	if ( rNEvt.GetType() == EVENT_KEYINPUT &&
425*cdf0e10cSrcweir 		 KEY_RETURN == rNEvt.GetKeyEvent()->GetKeyCode().GetCode() )
426*cdf0e10cSrcweir 	{
427*cdf0e10cSrcweir 		GetDoubleClickHdl().Call( NULL );
428*cdf0e10cSrcweir 		bHandled = sal_True;
429*cdf0e10cSrcweir 	}
430*cdf0e10cSrcweir 
431*cdf0e10cSrcweir 	return bHandled ? 1 : SvTreeListBox::Notify( rNEvt );
432*cdf0e10cSrcweir }
433*cdf0e10cSrcweir 
434*cdf0e10cSrcweir // -----------------------------------------------------------------------
435*cdf0e10cSrcweir 
436*cdf0e10cSrcweir String ContentListBox_Impl::GetSelectEntry() const
437*cdf0e10cSrcweir {
438*cdf0e10cSrcweir 	String aRet;
439*cdf0e10cSrcweir 	SvLBoxEntry* pEntry = FirstSelected();
440*cdf0e10cSrcweir 	if ( pEntry && !( (ContentEntry_Impl*)pEntry->GetUserData()  )->bIsFolder )
441*cdf0e10cSrcweir 		aRet = ( (ContentEntry_Impl*)pEntry->GetUserData() )->aURL;
442*cdf0e10cSrcweir 	return aRet;
443*cdf0e10cSrcweir }
444*cdf0e10cSrcweir 
445*cdf0e10cSrcweir // class HelpTabPage_Impl ------------------------------------------------
446*cdf0e10cSrcweir 
447*cdf0e10cSrcweir HelpTabPage_Impl::HelpTabPage_Impl(
448*cdf0e10cSrcweir 	Window* pParent, SfxHelpIndexWindow_Impl* _pIdxWin, const ResId& rResId ) :
449*cdf0e10cSrcweir 
450*cdf0e10cSrcweir 	TabPage( pParent, rResId ),
451*cdf0e10cSrcweir 
452*cdf0e10cSrcweir 	m_pIdxWin( _pIdxWin )
453*cdf0e10cSrcweir 
454*cdf0e10cSrcweir {
455*cdf0e10cSrcweir }
456*cdf0e10cSrcweir 
457*cdf0e10cSrcweir // class ContentTabPage_Impl ---------------------------------------------
458*cdf0e10cSrcweir 
459*cdf0e10cSrcweir ContentTabPage_Impl::ContentTabPage_Impl( Window* pParent, SfxHelpIndexWindow_Impl* _pIdxWin ) :
460*cdf0e10cSrcweir 
461*cdf0e10cSrcweir 	HelpTabPage_Impl( pParent, _pIdxWin, SfxResId( TP_HELP_CONTENT ) ),
462*cdf0e10cSrcweir 
463*cdf0e10cSrcweir 	aContentBox( this, SfxResId( LB_CONTENTS ) )
464*cdf0e10cSrcweir 
465*cdf0e10cSrcweir {
466*cdf0e10cSrcweir 	FreeResource();
467*cdf0e10cSrcweir 
468*cdf0e10cSrcweir 	aContentBox.Show();
469*cdf0e10cSrcweir }
470*cdf0e10cSrcweir 
471*cdf0e10cSrcweir // -----------------------------------------------------------------------
472*cdf0e10cSrcweir 
473*cdf0e10cSrcweir void ContentTabPage_Impl::Resize()
474*cdf0e10cSrcweir {
475*cdf0e10cSrcweir 	Size aSize = GetOutputSizePixel();
476*cdf0e10cSrcweir 	aSize.Width() -= 8;
477*cdf0e10cSrcweir 	aSize.Height() -= 8;
478*cdf0e10cSrcweir 	aContentBox.SetPosSizePixel( Point( 4, 4 ), aSize );
479*cdf0e10cSrcweir }
480*cdf0e10cSrcweir 
481*cdf0e10cSrcweir // -----------------------------------------------------------------------
482*cdf0e10cSrcweir 
483*cdf0e10cSrcweir void ContentTabPage_Impl::ActivatePage()
484*cdf0e10cSrcweir {
485*cdf0e10cSrcweir     if ( !m_pIdxWin->WasCursorLeftOrRight() )
486*cdf0e10cSrcweir         SetFocusOnBox();
487*cdf0e10cSrcweir }
488*cdf0e10cSrcweir 
489*cdf0e10cSrcweir // -----------------------------------------------------------------------
490*cdf0e10cSrcweir 
491*cdf0e10cSrcweir Control* ContentTabPage_Impl::GetLastFocusControl()
492*cdf0e10cSrcweir {
493*cdf0e10cSrcweir 	return &aContentBox;
494*cdf0e10cSrcweir }
495*cdf0e10cSrcweir 
496*cdf0e10cSrcweir // class IndexBox_Impl ---------------------------------------------------
497*cdf0e10cSrcweir 
498*cdf0e10cSrcweir IndexBox_Impl::IndexBox_Impl( Window* pParent, const ResId& rResId ) :
499*cdf0e10cSrcweir 
500*cdf0e10cSrcweir 	ComboBox( pParent, rResId )
501*cdf0e10cSrcweir 
502*cdf0e10cSrcweir {
503*cdf0e10cSrcweir 	EnableAutocomplete( sal_True );
504*cdf0e10cSrcweir     EnableUserDraw( sal_True );
505*cdf0e10cSrcweir }
506*cdf0e10cSrcweir 
507*cdf0e10cSrcweir // -----------------------------------------------------------------------
508*cdf0e10cSrcweir 
509*cdf0e10cSrcweir void IndexBox_Impl::UserDraw( const UserDrawEvent& rUDEvt )
510*cdf0e10cSrcweir {
511*cdf0e10cSrcweir 	IndexEntry_Impl* pEntry = (IndexEntry_Impl*)(sal_uIntPtr)GetEntryData( rUDEvt.GetItemId() );
512*cdf0e10cSrcweir 	if ( pEntry && pEntry->m_bSubEntry )
513*cdf0e10cSrcweir 	{
514*cdf0e10cSrcweir 		// indent sub entries
515*cdf0e10cSrcweir 		Point aPos( rUDEvt.GetRect().TopLeft() );
516*cdf0e10cSrcweir 		aPos.X() += 8;
517*cdf0e10cSrcweir 		aPos.Y() += ( rUDEvt.GetRect().GetHeight() - rUDEvt.GetDevice()->GetTextHeight() ) / 2;
518*cdf0e10cSrcweir 		String aEntry( GetEntry( rUDEvt.GetItemId() ) );
519*cdf0e10cSrcweir 		sal_uInt16 nPos = aEntry.Search( ';' );
520*cdf0e10cSrcweir 		rUDEvt.GetDevice()->DrawText( aPos, ( nPos != STRING_NOTFOUND ) ? aEntry.Copy( nPos + 1 ) : aEntry );
521*cdf0e10cSrcweir 	}
522*cdf0e10cSrcweir 	else
523*cdf0e10cSrcweir 		DrawEntry( rUDEvt, sal_False, sal_True, sal_True );
524*cdf0e10cSrcweir }
525*cdf0e10cSrcweir 
526*cdf0e10cSrcweir // -----------------------------------------------------------------------
527*cdf0e10cSrcweir 
528*cdf0e10cSrcweir long IndexBox_Impl::Notify( NotifyEvent& rNEvt )
529*cdf0e10cSrcweir {
530*cdf0e10cSrcweir 	sal_Bool bHandled = sal_False;
531*cdf0e10cSrcweir 	if ( rNEvt.GetType() == EVENT_KEYINPUT &&
532*cdf0e10cSrcweir 		 KEY_RETURN == rNEvt.GetKeyEvent()->GetKeyCode().GetCode() )
533*cdf0e10cSrcweir 	{
534*cdf0e10cSrcweir 		GetDoubleClickHdl().Call( NULL );
535*cdf0e10cSrcweir 		bHandled = sal_True;
536*cdf0e10cSrcweir 	}
537*cdf0e10cSrcweir 
538*cdf0e10cSrcweir 	return bHandled ? 1 : ComboBox::Notify( rNEvt );
539*cdf0e10cSrcweir }
540*cdf0e10cSrcweir 
541*cdf0e10cSrcweir // -----------------------------------------------------------------------
542*cdf0e10cSrcweir 
543*cdf0e10cSrcweir void IndexBox_Impl::SelectExecutableEntry()
544*cdf0e10cSrcweir {
545*cdf0e10cSrcweir 	sal_uInt16 nPos = GetEntryPos( GetText() );
546*cdf0e10cSrcweir 	if ( nPos != COMBOBOX_ENTRY_NOTFOUND )
547*cdf0e10cSrcweir 	{
548*cdf0e10cSrcweir 		sal_uInt16 nOldPos = nPos;
549*cdf0e10cSrcweir 		String aEntryText;
550*cdf0e10cSrcweir 		IndexEntry_Impl* pEntry = (IndexEntry_Impl*)(sal_uIntPtr)GetEntryData( nPos );
551*cdf0e10cSrcweir 		sal_uInt16 nCount = GetEntryCount();
552*cdf0e10cSrcweir 		while ( nPos < nCount && ( !pEntry || pEntry->m_aURL.Len() == 0 ) )
553*cdf0e10cSrcweir 		{
554*cdf0e10cSrcweir 			pEntry = (IndexEntry_Impl*)(sal_uIntPtr)GetEntryData( ++nPos );
555*cdf0e10cSrcweir 			aEntryText = GetEntry( nPos );
556*cdf0e10cSrcweir 		}
557*cdf0e10cSrcweir 
558*cdf0e10cSrcweir 		if ( nOldPos != nPos )
559*cdf0e10cSrcweir 			SetText( aEntryText );
560*cdf0e10cSrcweir 	}
561*cdf0e10cSrcweir }
562*cdf0e10cSrcweir 
563*cdf0e10cSrcweir // class IndexTabPage_Impl -----------------------------------------------
564*cdf0e10cSrcweir 
565*cdf0e10cSrcweir IndexTabPage_Impl::IndexTabPage_Impl( Window* pParent, SfxHelpIndexWindow_Impl* _pIdxWin ) :
566*cdf0e10cSrcweir 
567*cdf0e10cSrcweir 	HelpTabPage_Impl( pParent, _pIdxWin, SfxResId( TP_HELP_INDEX ) ),
568*cdf0e10cSrcweir 
569*cdf0e10cSrcweir 	aExpressionFT	( this, SfxResId( FT_EXPRESSION ) ),
570*cdf0e10cSrcweir 	aIndexCB		( this, SfxResId( CB_INDEX ) ),
571*cdf0e10cSrcweir 	aOpenBtn		( this, SfxResId( PB_OPEN_INDEX ) ),
572*cdf0e10cSrcweir 
573*cdf0e10cSrcweir     bIsActivated    ( sal_False )
574*cdf0e10cSrcweir 
575*cdf0e10cSrcweir {
576*cdf0e10cSrcweir 	FreeResource();
577*cdf0e10cSrcweir 
578*cdf0e10cSrcweir 	aOpenBtn.SetClickHdl( LINK( this, IndexTabPage_Impl, OpenHdl ) );
579*cdf0e10cSrcweir 	Link aTimeoutLink = LINK( this, IndexTabPage_Impl, TimeoutHdl );
580*cdf0e10cSrcweir 	aFactoryTimer.SetTimeoutHdl( aTimeoutLink );
581*cdf0e10cSrcweir 	aFactoryTimer.SetTimeout( 300 );
582*cdf0e10cSrcweir 	aKeywordTimer.SetTimeoutHdl( aTimeoutLink );
583*cdf0e10cSrcweir 	aFactoryTimer.SetTimeout( 300 );
584*cdf0e10cSrcweir 
585*cdf0e10cSrcweir 	nMinWidth = aOpenBtn.GetSizePixel().Width();
586*cdf0e10cSrcweir }
587*cdf0e10cSrcweir 
588*cdf0e10cSrcweir // -----------------------------------------------------------------------
589*cdf0e10cSrcweir 
590*cdf0e10cSrcweir IndexTabPage_Impl::~IndexTabPage_Impl()
591*cdf0e10cSrcweir {
592*cdf0e10cSrcweir 	ClearIndex();
593*cdf0e10cSrcweir }
594*cdf0e10cSrcweir 
595*cdf0e10cSrcweir // -----------------------------------------------------------------------
596*cdf0e10cSrcweir 
597*cdf0e10cSrcweir namespace sfx2 {
598*cdf0e10cSrcweir 
599*cdf0e10cSrcweir 	struct equalOUString
600*cdf0e10cSrcweir 	{
601*cdf0e10cSrcweir 		bool operator()( const ::rtl::OUString& rKey1, const ::rtl::OUString& rKey2 ) const
602*cdf0e10cSrcweir 		{
603*cdf0e10cSrcweir 			return !!( rKey1 == rKey2 );
604*cdf0e10cSrcweir 		}
605*cdf0e10cSrcweir 	};
606*cdf0e10cSrcweir 
607*cdf0e10cSrcweir 
608*cdf0e10cSrcweir 	struct hashOUString
609*cdf0e10cSrcweir 	{
610*cdf0e10cSrcweir 		size_t operator()( const ::rtl::OUString& rName ) const
611*cdf0e10cSrcweir 		{
612*cdf0e10cSrcweir 			return rName.hashCode();
613*cdf0e10cSrcweir 		}
614*cdf0e10cSrcweir 	};
615*cdf0e10cSrcweir 
616*cdf0e10cSrcweir 	typedef ::std::hash_map< ::rtl::OUString, int, hashOUString, equalOUString > KeywordInfo;
617*cdf0e10cSrcweir }
618*cdf0e10cSrcweir 
619*cdf0e10cSrcweir #define UNIFY_AND_INSERT_TOKEN( aToken )															\
620*cdf0e10cSrcweir     it =																							\
621*cdf0e10cSrcweir     aInfo.insert( sfx2::KeywordInfo::value_type( aToken, 0 ) ).first;								\
622*cdf0e10cSrcweir     if ( ( tmp = it->second++ ) != 0 )																\
623*cdf0e10cSrcweir        nPos = aIndexCB.InsertEntry( aToken + rtl::OUString( append, tmp ) );						\
624*cdf0e10cSrcweir     else																							\
625*cdf0e10cSrcweir        nPos = aIndexCB.InsertEntry( aToken )
626*cdf0e10cSrcweir 
627*cdf0e10cSrcweir #define INSERT_DATA( j )																			\
628*cdf0e10cSrcweir 	if ( aAnchorList[j].getLength() > 0 )															\
629*cdf0e10cSrcweir 	{																								\
630*cdf0e10cSrcweir 		aData.append( aRefList[j] ).append( sal_Unicode('#') ).append( aAnchorList[j] );			\
631*cdf0e10cSrcweir 		aIndexCB.SetEntryData( nPos, NEW_ENTRY( aData.makeStringAndClear(), insert ) );				\
632*cdf0e10cSrcweir 	}																								\
633*cdf0e10cSrcweir 	else																							\
634*cdf0e10cSrcweir 		aIndexCB.SetEntryData( nPos, NEW_ENTRY( aRefList[j], insert ) );
635*cdf0e10cSrcweir 
636*cdf0e10cSrcweir // -----------------------------------------------------------------------
637*cdf0e10cSrcweir 
638*cdf0e10cSrcweir void IndexTabPage_Impl::InitializeIndex()
639*cdf0e10cSrcweir {
640*cdf0e10cSrcweir 	WaitObject( this );
641*cdf0e10cSrcweir 
642*cdf0e10cSrcweir 	// By now more than 256 equal entries are not allowed
643*cdf0e10cSrcweir 	sal_Unicode append[256];
644*cdf0e10cSrcweir 	for( int k = 0; k < 256; ++k )
645*cdf0e10cSrcweir 		append[k] = sal_Unicode( ' ' );
646*cdf0e10cSrcweir 
647*cdf0e10cSrcweir 	sfx2::KeywordInfo aInfo;
648*cdf0e10cSrcweir 	aIndexCB.SetUpdateMode( sal_False );
649*cdf0e10cSrcweir 
650*cdf0e10cSrcweir 	try
651*cdf0e10cSrcweir 	{
652*cdf0e10cSrcweir 		::rtl::OUString aURL = HELP_URL;
653*cdf0e10cSrcweir 		aURL += ::rtl::OUString( sFactory );
654*cdf0e10cSrcweir 
655*cdf0e10cSrcweir 		String aTemp = aURL;
656*cdf0e10cSrcweir 		AppendConfigToken_Impl( aTemp, sal_True );
657*cdf0e10cSrcweir 		aURL = aTemp;
658*cdf0e10cSrcweir 
659*cdf0e10cSrcweir 		Content aCnt( aURL, Reference< ::com::sun::star::ucb::XCommandEnvironment > () );
660*cdf0e10cSrcweir 		::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > xInfo = aCnt.getProperties();
661*cdf0e10cSrcweir 		if ( xInfo->hasPropertyByName( PROPERTY_ANCHORREF ) )
662*cdf0e10cSrcweir 		{
663*cdf0e10cSrcweir 			::com::sun::star::uno::Sequence< ::rtl::OUString > aPropSeq( 4 );
664*cdf0e10cSrcweir 			aPropSeq[0] = PROPERTY_KEYWORDLIST;
665*cdf0e10cSrcweir 			aPropSeq[1] = PROPERTY_KEYWORDREF;
666*cdf0e10cSrcweir 			aPropSeq[2] = PROPERTY_ANCHORREF;
667*cdf0e10cSrcweir 			aPropSeq[3] = PROPERTY_TITLEREF;
668*cdf0e10cSrcweir 
669*cdf0e10cSrcweir 			// abi: use one possibly remote call only
670*cdf0e10cSrcweir 			::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any > aAnySeq =
671*cdf0e10cSrcweir 				  aCnt.getPropertyValues( aPropSeq );
672*cdf0e10cSrcweir 
673*cdf0e10cSrcweir 			::com::sun::star::uno::Sequence< ::rtl::OUString > aKeywordList;
674*cdf0e10cSrcweir 			::com::sun::star::uno::Sequence< ::com::sun::star::uno::Sequence< ::rtl::OUString > > aKeywordRefList;
675*cdf0e10cSrcweir 			::com::sun::star::uno::Sequence< ::com::sun::star::uno::Sequence< ::rtl::OUString > > aAnchorRefList;
676*cdf0e10cSrcweir 			::com::sun::star::uno::Sequence< ::com::sun::star::uno::Sequence< ::rtl::OUString > > aTitleRefList;
677*cdf0e10cSrcweir 
678*cdf0e10cSrcweir 			if ( ( aAnySeq[0] >>= aKeywordList ) && ( aAnySeq[1] >>= aKeywordRefList ) &&
679*cdf0e10cSrcweir 				 ( aAnySeq[2] >>= aAnchorRefList ) && ( aAnySeq[3] >>= aTitleRefList ) )
680*cdf0e10cSrcweir 			{
681*cdf0e10cSrcweir 				sal_Bool insert;
682*cdf0e10cSrcweir 				sal_uInt16 nPos;
683*cdf0e10cSrcweir 				int ndx,tmp;
684*cdf0e10cSrcweir 				::rtl::OUString aIndex, aTempString;
685*cdf0e10cSrcweir 				::rtl::OUStringBuffer aData( 128 );            // Capacity of up to 128 characters
686*cdf0e10cSrcweir 				sfx2::KeywordInfo::iterator it;
687*cdf0e10cSrcweir 
688*cdf0e10cSrcweir 				for ( int i = 0; i < aKeywordList.getLength(); ++i )
689*cdf0e10cSrcweir 				{
690*cdf0e10cSrcweir 					// abi: Do not copy, but use references
691*cdf0e10cSrcweir 					const ::rtl::OUString& aKeywordPair = aKeywordList[i];
692*cdf0e10cSrcweir 					DBG_ASSERT( aKeywordPair.getLength() > 0, "invalid help index" );
693*cdf0e10cSrcweir 					const ::com::sun::star::uno::Sequence< ::rtl::OUString >& aRefList = aKeywordRefList[i];
694*cdf0e10cSrcweir 					const ::com::sun::star::uno::Sequence< ::rtl::OUString >& aAnchorList = aAnchorRefList[i];
695*cdf0e10cSrcweir 					const ::com::sun::star::uno::Sequence< ::rtl::OUString >& aTitleList = aTitleRefList[i];
696*cdf0e10cSrcweir 
697*cdf0e10cSrcweir 					DBG_ASSERT( aRefList.getLength() == aAnchorList.getLength(),"reference list and title list of different length" );
698*cdf0e10cSrcweir 
699*cdf0e10cSrcweir 					insert = ( ( ndx = aKeywordPair.indexOf( sal_Unicode( ';' ) ) ) == -1 ? sal_False : sal_True );
700*cdf0e10cSrcweir 
701*cdf0e10cSrcweir 					if ( insert )
702*cdf0e10cSrcweir 					{
703*cdf0e10cSrcweir 						aTempString = aKeywordPair.copy( 0, ndx );
704*cdf0e10cSrcweir 						if ( aIndex != aTempString )
705*cdf0e10cSrcweir 						{
706*cdf0e10cSrcweir 							aIndex = aTempString;
707*cdf0e10cSrcweir 							UNIFY_AND_INSERT_TOKEN( aTempString );
708*cdf0e10cSrcweir 						}
709*cdf0e10cSrcweir 					}
710*cdf0e10cSrcweir 					else
711*cdf0e10cSrcweir 						aIndex = ::rtl::OUString();
712*cdf0e10cSrcweir 
713*cdf0e10cSrcweir 					// Assume the token is trimed
714*cdf0e10cSrcweir 					UNIFY_AND_INSERT_TOKEN( aKeywordPair );
715*cdf0e10cSrcweir 
716*cdf0e10cSrcweir 					sal_uInt32 nRefListLen = aRefList.getLength();
717*cdf0e10cSrcweir 
718*cdf0e10cSrcweir 					DBG_ASSERT( aAnchorList.getLength(), "*IndexTabPage_Impl::InitializeIndex(): AnchorList is empty!" );			\
719*cdf0e10cSrcweir 					DBG_ASSERT( nRefListLen, "*IndexTabPage_Impl::InitializeIndex(): RefList is empty!" );			\
720*cdf0e10cSrcweir 
721*cdf0e10cSrcweir 					if ( aAnchorList.getLength() && nRefListLen )
722*cdf0e10cSrcweir 					{
723*cdf0e10cSrcweir 						INSERT_DATA( 0 );
724*cdf0e10cSrcweir 					}
725*cdf0e10cSrcweir 
726*cdf0e10cSrcweir 					for ( sal_uInt32 j = 1; j < nRefListLen ; ++j )
727*cdf0e10cSrcweir 					{
728*cdf0e10cSrcweir 						aData
729*cdf0e10cSrcweir 							.append( aKeywordPair )
730*cdf0e10cSrcweir 							.append( sal_Unicode(' ') )
731*cdf0e10cSrcweir 							.append( sal_Unicode('-') )
732*cdf0e10cSrcweir 							.append( sal_Unicode(' ') )
733*cdf0e10cSrcweir 							.append( aTitleList[j] );
734*cdf0e10cSrcweir 
735*cdf0e10cSrcweir 						aTempString = aData.makeStringAndClear();
736*cdf0e10cSrcweir 						UNIFY_AND_INSERT_TOKEN( aTempString );
737*cdf0e10cSrcweir 						INSERT_DATA( j );
738*cdf0e10cSrcweir 					}
739*cdf0e10cSrcweir 				}
740*cdf0e10cSrcweir 			}
741*cdf0e10cSrcweir 		}
742*cdf0e10cSrcweir 	}
743*cdf0e10cSrcweir 	catch( Exception& )
744*cdf0e10cSrcweir 	{
745*cdf0e10cSrcweir 		DBG_ERROR( "IndexTabPage_Impl::InitializeIndex(): unexpected exception" );
746*cdf0e10cSrcweir 	}
747*cdf0e10cSrcweir 
748*cdf0e10cSrcweir 	aIndexCB.SetUpdateMode( sal_True );
749*cdf0e10cSrcweir 
750*cdf0e10cSrcweir 	if ( sKeyword.Len() > 0 )
751*cdf0e10cSrcweir 		aKeywordLink.Call( this );
752*cdf0e10cSrcweir }
753*cdf0e10cSrcweir 
754*cdf0e10cSrcweir #undef INSERT_DATA
755*cdf0e10cSrcweir #undef UNIFY_AND_INSERT_TOKEN
756*cdf0e10cSrcweir 
757*cdf0e10cSrcweir // -----------------------------------------------------------------------
758*cdf0e10cSrcweir 
759*cdf0e10cSrcweir void IndexTabPage_Impl::ClearIndex()
760*cdf0e10cSrcweir {
761*cdf0e10cSrcweir 	sal_uInt16 nCount = aIndexCB.GetEntryCount();
762*cdf0e10cSrcweir 	for ( sal_uInt16 i = 0; i < nCount; ++i )
763*cdf0e10cSrcweir 		delete (IndexEntry_Impl*)(sal_uIntPtr)aIndexCB.GetEntryData(i);
764*cdf0e10cSrcweir 	aIndexCB.Clear();
765*cdf0e10cSrcweir }
766*cdf0e10cSrcweir 
767*cdf0e10cSrcweir // -----------------------------------------------------------------------
768*cdf0e10cSrcweir 
769*cdf0e10cSrcweir IMPL_LINK( IndexTabPage_Impl, OpenHdl, PushButton*, EMPTYARG )
770*cdf0e10cSrcweir {
771*cdf0e10cSrcweir 	aIndexCB.GetDoubleClickHdl().Call( &aIndexCB );
772*cdf0e10cSrcweir 	return 0;
773*cdf0e10cSrcweir }
774*cdf0e10cSrcweir 
775*cdf0e10cSrcweir // -----------------------------------------------------------------------
776*cdf0e10cSrcweir 
777*cdf0e10cSrcweir IMPL_LINK( IndexTabPage_Impl, TimeoutHdl, Timer*, pTimer )
778*cdf0e10cSrcweir {
779*cdf0e10cSrcweir 	if ( &aFactoryTimer == pTimer )
780*cdf0e10cSrcweir 		InitializeIndex();
781*cdf0e10cSrcweir 	else if ( &aKeywordTimer == pTimer && sKeyword.Len() > 0 )
782*cdf0e10cSrcweir 		aKeywordLink.Call( this );
783*cdf0e10cSrcweir 	return 0;
784*cdf0e10cSrcweir }
785*cdf0e10cSrcweir 
786*cdf0e10cSrcweir // -----------------------------------------------------------------------
787*cdf0e10cSrcweir 
788*cdf0e10cSrcweir void IndexTabPage_Impl::Resize()
789*cdf0e10cSrcweir {
790*cdf0e10cSrcweir 	Size aSize = GetSizePixel();
791*cdf0e10cSrcweir 	if ( aSize.Width() < nMinWidth )
792*cdf0e10cSrcweir 		aSize.Width() = nMinWidth;
793*cdf0e10cSrcweir 	Point aPnt = aExpressionFT.GetPosPixel();
794*cdf0e10cSrcweir 	Size aNewSize = aExpressionFT.GetSizePixel();
795*cdf0e10cSrcweir 	aNewSize.Width() = aSize.Width() - ( aPnt.X() * 2 );
796*cdf0e10cSrcweir 	aExpressionFT.SetSizePixel( aNewSize );
797*cdf0e10cSrcweir 
798*cdf0e10cSrcweir 	Size a6Size = LogicToPixel( Size( 6, 6 ), MAP_APPFONT );
799*cdf0e10cSrcweir 	Size aBtnSize = aOpenBtn.GetSizePixel();
800*cdf0e10cSrcweir 
801*cdf0e10cSrcweir 	aPnt = aIndexCB.GetPosPixel();
802*cdf0e10cSrcweir 	aNewSize = aIndexCB.GetSizePixel();
803*cdf0e10cSrcweir 	aNewSize.Width() = aSize.Width() - ( aPnt.X() * 2 );
804*cdf0e10cSrcweir 	aNewSize.Height() = aSize.Height() - aPnt.Y();
805*cdf0e10cSrcweir 	aNewSize.Height() -= ( aBtnSize.Height() + ( a6Size.Height() * 3 / 2 ) );
806*cdf0e10cSrcweir 	aIndexCB.SetSizePixel( aNewSize );
807*cdf0e10cSrcweir 
808*cdf0e10cSrcweir 	aPnt.X() += ( aNewSize.Width() - aBtnSize.Width() );
809*cdf0e10cSrcweir 	aPnt.Y() += aNewSize.Height() + ( a6Size.Height() / 2 );
810*cdf0e10cSrcweir 	long nMinX = aIndexCB.GetPosPixel().X();
811*cdf0e10cSrcweir 	if ( aPnt.X() < nMinX )
812*cdf0e10cSrcweir 		aPnt.X() = nMinX;
813*cdf0e10cSrcweir 	aOpenBtn.SetPosPixel( aPnt );
814*cdf0e10cSrcweir }
815*cdf0e10cSrcweir 
816*cdf0e10cSrcweir // -----------------------------------------------------------------------
817*cdf0e10cSrcweir 
818*cdf0e10cSrcweir void IndexTabPage_Impl::ActivatePage()
819*cdf0e10cSrcweir {
820*cdf0e10cSrcweir 	if ( !bIsActivated )
821*cdf0e10cSrcweir 	{
822*cdf0e10cSrcweir 		bIsActivated = sal_True;
823*cdf0e10cSrcweir 		aFactoryTimer.Start();
824*cdf0e10cSrcweir 	}
825*cdf0e10cSrcweir 
826*cdf0e10cSrcweir 	if ( !m_pIdxWin->WasCursorLeftOrRight() )
827*cdf0e10cSrcweir 		SetFocusOnBox();
828*cdf0e10cSrcweir }
829*cdf0e10cSrcweir 
830*cdf0e10cSrcweir // -----------------------------------------------------------------------
831*cdf0e10cSrcweir 
832*cdf0e10cSrcweir Control* IndexTabPage_Impl::GetLastFocusControl()
833*cdf0e10cSrcweir {
834*cdf0e10cSrcweir 	return &aOpenBtn;
835*cdf0e10cSrcweir }
836*cdf0e10cSrcweir 
837*cdf0e10cSrcweir // -----------------------------------------------------------------------
838*cdf0e10cSrcweir 
839*cdf0e10cSrcweir void IndexTabPage_Impl::SetDoubleClickHdl( const Link& rLink )
840*cdf0e10cSrcweir {
841*cdf0e10cSrcweir 	aIndexCB.SetDoubleClickHdl( rLink );
842*cdf0e10cSrcweir }
843*cdf0e10cSrcweir 
844*cdf0e10cSrcweir // -----------------------------------------------------------------------
845*cdf0e10cSrcweir 
846*cdf0e10cSrcweir void IndexTabPage_Impl::SetFactory( const String& rFactory )
847*cdf0e10cSrcweir {
848*cdf0e10cSrcweir     String sNewFactory( rFactory );
849*cdf0e10cSrcweir     DBG_ASSERT( sNewFactory.Len() > 0, "empty factory" );
850*cdf0e10cSrcweir     bool bValid = m_pIdxWin->IsValidFactory( rFactory );
851*cdf0e10cSrcweir 
852*cdf0e10cSrcweir     if ( sFactory.Len() == 0 && !bValid )
853*cdf0e10cSrcweir     {
854*cdf0e10cSrcweir         sNewFactory = SfxHelp::GetDefaultHelpModule();
855*cdf0e10cSrcweir         bValid = true;
856*cdf0e10cSrcweir     }
857*cdf0e10cSrcweir 
858*cdf0e10cSrcweir     if ( sNewFactory != sFactory && bValid )
859*cdf0e10cSrcweir     {
860*cdf0e10cSrcweir         sFactory = sNewFactory;
861*cdf0e10cSrcweir         ClearIndex();
862*cdf0e10cSrcweir         if ( bIsActivated )
863*cdf0e10cSrcweir             aFactoryTimer.Start();
864*cdf0e10cSrcweir     }
865*cdf0e10cSrcweir }
866*cdf0e10cSrcweir 
867*cdf0e10cSrcweir // -----------------------------------------------------------------------
868*cdf0e10cSrcweir 
869*cdf0e10cSrcweir String IndexTabPage_Impl::GetSelectEntry() const
870*cdf0e10cSrcweir {
871*cdf0e10cSrcweir 	String aRet;
872*cdf0e10cSrcweir 	IndexEntry_Impl* pEntry = (IndexEntry_Impl*)(sal_uIntPtr)aIndexCB.GetEntryData( aIndexCB.GetEntryPos( aIndexCB.GetText() ) );
873*cdf0e10cSrcweir 	if ( pEntry )
874*cdf0e10cSrcweir 		aRet = pEntry->m_aURL;
875*cdf0e10cSrcweir 	return aRet;
876*cdf0e10cSrcweir }
877*cdf0e10cSrcweir 
878*cdf0e10cSrcweir // -----------------------------------------------------------------------
879*cdf0e10cSrcweir 
880*cdf0e10cSrcweir void IndexTabPage_Impl::SetKeyword( const String& rKeyword )
881*cdf0e10cSrcweir {
882*cdf0e10cSrcweir 	sKeyword = rKeyword;
883*cdf0e10cSrcweir 
884*cdf0e10cSrcweir 	if ( aIndexCB.GetEntryCount() > 0 )
885*cdf0e10cSrcweir 		aKeywordTimer.Start();
886*cdf0e10cSrcweir 	else if ( !bIsActivated )
887*cdf0e10cSrcweir 		aFactoryTimer.Start();
888*cdf0e10cSrcweir }
889*cdf0e10cSrcweir 
890*cdf0e10cSrcweir // -----------------------------------------------------------------------
891*cdf0e10cSrcweir 
892*cdf0e10cSrcweir sal_Bool IndexTabPage_Impl::HasKeyword() const
893*cdf0e10cSrcweir {
894*cdf0e10cSrcweir 	sal_Bool bRet = sal_False;
895*cdf0e10cSrcweir 	if ( sKeyword.Len() > 0 )
896*cdf0e10cSrcweir 	{
897*cdf0e10cSrcweir 		sal_uInt16 nPos = aIndexCB.GetEntryPos( sKeyword );
898*cdf0e10cSrcweir 		bRet = ( nPos != LISTBOX_ENTRY_NOTFOUND );
899*cdf0e10cSrcweir 	}
900*cdf0e10cSrcweir 
901*cdf0e10cSrcweir 	return bRet;
902*cdf0e10cSrcweir }
903*cdf0e10cSrcweir 
904*cdf0e10cSrcweir // -----------------------------------------------------------------------
905*cdf0e10cSrcweir //added by BerryJia for fixing Bug98251, 2002-12-11
906*cdf0e10cSrcweir sal_Bool IndexTabPage_Impl::HasKeywordIgnoreCase()
907*cdf0e10cSrcweir {
908*cdf0e10cSrcweir 	sal_Bool bRet = sal_False;
909*cdf0e10cSrcweir 	if ( sKeyword.Len() > 0 )
910*cdf0e10cSrcweir 	{
911*cdf0e10cSrcweir 		sal_uInt16 nEntries = aIndexCB.GetEntryCount();
912*cdf0e10cSrcweir 		String sIndexItem;
913*cdf0e10cSrcweir 		const vcl::I18nHelper& rI18nHelper = GetSettings().GetLocaleI18nHelper();
914*cdf0e10cSrcweir 		for ( sal_uInt16 n = 0; n < nEntries; n++)
915*cdf0e10cSrcweir 		{
916*cdf0e10cSrcweir 			sIndexItem = aIndexCB.GetEntry( n );
917*cdf0e10cSrcweir 			if (rI18nHelper.MatchString( sIndexItem, sKeyword ))
918*cdf0e10cSrcweir 			{
919*cdf0e10cSrcweir 				sKeyword = sIndexItem;
920*cdf0e10cSrcweir 				bRet = sal_True;
921*cdf0e10cSrcweir 			}
922*cdf0e10cSrcweir 		}
923*cdf0e10cSrcweir 	}
924*cdf0e10cSrcweir 
925*cdf0e10cSrcweir 	return bRet;
926*cdf0e10cSrcweir }
927*cdf0e10cSrcweir 
928*cdf0e10cSrcweir // -----------------------------------------------------------------------
929*cdf0e10cSrcweir 
930*cdf0e10cSrcweir void IndexTabPage_Impl::OpenKeyword()
931*cdf0e10cSrcweir {
932*cdf0e10cSrcweir 	if ( sKeyword.Len() > 0 )
933*cdf0e10cSrcweir 	{
934*cdf0e10cSrcweir 		aIndexCB.SetText( sKeyword );
935*cdf0e10cSrcweir 		aIndexCB.GetDoubleClickHdl().Call( NULL );
936*cdf0e10cSrcweir 		sKeyword.Erase();
937*cdf0e10cSrcweir 	}
938*cdf0e10cSrcweir }
939*cdf0e10cSrcweir 
940*cdf0e10cSrcweir // class SearchBox_Impl --------------------------------------------------
941*cdf0e10cSrcweir 
942*cdf0e10cSrcweir long SearchBox_Impl::PreNotify( NotifyEvent& rNEvt )
943*cdf0e10cSrcweir {
944*cdf0e10cSrcweir 	sal_Bool bHandled = sal_False;
945*cdf0e10cSrcweir 	if ( !IsInDropDown() &&
946*cdf0e10cSrcweir 		 rNEvt.GetWindow() == GetSubEdit() &&
947*cdf0e10cSrcweir 		 rNEvt.GetType() == EVENT_KEYINPUT &&
948*cdf0e10cSrcweir 		 KEY_RETURN == rNEvt.GetKeyEvent()->GetKeyCode().GetCode() )
949*cdf0e10cSrcweir 	{
950*cdf0e10cSrcweir 		aSearchLink.Call( NULL );
951*cdf0e10cSrcweir 		bHandled = sal_True;
952*cdf0e10cSrcweir 	}
953*cdf0e10cSrcweir 	return bHandled ? 1 : ComboBox::PreNotify( rNEvt );
954*cdf0e10cSrcweir }
955*cdf0e10cSrcweir 
956*cdf0e10cSrcweir // -----------------------------------------------------------------------
957*cdf0e10cSrcweir 
958*cdf0e10cSrcweir void SearchBox_Impl::Select()
959*cdf0e10cSrcweir {
960*cdf0e10cSrcweir 	if ( !IsTravelSelect() )
961*cdf0e10cSrcweir 		aSearchLink.Call( NULL );
962*cdf0e10cSrcweir }
963*cdf0e10cSrcweir 
964*cdf0e10cSrcweir // class SearchResultsBox_Impl -------------------------------------------
965*cdf0e10cSrcweir 
966*cdf0e10cSrcweir long SearchResultsBox_Impl::Notify( NotifyEvent& rNEvt )
967*cdf0e10cSrcweir {
968*cdf0e10cSrcweir 	sal_Bool bHandled = sal_False;
969*cdf0e10cSrcweir 	if ( rNEvt.GetType() == EVENT_KEYINPUT &&
970*cdf0e10cSrcweir 		 KEY_RETURN == rNEvt.GetKeyEvent()->GetKeyCode().GetCode() )
971*cdf0e10cSrcweir 	{
972*cdf0e10cSrcweir 		GetDoubleClickHdl().Call( NULL );
973*cdf0e10cSrcweir 		bHandled = sal_True;
974*cdf0e10cSrcweir 	}
975*cdf0e10cSrcweir 
976*cdf0e10cSrcweir 	return bHandled ? 1 : ListBox::Notify( rNEvt );
977*cdf0e10cSrcweir }
978*cdf0e10cSrcweir 
979*cdf0e10cSrcweir // class SearchTabPage_Impl ----------------------------------------------
980*cdf0e10cSrcweir 
981*cdf0e10cSrcweir SearchTabPage_Impl::SearchTabPage_Impl( Window* pParent, SfxHelpIndexWindow_Impl* _pIdxWin ) :
982*cdf0e10cSrcweir 
983*cdf0e10cSrcweir 	HelpTabPage_Impl( pParent, _pIdxWin, SfxResId( TP_HELP_SEARCH ) ),
984*cdf0e10cSrcweir 
985*cdf0e10cSrcweir 	aSearchFT		( this, SfxResId( FT_SEARCH ) ),
986*cdf0e10cSrcweir 	aSearchED		( this, SfxResId( ED_SEARCH ) ),
987*cdf0e10cSrcweir 	aSearchBtn		( this, SfxResId( PB_SEARCH ) ),
988*cdf0e10cSrcweir 	aFullWordsCB	( this, SfxResId( CB_FULLWORDS ) ),
989*cdf0e10cSrcweir 	aScopeCB		( this, SfxResId( CB_SCOPE ) ),
990*cdf0e10cSrcweir 	aResultsLB		( this, SfxResId( LB_RESULT ) ),
991*cdf0e10cSrcweir 	aOpenBtn		( this, SfxResId( PB_OPEN_SEARCH ) ),
992*cdf0e10cSrcweir 	xBreakIterator	( vcl::unohelper::CreateBreakIterator() )
993*cdf0e10cSrcweir 
994*cdf0e10cSrcweir {
995*cdf0e10cSrcweir 	FreeResource();
996*cdf0e10cSrcweir 
997*cdf0e10cSrcweir 	Link aLink = LINK( this, SearchTabPage_Impl, SearchHdl );
998*cdf0e10cSrcweir 	aSearchED.SetSearchLink( aLink );
999*cdf0e10cSrcweir 	aSearchBtn.SetClickHdl( aLink );
1000*cdf0e10cSrcweir 	aSearchED.SetModifyHdl( LINK( this, SearchTabPage_Impl, ModifyHdl ) );
1001*cdf0e10cSrcweir 	aOpenBtn.SetClickHdl( LINK( this, SearchTabPage_Impl, OpenHdl ) );
1002*cdf0e10cSrcweir 
1003*cdf0e10cSrcweir 	aMinSize = GetSizePixel();
1004*cdf0e10cSrcweir 
1005*cdf0e10cSrcweir 	SvtViewOptions aViewOpt( E_TABPAGE, CONFIGNAME_SEARCHPAGE );
1006*cdf0e10cSrcweir 	if ( aViewOpt.Exists() )
1007*cdf0e10cSrcweir 	{
1008*cdf0e10cSrcweir 		String aUserData;
1009*cdf0e10cSrcweir         Any aUserItem = aViewOpt.GetUserItem( USERITEM_NAME );
1010*cdf0e10cSrcweir 		::rtl::OUString aTemp;
1011*cdf0e10cSrcweir 		if ( aUserItem >>= aTemp )
1012*cdf0e10cSrcweir 		{
1013*cdf0e10cSrcweir 			aUserData = String( aTemp );
1014*cdf0e10cSrcweir 			sal_Bool bChecked = ( 1 == aUserData.GetToken(0).ToInt32() ) ? sal_True : sal_False;
1015*cdf0e10cSrcweir 			aFullWordsCB.Check( bChecked );
1016*cdf0e10cSrcweir 			bChecked = ( 1 == aUserData.GetToken(1).ToInt32() ) ? sal_True : sal_False;
1017*cdf0e10cSrcweir 			aScopeCB.Check( bChecked );
1018*cdf0e10cSrcweir 
1019*cdf0e10cSrcweir 			for ( sal_uInt16 i = 2; i < aUserData.GetTokenCount(); ++i )
1020*cdf0e10cSrcweir 			{
1021*cdf0e10cSrcweir 				String aToken = aUserData.GetToken(i);
1022*cdf0e10cSrcweir 				aSearchED.InsertEntry( INetURLObject::decode(
1023*cdf0e10cSrcweir 					aToken, '%', INetURLObject::DECODE_WITH_CHARSET ) );
1024*cdf0e10cSrcweir 			}
1025*cdf0e10cSrcweir 		}
1026*cdf0e10cSrcweir 	}
1027*cdf0e10cSrcweir 
1028*cdf0e10cSrcweir 	ModifyHdl( &aSearchED );
1029*cdf0e10cSrcweir }
1030*cdf0e10cSrcweir 
1031*cdf0e10cSrcweir // -----------------------------------------------------------------------
1032*cdf0e10cSrcweir 
1033*cdf0e10cSrcweir SearchTabPage_Impl::~SearchTabPage_Impl()
1034*cdf0e10cSrcweir {
1035*cdf0e10cSrcweir 	SvtViewOptions aViewOpt( E_TABPAGE, CONFIGNAME_SEARCHPAGE );
1036*cdf0e10cSrcweir 	sal_Int32 nChecked = aFullWordsCB.IsChecked() ? 1 : 0;
1037*cdf0e10cSrcweir 	String aUserData = String::CreateFromInt32( nChecked );
1038*cdf0e10cSrcweir 	aUserData += ';';
1039*cdf0e10cSrcweir 	nChecked = aScopeCB.IsChecked() ? 1 : 0;
1040*cdf0e10cSrcweir 	aUserData += String::CreateFromInt32( nChecked );
1041*cdf0e10cSrcweir 	aUserData += ';';
1042*cdf0e10cSrcweir 	sal_uInt16 nCount = Min( aSearchED.GetEntryCount(), (sal_uInt16)10 );  // save only 10 entries
1043*cdf0e10cSrcweir 
1044*cdf0e10cSrcweir 	for ( sal_uInt16 i = 0; i < nCount; ++i )
1045*cdf0e10cSrcweir 	{
1046*cdf0e10cSrcweir 		rtl::OUString aText = aSearchED.GetEntry(i);
1047*cdf0e10cSrcweir 		aUserData += String(INetURLObject::encode(
1048*cdf0e10cSrcweir 			aText, INetURLObject::PART_UNO_PARAM_VALUE, '%',
1049*cdf0e10cSrcweir 			INetURLObject::ENCODE_ALL ));
1050*cdf0e10cSrcweir 		aUserData += ';';
1051*cdf0e10cSrcweir 	}
1052*cdf0e10cSrcweir 
1053*cdf0e10cSrcweir 	aUserData.EraseTrailingChars(';');
1054*cdf0e10cSrcweir 	Any aUserItem = makeAny( ::rtl::OUString( aUserData ) );
1055*cdf0e10cSrcweir     aViewOpt.SetUserItem( USERITEM_NAME, aUserItem );
1056*cdf0e10cSrcweir }
1057*cdf0e10cSrcweir 
1058*cdf0e10cSrcweir // -----------------------------------------------------------------------
1059*cdf0e10cSrcweir 
1060*cdf0e10cSrcweir void SearchTabPage_Impl::ClearSearchResults()
1061*cdf0e10cSrcweir {
1062*cdf0e10cSrcweir 	sal_uInt16 nCount = aResultsLB.GetEntryCount();
1063*cdf0e10cSrcweir 	for ( sal_uInt16 i = 0; i < nCount; ++i )
1064*cdf0e10cSrcweir 		delete (String*)(sal_uIntPtr)aResultsLB.GetEntryData(i);
1065*cdf0e10cSrcweir 	aResultsLB.Clear();
1066*cdf0e10cSrcweir 	aResultsLB.Update();
1067*cdf0e10cSrcweir }
1068*cdf0e10cSrcweir 
1069*cdf0e10cSrcweir // -----------------------------------------------------------------------
1070*cdf0e10cSrcweir 
1071*cdf0e10cSrcweir void SearchTabPage_Impl::RememberSearchText( const String& rSearchText )
1072*cdf0e10cSrcweir {
1073*cdf0e10cSrcweir 	for ( sal_uInt16 i = 0; i < aSearchED.GetEntryCount(); ++i )
1074*cdf0e10cSrcweir 	{
1075*cdf0e10cSrcweir 		if ( rSearchText == aSearchED.GetEntry(i) )
1076*cdf0e10cSrcweir 		{
1077*cdf0e10cSrcweir 			aSearchED.RemoveEntry(i);
1078*cdf0e10cSrcweir 			break;
1079*cdf0e10cSrcweir 		}
1080*cdf0e10cSrcweir 	}
1081*cdf0e10cSrcweir 
1082*cdf0e10cSrcweir 	aSearchED.InsertEntry( rSearchText, 0 );
1083*cdf0e10cSrcweir }
1084*cdf0e10cSrcweir 
1085*cdf0e10cSrcweir // -----------------------------------------------------------------------
1086*cdf0e10cSrcweir 
1087*cdf0e10cSrcweir IMPL_LINK( SearchTabPage_Impl, SearchHdl, PushButton*, EMPTYARG )
1088*cdf0e10cSrcweir {
1089*cdf0e10cSrcweir 	String aSearchText = TRIM( aSearchED.GetText() );
1090*cdf0e10cSrcweir 	if ( aSearchText.Len() > 0 )
1091*cdf0e10cSrcweir 	{
1092*cdf0e10cSrcweir 		EnterWait();
1093*cdf0e10cSrcweir 		ClearSearchResults();
1094*cdf0e10cSrcweir 		RememberSearchText( aSearchText );
1095*cdf0e10cSrcweir 		String aSearchURL = HELP_URL;
1096*cdf0e10cSrcweir 		aSearchURL += aFactory;
1097*cdf0e10cSrcweir 		aSearchURL += String( HELP_SEARCH_TAG );
1098*cdf0e10cSrcweir 		if ( !aFullWordsCB.IsChecked() )
1099*cdf0e10cSrcweir 			aSearchText = sfx2::PrepareSearchString( aSearchText, xBreakIterator, true );
1100*cdf0e10cSrcweir 		aSearchURL += aSearchText;
1101*cdf0e10cSrcweir 		AppendConfigToken_Impl( aSearchURL, sal_False );
1102*cdf0e10cSrcweir 		if ( aScopeCB.IsChecked() )
1103*cdf0e10cSrcweir 			aSearchURL += DEFINE_CONST_UNICODE("&Scope=Heading");
1104*cdf0e10cSrcweir 		Sequence< ::rtl::OUString > aFactories = SfxContentHelper::GetResultSet( aSearchURL );
1105*cdf0e10cSrcweir 		const ::rtl::OUString* pFacs  = aFactories.getConstArray();
1106*cdf0e10cSrcweir 		sal_uInt32 i, nCount = aFactories.getLength();
1107*cdf0e10cSrcweir 		for ( i = 0; i < nCount; ++i )
1108*cdf0e10cSrcweir 		{
1109*cdf0e10cSrcweir 			String aRow( pFacs[i] );
1110*cdf0e10cSrcweir 			String aTitle, aType;
1111*cdf0e10cSrcweir 			xub_StrLen nIdx = 0;
1112*cdf0e10cSrcweir 			aTitle = aRow.GetToken( 0, '\t', nIdx );
1113*cdf0e10cSrcweir 			aType = aRow.GetToken( 0, '\t', nIdx );
1114*cdf0e10cSrcweir 			String* pURL = new String( aRow.GetToken( 0, '\t', nIdx ) );
1115*cdf0e10cSrcweir 			sal_uInt16 nPos = aResultsLB.InsertEntry( aTitle );
1116*cdf0e10cSrcweir 			aResultsLB.SetEntryData( nPos, (void*)(sal_uIntPtr)pURL );
1117*cdf0e10cSrcweir 		}
1118*cdf0e10cSrcweir 		LeaveWait();
1119*cdf0e10cSrcweir 
1120*cdf0e10cSrcweir 		if ( !nCount )
1121*cdf0e10cSrcweir 		{
1122*cdf0e10cSrcweir 			InfoBox aBox( this, SfxResId( RID_INFO_NOSEARCHRESULTS ) );
1123*cdf0e10cSrcweir 			aBox.SetText( String( SfxResId( STR_HELP_WINDOW_TITLE ) ) );
1124*cdf0e10cSrcweir 			aBox.Execute();
1125*cdf0e10cSrcweir 		}
1126*cdf0e10cSrcweir 	}
1127*cdf0e10cSrcweir 	return 0;
1128*cdf0e10cSrcweir }
1129*cdf0e10cSrcweir 
1130*cdf0e10cSrcweir // -----------------------------------------------------------------------
1131*cdf0e10cSrcweir 
1132*cdf0e10cSrcweir IMPL_LINK( SearchTabPage_Impl, OpenHdl, PushButton*, EMPTYARG )
1133*cdf0e10cSrcweir {
1134*cdf0e10cSrcweir 	aResultsLB.GetDoubleClickHdl().Call( &aResultsLB );
1135*cdf0e10cSrcweir 	return 0;
1136*cdf0e10cSrcweir }
1137*cdf0e10cSrcweir 
1138*cdf0e10cSrcweir // -----------------------------------------------------------------------
1139*cdf0e10cSrcweir 
1140*cdf0e10cSrcweir IMPL_LINK( SearchTabPage_Impl, ModifyHdl, Edit*, EMPTYARG )
1141*cdf0e10cSrcweir {
1142*cdf0e10cSrcweir 	String aSearchText = TRIM( aSearchED.GetText() );
1143*cdf0e10cSrcweir 	aSearchBtn.Enable( aSearchText.Len() > 0 );
1144*cdf0e10cSrcweir 	return 0;
1145*cdf0e10cSrcweir }
1146*cdf0e10cSrcweir 
1147*cdf0e10cSrcweir // -----------------------------------------------------------------------
1148*cdf0e10cSrcweir 
1149*cdf0e10cSrcweir void SearchTabPage_Impl::Resize()
1150*cdf0e10cSrcweir {
1151*cdf0e10cSrcweir 	Size a6Size = LogicToPixel( Size( 6, 6 ), MAP_APPFONT );
1152*cdf0e10cSrcweir 	Size aSize = GetSizePixel();
1153*cdf0e10cSrcweir 	if ( aSize.Width() < aMinSize.Width() )
1154*cdf0e10cSrcweir 		aSize.Width() = aMinSize.Width();
1155*cdf0e10cSrcweir 	Point aPnt = aSearchFT.GetPosPixel();
1156*cdf0e10cSrcweir 	Size aNewSize = aSearchFT.GetSizePixel();
1157*cdf0e10cSrcweir 	aNewSize.Width() = aSize.Width() - ( aPnt.X() * 2 );
1158*cdf0e10cSrcweir 	aSearchFT.SetSizePixel( aNewSize );
1159*cdf0e10cSrcweir     aNewSize.Height() = aResultsLB.GetSizePixel().Height();
1160*cdf0e10cSrcweir     aResultsLB.SetSizePixel( aNewSize );
1161*cdf0e10cSrcweir     aNewSize.Height() = aFullWordsCB.GetSizePixel().Height();
1162*cdf0e10cSrcweir     aFullWordsCB.SetSizePixel( aNewSize );
1163*cdf0e10cSrcweir     aScopeCB.SetSizePixel( aNewSize );
1164*cdf0e10cSrcweir     aNewSize = aSearchED.GetSizePixel();
1165*cdf0e10cSrcweir 	aNewSize.Width() = aSize.Width() - ( aPnt.X() * 2 ) -
1166*cdf0e10cSrcweir 					   ( aSearchBtn.GetSizePixel().Width() + ( aPnt.X() / 2 ) );
1167*cdf0e10cSrcweir 	aSearchED.SetSizePixel( aNewSize );
1168*cdf0e10cSrcweir 	Point aNewPnt = aSearchBtn.GetPosPixel();
1169*cdf0e10cSrcweir 	aNewPnt.X() = aPnt.X() + aNewSize.Width() + ( aPnt.X() / 2 );
1170*cdf0e10cSrcweir 	aSearchBtn.SetPosPixel( aNewPnt );
1171*cdf0e10cSrcweir 
1172*cdf0e10cSrcweir 	if ( aSize.Height() > aMinSize.Height() )
1173*cdf0e10cSrcweir 	{
1174*cdf0e10cSrcweir 		long n3Height = a6Size.Height() / 2;
1175*cdf0e10cSrcweir 		Size aBtnSize = aOpenBtn.GetSizePixel();
1176*cdf0e10cSrcweir 		long nExtraHeight = aBtnSize.Height() + n3Height;
1177*cdf0e10cSrcweir 
1178*cdf0e10cSrcweir 		aPnt = aResultsLB.GetPosPixel();
1179*cdf0e10cSrcweir 		aNewSize = aResultsLB.GetSizePixel();
1180*cdf0e10cSrcweir 		aNewSize.Height() = aSize.Height() - aPnt.Y();
1181*cdf0e10cSrcweir 		aNewSize.Height() -= ( nExtraHeight + ( a6Size.Height() * 3 / 2 ) );
1182*cdf0e10cSrcweir 		aResultsLB.SetSizePixel( aNewSize );
1183*cdf0e10cSrcweir 
1184*cdf0e10cSrcweir 		aPnt.X() += ( aNewSize.Width() - aBtnSize.Width() );
1185*cdf0e10cSrcweir 		aPnt.Y() += aNewSize.Height() + a6Size.Height();
1186*cdf0e10cSrcweir 		aOpenBtn.SetPosPixel( aPnt );
1187*cdf0e10cSrcweir 	}
1188*cdf0e10cSrcweir }
1189*cdf0e10cSrcweir 
1190*cdf0e10cSrcweir // -----------------------------------------------------------------------
1191*cdf0e10cSrcweir 
1192*cdf0e10cSrcweir void SearchTabPage_Impl::ActivatePage()
1193*cdf0e10cSrcweir {
1194*cdf0e10cSrcweir 	if ( !m_pIdxWin->WasCursorLeftOrRight() )
1195*cdf0e10cSrcweir 		aSearchED.GrabFocus();
1196*cdf0e10cSrcweir }
1197*cdf0e10cSrcweir 
1198*cdf0e10cSrcweir // -----------------------------------------------------------------------
1199*cdf0e10cSrcweir 
1200*cdf0e10cSrcweir Control* SearchTabPage_Impl::GetLastFocusControl()
1201*cdf0e10cSrcweir {
1202*cdf0e10cSrcweir 	return &aOpenBtn;
1203*cdf0e10cSrcweir }
1204*cdf0e10cSrcweir 
1205*cdf0e10cSrcweir // -----------------------------------------------------------------------
1206*cdf0e10cSrcweir 
1207*cdf0e10cSrcweir void SearchTabPage_Impl::SetDoubleClickHdl( const Link& rLink )
1208*cdf0e10cSrcweir {
1209*cdf0e10cSrcweir 	aResultsLB.SetDoubleClickHdl( rLink );
1210*cdf0e10cSrcweir }
1211*cdf0e10cSrcweir 
1212*cdf0e10cSrcweir // -----------------------------------------------------------------------
1213*cdf0e10cSrcweir 
1214*cdf0e10cSrcweir String SearchTabPage_Impl::GetSelectEntry() const
1215*cdf0e10cSrcweir {
1216*cdf0e10cSrcweir 	String aRet;
1217*cdf0e10cSrcweir 	String* pData = (String*)(sal_uIntPtr)aResultsLB.GetEntryData( aResultsLB.GetSelectEntryPos() );
1218*cdf0e10cSrcweir 	if ( pData )
1219*cdf0e10cSrcweir 		aRet = String( *pData );
1220*cdf0e10cSrcweir 	return aRet;
1221*cdf0e10cSrcweir }
1222*cdf0e10cSrcweir 
1223*cdf0e10cSrcweir // -----------------------------------------------------------------------
1224*cdf0e10cSrcweir 
1225*cdf0e10cSrcweir void SearchTabPage_Impl::ClearPage()
1226*cdf0e10cSrcweir {
1227*cdf0e10cSrcweir 	ClearSearchResults();
1228*cdf0e10cSrcweir 	aSearchED.SetText( String() );
1229*cdf0e10cSrcweir }
1230*cdf0e10cSrcweir 
1231*cdf0e10cSrcweir // -----------------------------------------------------------------------
1232*cdf0e10cSrcweir 
1233*cdf0e10cSrcweir sal_Bool SearchTabPage_Impl::OpenKeyword( const String& rKeyword )
1234*cdf0e10cSrcweir {
1235*cdf0e10cSrcweir 	sal_Bool bRet = sal_False;
1236*cdf0e10cSrcweir 	aSearchED.SetText( rKeyword );
1237*cdf0e10cSrcweir 	SearchHdl( NULL );
1238*cdf0e10cSrcweir 	if ( aResultsLB.GetEntryCount() > 0 )
1239*cdf0e10cSrcweir 	{
1240*cdf0e10cSrcweir 		// found keyword -> open it
1241*cdf0e10cSrcweir 		aResultsLB.SelectEntryPos(0);
1242*cdf0e10cSrcweir 		OpenHdl( NULL );
1243*cdf0e10cSrcweir 		bRet = sal_True;
1244*cdf0e10cSrcweir 	}
1245*cdf0e10cSrcweir 
1246*cdf0e10cSrcweir 	return bRet;
1247*cdf0e10cSrcweir }
1248*cdf0e10cSrcweir 
1249*cdf0e10cSrcweir // class BookmarksTabPage_Impl -------------------------------------------
1250*cdf0e10cSrcweir 
1251*cdf0e10cSrcweir void GetBookmarkEntry_Impl
1252*cdf0e10cSrcweir (
1253*cdf0e10cSrcweir 	Sequence< PropertyValue >& aBookmarkEntry,
1254*cdf0e10cSrcweir 	::rtl::OUString& rTitle,
1255*cdf0e10cSrcweir 	::rtl::OUString& rURL
1256*cdf0e10cSrcweir )
1257*cdf0e10cSrcweir {
1258*cdf0e10cSrcweir 	for ( int i = 0; i < aBookmarkEntry.getLength(); i++ )
1259*cdf0e10cSrcweir 	{
1260*cdf0e10cSrcweir 		PropertyValue aValue = aBookmarkEntry[i];
1261*cdf0e10cSrcweir 		if ( aValue.Name == HISTORY_PROPERTYNAME_URL )
1262*cdf0e10cSrcweir 			aValue.Value >>= rURL;
1263*cdf0e10cSrcweir 		else if ( aValue.Name == HISTORY_PROPERTYNAME_TITLE )
1264*cdf0e10cSrcweir 			aValue.Value >>= rTitle;
1265*cdf0e10cSrcweir 	}
1266*cdf0e10cSrcweir }
1267*cdf0e10cSrcweir 
1268*cdf0e10cSrcweir // -----------------------------------------------------------------------
1269*cdf0e10cSrcweir 
1270*cdf0e10cSrcweir BookmarksBox_Impl::BookmarksBox_Impl( Window* pParent, const ResId& rResId ) :
1271*cdf0e10cSrcweir 
1272*cdf0e10cSrcweir 	ListBox( pParent, rResId )
1273*cdf0e10cSrcweir 
1274*cdf0e10cSrcweir {
1275*cdf0e10cSrcweir }
1276*cdf0e10cSrcweir 
1277*cdf0e10cSrcweir // -----------------------------------------------------------------------
1278*cdf0e10cSrcweir 
1279*cdf0e10cSrcweir BookmarksBox_Impl::~BookmarksBox_Impl()
1280*cdf0e10cSrcweir {
1281*cdf0e10cSrcweir 	// save bookmarks to configuration
1282*cdf0e10cSrcweir 	SvtHistoryOptions aHistOpt;
1283*cdf0e10cSrcweir 	aHistOpt.Clear( eHELPBOOKMARKS );
1284*cdf0e10cSrcweir 	rtl::OUString sEmpty;
1285*cdf0e10cSrcweir 	sal_uInt16 nCount = GetEntryCount();
1286*cdf0e10cSrcweir 	for ( sal_uInt16 i = 0; i < nCount; ++i )
1287*cdf0e10cSrcweir 	{
1288*cdf0e10cSrcweir 		String aTitle = GetEntry(i);
1289*cdf0e10cSrcweir 		String* pURL = (String*)(sal_uIntPtr)GetEntryData(i);
1290*cdf0e10cSrcweir 		aHistOpt.AppendItem( eHELPBOOKMARKS, rtl::OUString( *pURL ), sEmpty, rtl::OUString( aTitle ), sEmpty );
1291*cdf0e10cSrcweir 		delete pURL;
1292*cdf0e10cSrcweir 	}
1293*cdf0e10cSrcweir }
1294*cdf0e10cSrcweir 
1295*cdf0e10cSrcweir // -----------------------------------------------------------------------
1296*cdf0e10cSrcweir 
1297*cdf0e10cSrcweir void BookmarksBox_Impl::DoAction( sal_uInt16 nAction )
1298*cdf0e10cSrcweir {
1299*cdf0e10cSrcweir 	switch ( nAction )
1300*cdf0e10cSrcweir 	{
1301*cdf0e10cSrcweir 		case MID_OPEN :
1302*cdf0e10cSrcweir 			GetDoubleClickHdl().Call( NULL );
1303*cdf0e10cSrcweir 			break;
1304*cdf0e10cSrcweir 
1305*cdf0e10cSrcweir 		case MID_RENAME :
1306*cdf0e10cSrcweir 	   	{
1307*cdf0e10cSrcweir 			sal_uInt16 nPos = GetSelectEntryPos();
1308*cdf0e10cSrcweir 			if ( nPos != LISTBOX_ENTRY_NOTFOUND )
1309*cdf0e10cSrcweir 			{
1310*cdf0e10cSrcweir 				SfxAddHelpBookmarkDialog_Impl aDlg( this, sal_True );
1311*cdf0e10cSrcweir 				aDlg.SetTitle( GetEntry( nPos ) );
1312*cdf0e10cSrcweir 				if ( aDlg.Execute() == RET_OK )
1313*cdf0e10cSrcweir 				{
1314*cdf0e10cSrcweir 					String* pURL = (String*)(sal_uIntPtr)GetEntryData( nPos );
1315*cdf0e10cSrcweir 					RemoveEntry( nPos );
1316*cdf0e10cSrcweir 					rtl::OUString aImageURL = IMAGE_URL;
1317*cdf0e10cSrcweir 					aImageURL += INetURLObject( *pURL ).GetHost();
1318*cdf0e10cSrcweir 					nPos = InsertEntry( aDlg.GetTitle(), SvFileInformationManager::GetImage( aImageURL ) );
1319*cdf0e10cSrcweir 					SetEntryData( nPos, (void*)(sal_uIntPtr)( new String( *pURL ) ) );
1320*cdf0e10cSrcweir 					SelectEntryPos( nPos );
1321*cdf0e10cSrcweir 					delete pURL;
1322*cdf0e10cSrcweir 				}
1323*cdf0e10cSrcweir 			}
1324*cdf0e10cSrcweir 			break;
1325*cdf0e10cSrcweir 		}
1326*cdf0e10cSrcweir 
1327*cdf0e10cSrcweir 		case MID_DELETE :
1328*cdf0e10cSrcweir 		{
1329*cdf0e10cSrcweir 			sal_uInt16 nPos = GetSelectEntryPos();
1330*cdf0e10cSrcweir 			if ( nPos != LISTBOX_ENTRY_NOTFOUND )
1331*cdf0e10cSrcweir 			{
1332*cdf0e10cSrcweir 				RemoveEntry( nPos );
1333*cdf0e10cSrcweir 				sal_uInt16 nCount = GetEntryCount();
1334*cdf0e10cSrcweir 				if ( nCount )
1335*cdf0e10cSrcweir 				{
1336*cdf0e10cSrcweir 					if ( nPos >= nCount )
1337*cdf0e10cSrcweir 						nPos = nCount - 1;
1338*cdf0e10cSrcweir 					SelectEntryPos( nPos );
1339*cdf0e10cSrcweir 				}
1340*cdf0e10cSrcweir 			}
1341*cdf0e10cSrcweir 			break;
1342*cdf0e10cSrcweir 		}
1343*cdf0e10cSrcweir 	}
1344*cdf0e10cSrcweir }
1345*cdf0e10cSrcweir 
1346*cdf0e10cSrcweir // -----------------------------------------------------------------------
1347*cdf0e10cSrcweir 
1348*cdf0e10cSrcweir long BookmarksBox_Impl::Notify( NotifyEvent& rNEvt )
1349*cdf0e10cSrcweir {
1350*cdf0e10cSrcweir 	long nRet = 0;
1351*cdf0e10cSrcweir 	sal_uInt16 nType = rNEvt.GetType();
1352*cdf0e10cSrcweir 	if ( EVENT_KEYINPUT == nType )
1353*cdf0e10cSrcweir 	{
1354*cdf0e10cSrcweir 		sal_uInt16 nCode = rNEvt.GetKeyEvent()->GetKeyCode().GetCode();
1355*cdf0e10cSrcweir 		if ( KEY_DELETE == nCode && GetEntryCount() > 0 )
1356*cdf0e10cSrcweir 		{
1357*cdf0e10cSrcweir 			DoAction( MID_DELETE );
1358*cdf0e10cSrcweir 			nRet = 1;
1359*cdf0e10cSrcweir 		}
1360*cdf0e10cSrcweir 		else if ( KEY_RETURN == nCode )
1361*cdf0e10cSrcweir 		{
1362*cdf0e10cSrcweir 			GetDoubleClickHdl().Call( NULL );
1363*cdf0e10cSrcweir 			nRet = 1;
1364*cdf0e10cSrcweir 		}
1365*cdf0e10cSrcweir 	}
1366*cdf0e10cSrcweir 	else if ( EVENT_COMMAND == nType )
1367*cdf0e10cSrcweir 	{
1368*cdf0e10cSrcweir 		const CommandEvent* pCEvt = rNEvt.GetCommandEvent();
1369*cdf0e10cSrcweir 		if ( pCEvt->GetCommand() == COMMAND_CONTEXTMENU )
1370*cdf0e10cSrcweir 		{
1371*cdf0e10cSrcweir 			PopupMenu aMenu( SfxResId( MENU_HELP_BOOKMARKS ) );
1372*cdf0e10cSrcweir             sal_uInt16 nId = aMenu.Execute( this, pCEvt->GetMousePosPixel() );
1373*cdf0e10cSrcweir 			if ( nId != MENU_ITEM_NOTFOUND )
1374*cdf0e10cSrcweir 				DoAction( nId );
1375*cdf0e10cSrcweir 			nRet = 1;
1376*cdf0e10cSrcweir 		}
1377*cdf0e10cSrcweir 	}
1378*cdf0e10cSrcweir 
1379*cdf0e10cSrcweir 	return nRet ? nRet : ListBox::Notify( rNEvt );
1380*cdf0e10cSrcweir }
1381*cdf0e10cSrcweir 
1382*cdf0e10cSrcweir // class BookmarksTabPage_Impl -------------------------------------------
1383*cdf0e10cSrcweir 
1384*cdf0e10cSrcweir BookmarksTabPage_Impl::BookmarksTabPage_Impl( Window* pParent, SfxHelpIndexWindow_Impl* _pIdxWin ) :
1385*cdf0e10cSrcweir 
1386*cdf0e10cSrcweir 	HelpTabPage_Impl( pParent, _pIdxWin, SfxResId( TP_HELP_BOOKMARKS ) ),
1387*cdf0e10cSrcweir 
1388*cdf0e10cSrcweir 	aBookmarksFT	( this, SfxResId( FT_BOOKMARKS ) ),
1389*cdf0e10cSrcweir 	aBookmarksBox	( this, SfxResId( LB_BOOKMARKS ) ),
1390*cdf0e10cSrcweir 	aBookmarksPB	( this, SfxResId( PB_BOOKMARKS ) )
1391*cdf0e10cSrcweir 
1392*cdf0e10cSrcweir {
1393*cdf0e10cSrcweir 	FreeResource();
1394*cdf0e10cSrcweir 
1395*cdf0e10cSrcweir 	nMinWidth = aBookmarksPB.GetSizePixel().Width();
1396*cdf0e10cSrcweir 
1397*cdf0e10cSrcweir 	aBookmarksPB.SetClickHdl( LINK( this, BookmarksTabPage_Impl, OpenHdl ) );
1398*cdf0e10cSrcweir 
1399*cdf0e10cSrcweir 	// load bookmarks from configuration
1400*cdf0e10cSrcweir 	Sequence< Sequence< PropertyValue > > aBookmarkSeq;
1401*cdf0e10cSrcweir 	aBookmarkSeq = SvtHistoryOptions().GetList( eHELPBOOKMARKS );
1402*cdf0e10cSrcweir 
1403*cdf0e10cSrcweir 	::rtl::OUString aTitle;
1404*cdf0e10cSrcweir 	::rtl::OUString aURL;
1405*cdf0e10cSrcweir 
1406*cdf0e10cSrcweir 	sal_uInt32 i, nCount = aBookmarkSeq.getLength();
1407*cdf0e10cSrcweir 	for ( i = 0; i < nCount; ++i )
1408*cdf0e10cSrcweir 	{
1409*cdf0e10cSrcweir 		GetBookmarkEntry_Impl( aBookmarkSeq[i], aTitle, aURL );
1410*cdf0e10cSrcweir 		AddBookmarks( aTitle, aURL );
1411*cdf0e10cSrcweir 	}
1412*cdf0e10cSrcweir }
1413*cdf0e10cSrcweir 
1414*cdf0e10cSrcweir // -----------------------------------------------------------------------
1415*cdf0e10cSrcweir 
1416*cdf0e10cSrcweir IMPL_LINK( BookmarksTabPage_Impl, OpenHdl, PushButton*, EMPTYARG )
1417*cdf0e10cSrcweir {
1418*cdf0e10cSrcweir 	aBookmarksBox.GetDoubleClickHdl().Call( &aBookmarksBox );
1419*cdf0e10cSrcweir 	return 0;
1420*cdf0e10cSrcweir }
1421*cdf0e10cSrcweir 
1422*cdf0e10cSrcweir // -----------------------------------------------------------------------
1423*cdf0e10cSrcweir 
1424*cdf0e10cSrcweir void BookmarksTabPage_Impl::Resize()
1425*cdf0e10cSrcweir {
1426*cdf0e10cSrcweir 	Size aSize = GetSizePixel();
1427*cdf0e10cSrcweir 	if ( aSize.Width() < nMinWidth )
1428*cdf0e10cSrcweir 		aSize.Width() = nMinWidth;
1429*cdf0e10cSrcweir 	Point aPnt = aBookmarksFT.GetPosPixel();
1430*cdf0e10cSrcweir 	Size aNewSize = aBookmarksFT.GetSizePixel();
1431*cdf0e10cSrcweir 	aNewSize.Width() = aSize.Width() - ( aPnt.X() * 2 );
1432*cdf0e10cSrcweir 	aBookmarksFT.SetSizePixel( aNewSize );
1433*cdf0e10cSrcweir 
1434*cdf0e10cSrcweir 	Size a6Size = LogicToPixel( Size( 6, 6 ), MAP_APPFONT );
1435*cdf0e10cSrcweir 	Size aBtnSize = aBookmarksPB.GetSizePixel();
1436*cdf0e10cSrcweir 
1437*cdf0e10cSrcweir 	aPnt = aBookmarksBox.GetPosPixel();
1438*cdf0e10cSrcweir 	aNewSize = aBookmarksBox.GetSizePixel();
1439*cdf0e10cSrcweir 	aNewSize.Width() = aSize.Width() - ( aPnt.X() * 2 );
1440*cdf0e10cSrcweir 	aNewSize.Height() = aSize.Height() - aPnt.Y();
1441*cdf0e10cSrcweir 	aNewSize.Height() -= ( aBtnSize.Height() + ( a6Size.Height() * 3 / 2 ) );
1442*cdf0e10cSrcweir 	aBookmarksBox.SetSizePixel( aNewSize );
1443*cdf0e10cSrcweir 
1444*cdf0e10cSrcweir 	aPnt.X() += ( aNewSize.Width() - aBtnSize.Width() );
1445*cdf0e10cSrcweir 	aPnt.Y() += aNewSize.Height() + ( a6Size.Height() / 2 );
1446*cdf0e10cSrcweir 	long nMinX = aBookmarksBox.GetPosPixel().X();
1447*cdf0e10cSrcweir 	if ( aPnt.X() < nMinX )
1448*cdf0e10cSrcweir 		aPnt.X() = nMinX;
1449*cdf0e10cSrcweir 	aBookmarksPB.SetPosPixel( aPnt );
1450*cdf0e10cSrcweir }
1451*cdf0e10cSrcweir 
1452*cdf0e10cSrcweir // -----------------------------------------------------------------------
1453*cdf0e10cSrcweir 
1454*cdf0e10cSrcweir void BookmarksTabPage_Impl::ActivatePage()
1455*cdf0e10cSrcweir {
1456*cdf0e10cSrcweir 	if ( !m_pIdxWin->WasCursorLeftOrRight() )
1457*cdf0e10cSrcweir 		SetFocusOnBox();
1458*cdf0e10cSrcweir }
1459*cdf0e10cSrcweir 
1460*cdf0e10cSrcweir // -----------------------------------------------------------------------
1461*cdf0e10cSrcweir 
1462*cdf0e10cSrcweir Control* BookmarksTabPage_Impl::GetLastFocusControl()
1463*cdf0e10cSrcweir {
1464*cdf0e10cSrcweir 	return &aBookmarksPB;
1465*cdf0e10cSrcweir }
1466*cdf0e10cSrcweir 
1467*cdf0e10cSrcweir // -----------------------------------------------------------------------
1468*cdf0e10cSrcweir 
1469*cdf0e10cSrcweir void BookmarksTabPage_Impl::SetDoubleClickHdl( const Link& rLink )
1470*cdf0e10cSrcweir {
1471*cdf0e10cSrcweir 	aBookmarksBox.SetDoubleClickHdl( rLink );
1472*cdf0e10cSrcweir }
1473*cdf0e10cSrcweir 
1474*cdf0e10cSrcweir // -----------------------------------------------------------------------
1475*cdf0e10cSrcweir 
1476*cdf0e10cSrcweir String BookmarksTabPage_Impl::GetSelectEntry() const
1477*cdf0e10cSrcweir {
1478*cdf0e10cSrcweir 	String aRet;
1479*cdf0e10cSrcweir 	String* pData = (String*)(sal_uIntPtr)aBookmarksBox.GetEntryData( aBookmarksBox.GetSelectEntryPos() );
1480*cdf0e10cSrcweir 	if ( pData )
1481*cdf0e10cSrcweir 		aRet = String( *pData );
1482*cdf0e10cSrcweir 	return aRet;
1483*cdf0e10cSrcweir }
1484*cdf0e10cSrcweir 
1485*cdf0e10cSrcweir // -----------------------------------------------------------------------
1486*cdf0e10cSrcweir 
1487*cdf0e10cSrcweir void BookmarksTabPage_Impl::AddBookmarks( const String& rTitle, const String& rURL )
1488*cdf0e10cSrcweir {
1489*cdf0e10cSrcweir 	rtl::OUString aImageURL = IMAGE_URL;
1490*cdf0e10cSrcweir 	aImageURL += INetURLObject( rURL ).GetHost();
1491*cdf0e10cSrcweir 	sal_uInt16 nPos = aBookmarksBox.InsertEntry( rTitle, SvFileInformationManager::GetImage( aImageURL ) );
1492*cdf0e10cSrcweir 	aBookmarksBox.SetEntryData( nPos, (void*)(sal_uIntPtr)( new String( rURL ) ) );
1493*cdf0e10cSrcweir }
1494*cdf0e10cSrcweir 
1495*cdf0e10cSrcweir // class SfxHelpIndexWindow_Impl -----------------------------------------
1496*cdf0e10cSrcweir 
1497*cdf0e10cSrcweir sal_Bool SfxHelpWindow_Impl::splitHelpURL(const ::rtl::OUString& sHelpURL,
1498*cdf0e10cSrcweir                                                 ::rtl::OUString& sFactory,
1499*cdf0e10cSrcweir                                                 ::rtl::OUString& sContent,
1500*cdf0e10cSrcweir                                                 ::rtl::OUString& sAnchor )
1501*cdf0e10cSrcweir {
1502*cdf0e10cSrcweir     Reference < XURLTransformer > xParser( ::comphelper::getProcessServiceFactory()->createInstance(
1503*cdf0e10cSrcweir             DEFINE_CONST_UNICODE("com.sun.star.util.URLTransformer" )), UNO_QUERY_THROW );
1504*cdf0e10cSrcweir 
1505*cdf0e10cSrcweir     URL aURL;
1506*cdf0e10cSrcweir     aURL.Complete = sHelpURL;
1507*cdf0e10cSrcweir     sal_Bool bResult = xParser->parseStrict(aURL);
1508*cdf0e10cSrcweir 
1509*cdf0e10cSrcweir     sFactory = aURL.Server;
1510*cdf0e10cSrcweir     sContent = aURL.Path.copy(1); // strip "/"!
1511*cdf0e10cSrcweir     sAnchor  = aURL.Mark;
1512*cdf0e10cSrcweir 
1513*cdf0e10cSrcweir     return bResult;
1514*cdf0e10cSrcweir }
1515*cdf0e10cSrcweir 
1516*cdf0e10cSrcweir ::rtl::OUString SfxHelpWindow_Impl::buildHelpURL(const ::rtl::OUString& sFactory        ,
1517*cdf0e10cSrcweir                                                  const ::rtl::OUString& sContent        ,
1518*cdf0e10cSrcweir                                                  const ::rtl::OUString& sAnchor         ,
1519*cdf0e10cSrcweir                                                        sal_Bool         bUseQuestionMark)
1520*cdf0e10cSrcweir {
1521*cdf0e10cSrcweir     ::rtl::OUStringBuffer sHelpURL(256);
1522*cdf0e10cSrcweir     sHelpURL.append(HELP_URL);
1523*cdf0e10cSrcweir     sHelpURL.append(sFactory);
1524*cdf0e10cSrcweir     sHelpURL.append(sContent);
1525*cdf0e10cSrcweir     String sURL = String(sHelpURL.makeStringAndClear());
1526*cdf0e10cSrcweir     AppendConfigToken_Impl(sURL, bUseQuestionMark);
1527*cdf0e10cSrcweir     if (sAnchor.getLength())
1528*cdf0e10cSrcweir         sURL += String(sAnchor);
1529*cdf0e10cSrcweir     return ::rtl::OUString(sURL);
1530*cdf0e10cSrcweir }
1531*cdf0e10cSrcweir 
1532*cdf0e10cSrcweir void SfxHelpWindow_Impl::loadHelpContent(const ::rtl::OUString& sHelpURL, sal_Bool bAddToHistory)
1533*cdf0e10cSrcweir {
1534*cdf0e10cSrcweir     Reference< XComponentLoader > xLoader(getTextFrame(), UNO_QUERY);
1535*cdf0e10cSrcweir     if (!xLoader.is())
1536*cdf0e10cSrcweir         return;
1537*cdf0e10cSrcweir 
1538*cdf0e10cSrcweir     // --> PB 2007-03-12 #134037#
1539*cdf0e10cSrcweir     // If a print job runs do not open a new page
1540*cdf0e10cSrcweir     Reference< XFrame >      xTextFrame      = pTextWin->getFrame();
1541*cdf0e10cSrcweir     Reference< XController > xTextController ;
1542*cdf0e10cSrcweir     if (xTextFrame.is())
1543*cdf0e10cSrcweir         xTextController = xTextFrame->getController ();
1544*cdf0e10cSrcweir     if ( xTextController.is() && !xTextController->suspend( sal_True ) )
1545*cdf0e10cSrcweir     {
1546*cdf0e10cSrcweir         xTextController->suspend( sal_False );
1547*cdf0e10cSrcweir         return;
1548*cdf0e10cSrcweir     }
1549*cdf0e10cSrcweir     // <--
1550*cdf0e10cSrcweir 
1551*cdf0e10cSrcweir 	// save url to history
1552*cdf0e10cSrcweir     if (bAddToHistory)
1553*cdf0e10cSrcweir 	    pHelpInterceptor->addURL(sHelpURL);
1554*cdf0e10cSrcweir 
1555*cdf0e10cSrcweir     if ( !IsWait() )
1556*cdf0e10cSrcweir         EnterWait();
1557*cdf0e10cSrcweir     sal_Bool bSuccess = sal_False;
1558*cdf0e10cSrcweir // TODO implement locale fallback ... see below    while(sal_True)
1559*cdf0e10cSrcweir     {
1560*cdf0e10cSrcweir         try
1561*cdf0e10cSrcweir         {
1562*cdf0e10cSrcweir             Reference< XComponent > xContent = xLoader->loadComponentFromURL(sHelpURL, DEFINE_CONST_UNICODE("_self"), 0, Sequence< PropertyValue >());
1563*cdf0e10cSrcweir             if (xContent.is())
1564*cdf0e10cSrcweir             {
1565*cdf0e10cSrcweir                 bSuccess = sal_True;
1566*cdf0e10cSrcweir //                break;
1567*cdf0e10cSrcweir             }
1568*cdf0e10cSrcweir         }
1569*cdf0e10cSrcweir         catch(const RuntimeException&)
1570*cdf0e10cSrcweir             { throw; }
1571*cdf0e10cSrcweir         catch(const Exception&)
1572*cdf0e10cSrcweir             { /*break;*/ }
1573*cdf0e10cSrcweir 
1574*cdf0e10cSrcweir         /* TODO try next locale ...
1575*cdf0e10cSrcweir                 no further locale available? => break loop and show error page
1576*cdf0e10cSrcweir         */
1577*cdf0e10cSrcweir     }
1578*cdf0e10cSrcweir     openDone(sHelpURL, bSuccess);
1579*cdf0e10cSrcweir     if ( IsWait() )
1580*cdf0e10cSrcweir         LeaveWait();
1581*cdf0e10cSrcweir }
1582*cdf0e10cSrcweir 
1583*cdf0e10cSrcweir SfxHelpIndexWindow_Impl::SfxHelpIndexWindow_Impl( SfxHelpWindow_Impl* _pParent ) :
1584*cdf0e10cSrcweir 
1585*cdf0e10cSrcweir 	Window( _pParent, SfxResId( WIN_HELPINDEX ) ),
1586*cdf0e10cSrcweir 
1587*cdf0e10cSrcweir 	aActiveLB			( this, SfxResId( LB_ACTIVE ) ),
1588*cdf0e10cSrcweir 	aActiveLine			( this, SfxResId( FL_ACTIVE ) ),
1589*cdf0e10cSrcweir 	aTabCtrl			( this, SfxResId( TC_INDEX ) ),
1590*cdf0e10cSrcweir 
1591*cdf0e10cSrcweir 	aIndexKeywordLink	( LINK( this, SfxHelpIndexWindow_Impl, KeywordHdl ) ),
1592*cdf0e10cSrcweir 	pParentWin			( _pParent ),
1593*cdf0e10cSrcweir 
1594*cdf0e10cSrcweir 	pCPage				( NULL ),
1595*cdf0e10cSrcweir 	pIPage				( NULL ),
1596*cdf0e10cSrcweir 	pSPage				( NULL ),
1597*cdf0e10cSrcweir     pBPage              ( NULL ),
1598*cdf0e10cSrcweir 
1599*cdf0e10cSrcweir     bWasCursorLeftOrRight( false ),
1600*cdf0e10cSrcweir     bIsInitDone          ( false )
1601*cdf0e10cSrcweir 
1602*cdf0e10cSrcweir {
1603*cdf0e10cSrcweir 	FreeResource();
1604*cdf0e10cSrcweir 
1605*cdf0e10cSrcweir 	sfx2::AddToTaskPaneList( this );
1606*cdf0e10cSrcweir 
1607*cdf0e10cSrcweir 	aTabCtrl.SetActivatePageHdl( LINK( this, SfxHelpIndexWindow_Impl, ActivatePageHdl ) );
1608*cdf0e10cSrcweir 	aTabCtrl.Show();
1609*cdf0e10cSrcweir 
1610*cdf0e10cSrcweir 	sal_Int32 nPageId = HELP_INDEX_PAGE_INDEX;
1611*cdf0e10cSrcweir 	SvtViewOptions aViewOpt( E_TABDIALOG, CONFIGNAME_INDEXWIN );
1612*cdf0e10cSrcweir 	if ( aViewOpt.Exists() )
1613*cdf0e10cSrcweir 		nPageId = aViewOpt.GetPageID();
1614*cdf0e10cSrcweir 	aTabCtrl.SetCurPageId( (sal_uInt16)nPageId );
1615*cdf0e10cSrcweir 	ActivatePageHdl( &aTabCtrl );
1616*cdf0e10cSrcweir 	aActiveLB.SetSelectHdl( LINK( this, SfxHelpIndexWindow_Impl, SelectHdl ) );
1617*cdf0e10cSrcweir 	nMinWidth = ( aActiveLB.GetSizePixel().Width() / 2 );
1618*cdf0e10cSrcweir 
1619*cdf0e10cSrcweir 	aTimer.SetTimeoutHdl( LINK( this, SfxHelpIndexWindow_Impl, InitHdl ) );
1620*cdf0e10cSrcweir 	aTimer.SetTimeout( 200 );
1621*cdf0e10cSrcweir 	aTimer.Start();
1622*cdf0e10cSrcweir }
1623*cdf0e10cSrcweir 
1624*cdf0e10cSrcweir // -----------------------------------------------------------------------
1625*cdf0e10cSrcweir 
1626*cdf0e10cSrcweir SfxHelpIndexWindow_Impl::~SfxHelpIndexWindow_Impl()
1627*cdf0e10cSrcweir {
1628*cdf0e10cSrcweir 	sfx2::RemoveFromTaskPaneList( this );
1629*cdf0e10cSrcweir 
1630*cdf0e10cSrcweir 	DELETEZ( pCPage );
1631*cdf0e10cSrcweir 	DELETEZ( pIPage );
1632*cdf0e10cSrcweir 	DELETEZ( pSPage );
1633*cdf0e10cSrcweir 	DELETEZ( pBPage );
1634*cdf0e10cSrcweir 
1635*cdf0e10cSrcweir 	for ( sal_uInt16 i = 0; i < aActiveLB.GetEntryCount(); ++i )
1636*cdf0e10cSrcweir 		delete (String*)(sal_uIntPtr)aActiveLB.GetEntryData(i);
1637*cdf0e10cSrcweir 
1638*cdf0e10cSrcweir 	SvtViewOptions aViewOpt( E_TABDIALOG, CONFIGNAME_INDEXWIN );
1639*cdf0e10cSrcweir 	aViewOpt.SetPageID( (sal_Int32)aTabCtrl.GetCurPageId() );
1640*cdf0e10cSrcweir }
1641*cdf0e10cSrcweir 
1642*cdf0e10cSrcweir // -----------------------------------------------------------------------
1643*cdf0e10cSrcweir 
1644*cdf0e10cSrcweir void SfxHelpIndexWindow_Impl::Initialize()
1645*cdf0e10cSrcweir {
1646*cdf0e10cSrcweir 	String aHelpURL = HELP_URL;
1647*cdf0e10cSrcweir 	AppendConfigToken_Impl( aHelpURL, sal_True );
1648*cdf0e10cSrcweir 	Sequence< ::rtl::OUString > aFactories = SfxContentHelper::GetResultSet( aHelpURL );
1649*cdf0e10cSrcweir 	const ::rtl::OUString* pFacs  = aFactories.getConstArray();
1650*cdf0e10cSrcweir 	sal_uInt32 i, nCount = aFactories.getLength();
1651*cdf0e10cSrcweir 	for ( i = 0; i < nCount; ++i )
1652*cdf0e10cSrcweir 	{
1653*cdf0e10cSrcweir 		String aRow( pFacs[i] );
1654*cdf0e10cSrcweir 		String aTitle, aType, aURL;
1655*cdf0e10cSrcweir 		xub_StrLen nIdx = 0;
1656*cdf0e10cSrcweir 		aTitle = aRow.GetToken( 0, '\t', nIdx );
1657*cdf0e10cSrcweir 		aType = aRow.GetToken( 0, '\t', nIdx );
1658*cdf0e10cSrcweir 		aURL = aRow.GetToken( 0, '\t', nIdx );
1659*cdf0e10cSrcweir 		String* pFactory = new String( INetURLObject( aURL ).GetHost() );
1660*cdf0e10cSrcweir 		sal_uInt16 nPos = aActiveLB.InsertEntry( aTitle );
1661*cdf0e10cSrcweir 		aActiveLB.SetEntryData( nPos, (void*)(sal_uIntPtr)pFactory );
1662*cdf0e10cSrcweir 	}
1663*cdf0e10cSrcweir 
1664*cdf0e10cSrcweir 	aActiveLB.SetDropDownLineCount( (sal_uInt16)nCount );
1665*cdf0e10cSrcweir 	if ( aActiveLB.GetSelectEntryPos() == LISTBOX_ENTRY_NOTFOUND )
1666*cdf0e10cSrcweir 		SetActiveFactory();
1667*cdf0e10cSrcweir }
1668*cdf0e10cSrcweir 
1669*cdf0e10cSrcweir // -----------------------------------------------------------------------
1670*cdf0e10cSrcweir 
1671*cdf0e10cSrcweir void SfxHelpIndexWindow_Impl::SetActiveFactory()
1672*cdf0e10cSrcweir {
1673*cdf0e10cSrcweir 	DBG_ASSERT( pIPage, "index page not initialized" );
1674*cdf0e10cSrcweir     if ( !bIsInitDone && !aActiveLB.GetEntryCount() )
1675*cdf0e10cSrcweir     {
1676*cdf0e10cSrcweir         aTimer.Stop();
1677*cdf0e10cSrcweir         InitHdl( NULL );
1678*cdf0e10cSrcweir     }
1679*cdf0e10cSrcweir 
1680*cdf0e10cSrcweir 	for ( sal_uInt16 i = 0; i < aActiveLB.GetEntryCount(); ++i )
1681*cdf0e10cSrcweir 	{
1682*cdf0e10cSrcweir 		String* pFactory = (String*)(sal_uIntPtr)aActiveLB.GetEntryData(i);
1683*cdf0e10cSrcweir 		pFactory->ToLowerAscii();
1684*cdf0e10cSrcweir 		if ( *pFactory == pIPage->GetFactory() )
1685*cdf0e10cSrcweir 		{
1686*cdf0e10cSrcweir 			if ( aActiveLB.GetSelectEntryPos() != i )
1687*cdf0e10cSrcweir 			{
1688*cdf0e10cSrcweir 				aActiveLB.SelectEntryPos(i);
1689*cdf0e10cSrcweir 				aSelectFactoryLink.Call( NULL );
1690*cdf0e10cSrcweir 			}
1691*cdf0e10cSrcweir 			break;
1692*cdf0e10cSrcweir 		}
1693*cdf0e10cSrcweir 	}
1694*cdf0e10cSrcweir }
1695*cdf0e10cSrcweir 
1696*cdf0e10cSrcweir // -----------------------------------------------------------------------
1697*cdf0e10cSrcweir 
1698*cdf0e10cSrcweir HelpTabPage_Impl* SfxHelpIndexWindow_Impl::GetCurrentPage( sal_uInt16& rCurId )
1699*cdf0e10cSrcweir {
1700*cdf0e10cSrcweir 	rCurId = aTabCtrl.GetCurPageId();
1701*cdf0e10cSrcweir 	HelpTabPage_Impl* pPage = NULL;
1702*cdf0e10cSrcweir 
1703*cdf0e10cSrcweir 	switch ( rCurId )
1704*cdf0e10cSrcweir 	{
1705*cdf0e10cSrcweir 		case HELP_INDEX_PAGE_CONTENTS:
1706*cdf0e10cSrcweir 		{
1707*cdf0e10cSrcweir 			pPage = GetContentPage();
1708*cdf0e10cSrcweir 			break;
1709*cdf0e10cSrcweir 		}
1710*cdf0e10cSrcweir 
1711*cdf0e10cSrcweir 		case HELP_INDEX_PAGE_INDEX:
1712*cdf0e10cSrcweir 		{
1713*cdf0e10cSrcweir 			pPage = GetIndexPage();
1714*cdf0e10cSrcweir 			break;
1715*cdf0e10cSrcweir 		}
1716*cdf0e10cSrcweir 
1717*cdf0e10cSrcweir 		case HELP_INDEX_PAGE_SEARCH:
1718*cdf0e10cSrcweir 		{
1719*cdf0e10cSrcweir 			pPage = GetSearchPage();
1720*cdf0e10cSrcweir 			break;
1721*cdf0e10cSrcweir 		}
1722*cdf0e10cSrcweir 
1723*cdf0e10cSrcweir 		case HELP_INDEX_PAGE_BOOKMARKS:
1724*cdf0e10cSrcweir 		{
1725*cdf0e10cSrcweir 			pPage = GetBookmarksPage();
1726*cdf0e10cSrcweir 			break;
1727*cdf0e10cSrcweir 		}
1728*cdf0e10cSrcweir 	}
1729*cdf0e10cSrcweir 
1730*cdf0e10cSrcweir 	DBG_ASSERT( pPage, "SfxHelpIndexWindow_Impl::GetCurrentPage(): no current page" );
1731*cdf0e10cSrcweir 	return pPage;
1732*cdf0e10cSrcweir }
1733*cdf0e10cSrcweir 
1734*cdf0e10cSrcweir // -----------------------------------------------------------------------
1735*cdf0e10cSrcweir 
1736*cdf0e10cSrcweir IMPL_LINK( SfxHelpIndexWindow_Impl, ActivatePageHdl, TabControl *, pTabCtrl )
1737*cdf0e10cSrcweir {
1738*cdf0e10cSrcweir 	sal_uInt16 nId = 0;
1739*cdf0e10cSrcweir 	TabPage* pPage = GetCurrentPage( nId );
1740*cdf0e10cSrcweir 	pTabCtrl->SetTabPage( nId, pPage );
1741*cdf0e10cSrcweir 	return 0;
1742*cdf0e10cSrcweir }
1743*cdf0e10cSrcweir 
1744*cdf0e10cSrcweir // -----------------------------------------------------------------------
1745*cdf0e10cSrcweir 
1746*cdf0e10cSrcweir IMPL_LINK( SfxHelpIndexWindow_Impl, SelectHdl, ListBox *, EMPTYARG )
1747*cdf0e10cSrcweir {
1748*cdf0e10cSrcweir 	aTimer.Start();
1749*cdf0e10cSrcweir 
1750*cdf0e10cSrcweir 	return 0;
1751*cdf0e10cSrcweir }
1752*cdf0e10cSrcweir 
1753*cdf0e10cSrcweir // -----------------------------------------------------------------------
1754*cdf0e10cSrcweir 
1755*cdf0e10cSrcweir IMPL_LINK( SfxHelpIndexWindow_Impl, InitHdl, Timer *, EMPTYARG )
1756*cdf0e10cSrcweir {
1757*cdf0e10cSrcweir     bIsInitDone = true;
1758*cdf0e10cSrcweir 	Initialize();
1759*cdf0e10cSrcweir 
1760*cdf0e10cSrcweir 	// now use the timer for selection
1761*cdf0e10cSrcweir 	aTimer.SetTimeoutHdl( LINK( this, SfxHelpIndexWindow_Impl, SelectFactoryHdl ) );
1762*cdf0e10cSrcweir 	aTimer.SetTimeout( 1000 );
1763*cdf0e10cSrcweir 
1764*cdf0e10cSrcweir 	return 0;
1765*cdf0e10cSrcweir }
1766*cdf0e10cSrcweir 
1767*cdf0e10cSrcweir // -----------------------------------------------------------------------
1768*cdf0e10cSrcweir 
1769*cdf0e10cSrcweir IMPL_LINK( SfxHelpIndexWindow_Impl, SelectFactoryHdl, Timer *, EMPTYARG )
1770*cdf0e10cSrcweir {
1771*cdf0e10cSrcweir 	String* pFactory = (String*)(sal_uIntPtr)aActiveLB.GetEntryData( aActiveLB.GetSelectEntryPos() );
1772*cdf0e10cSrcweir 	if ( pFactory )
1773*cdf0e10cSrcweir 	{
1774*cdf0e10cSrcweir 		String aFactory( *pFactory );
1775*cdf0e10cSrcweir 		aFactory.ToLowerAscii();
1776*cdf0e10cSrcweir 		SetFactory( aFactory, sal_False );
1777*cdf0e10cSrcweir 		aSelectFactoryLink.Call( this );
1778*cdf0e10cSrcweir 	}
1779*cdf0e10cSrcweir 
1780*cdf0e10cSrcweir 	return 0;
1781*cdf0e10cSrcweir }
1782*cdf0e10cSrcweir 
1783*cdf0e10cSrcweir // -----------------------------------------------------------------------
1784*cdf0e10cSrcweir 
1785*cdf0e10cSrcweir IMPL_LINK( SfxHelpIndexWindow_Impl, KeywordHdl, IndexTabPage_Impl *, EMPTYARG )
1786*cdf0e10cSrcweir {
1787*cdf0e10cSrcweir 	// keyword found on index?
1788*cdf0e10cSrcweir 	sal_Bool bIndex = pIPage->HasKeyword();
1789*cdf0e10cSrcweir 	//The following two lines are added by BerryJia for fixing Bug98251, 2002-12-11
1790*cdf0e10cSrcweir 	if( !bIndex)
1791*cdf0e10cSrcweir 		bIndex = pIPage->HasKeywordIgnoreCase();
1792*cdf0e10cSrcweir 	// then set index or search page as current.
1793*cdf0e10cSrcweir 	sal_uInt16 nPageId = ( bIndex ) ? HELP_INDEX_PAGE_INDEX :  HELP_INDEX_PAGE_SEARCH;
1794*cdf0e10cSrcweir 	if ( nPageId != aTabCtrl.GetCurPageId() )
1795*cdf0e10cSrcweir 	{
1796*cdf0e10cSrcweir 		aTabCtrl.SetCurPageId( nPageId );
1797*cdf0e10cSrcweir 		ActivatePageHdl( &aTabCtrl );
1798*cdf0e10cSrcweir 	}
1799*cdf0e10cSrcweir 
1800*cdf0e10cSrcweir 	// at last we open the keyword
1801*cdf0e10cSrcweir 	if ( bIndex )
1802*cdf0e10cSrcweir 		pIPage->OpenKeyword();
1803*cdf0e10cSrcweir 	else if ( !pSPage->OpenKeyword( sKeyword ) )
1804*cdf0e10cSrcweir 		pParentWin->ShowStartPage();
1805*cdf0e10cSrcweir 
1806*cdf0e10cSrcweir 	return 0;
1807*cdf0e10cSrcweir }
1808*cdf0e10cSrcweir 
1809*cdf0e10cSrcweir // -----------------------------------------------------------------------
1810*cdf0e10cSrcweir 
1811*cdf0e10cSrcweir void SfxHelpIndexWindow_Impl::Resize()
1812*cdf0e10cSrcweir {
1813*cdf0e10cSrcweir 	Size aSize = GetOutputSizePixel();
1814*cdf0e10cSrcweir 	if ( aSize.Width() < nMinWidth )
1815*cdf0e10cSrcweir 		aSize.Width() = nMinWidth;
1816*cdf0e10cSrcweir 
1817*cdf0e10cSrcweir 	Point aPnt = aActiveLB.GetPosPixel();
1818*cdf0e10cSrcweir 	Size aNewSize = aActiveLB.GetSizePixel();
1819*cdf0e10cSrcweir 	aNewSize.Width() = aSize.Width() - ( aPnt.X() * 2 );
1820*cdf0e10cSrcweir 	aActiveLB.SetSizePixel( aNewSize );
1821*cdf0e10cSrcweir 	aPnt = aActiveLine.GetPosPixel();
1822*cdf0e10cSrcweir 	aNewSize = aActiveLine.GetSizePixel();
1823*cdf0e10cSrcweir 	aNewSize.Width() = aSize.Width() - ( aPnt.X() * 2 );
1824*cdf0e10cSrcweir 	aActiveLine.SetSizePixel( aNewSize );
1825*cdf0e10cSrcweir 	aPnt = aTabCtrl.GetPosPixel();
1826*cdf0e10cSrcweir 	aNewSize = aSize;
1827*cdf0e10cSrcweir 	aSize.Width() -= aPnt.X();
1828*cdf0e10cSrcweir 	aSize.Height() -= aPnt.Y();
1829*cdf0e10cSrcweir 	aTabCtrl.SetSizePixel( aSize );
1830*cdf0e10cSrcweir }
1831*cdf0e10cSrcweir 
1832*cdf0e10cSrcweir // -----------------------------------------------------------------------
1833*cdf0e10cSrcweir 
1834*cdf0e10cSrcweir long SfxHelpIndexWindow_Impl::PreNotify( NotifyEvent& rNEvt )
1835*cdf0e10cSrcweir {
1836*cdf0e10cSrcweir 	long nDone = 0;
1837*cdf0e10cSrcweir 	sal_uInt16 nType = rNEvt.GetType();
1838*cdf0e10cSrcweir 	if ( EVENT_KEYINPUT == nType && rNEvt.GetKeyEvent() )
1839*cdf0e10cSrcweir 	{
1840*cdf0e10cSrcweir 	 	const KeyCode& rKeyCode = rNEvt.GetKeyEvent()->GetKeyCode();
1841*cdf0e10cSrcweir 		sal_uInt16 nCode = rKeyCode.GetCode();
1842*cdf0e10cSrcweir 
1843*cdf0e10cSrcweir 		if (  KEY_TAB == nCode )
1844*cdf0e10cSrcweir 		{
1845*cdf0e10cSrcweir 			// don't exit index pane with <TAB>
1846*cdf0e10cSrcweir 			sal_uInt16 nPageId = 0;
1847*cdf0e10cSrcweir 			HelpTabPage_Impl* pCurPage = GetCurrentPage( nPageId );
1848*cdf0e10cSrcweir 			Control* pControl = pCurPage->GetLastFocusControl();
1849*cdf0e10cSrcweir 			sal_Bool bShift = rKeyCode.IsShift();
1850*cdf0e10cSrcweir 			sal_Bool bCtrl = rKeyCode.IsMod1();
1851*cdf0e10cSrcweir 			if ( !bCtrl && bShift && aActiveLB.HasChildPathFocus() )
1852*cdf0e10cSrcweir 			{
1853*cdf0e10cSrcweir 				pControl->GrabFocus();
1854*cdf0e10cSrcweir 				nDone = 1;
1855*cdf0e10cSrcweir 			}
1856*cdf0e10cSrcweir 			else if ( !bCtrl && !bShift && pControl->HasChildPathFocus() )
1857*cdf0e10cSrcweir 			{
1858*cdf0e10cSrcweir 				aActiveLB.GrabFocus();
1859*cdf0e10cSrcweir 				nDone = 1;
1860*cdf0e10cSrcweir 			}
1861*cdf0e10cSrcweir 			else if ( bCtrl )
1862*cdf0e10cSrcweir 			{
1863*cdf0e10cSrcweir 				// <STRG><TAB> moves through the pages
1864*cdf0e10cSrcweir 				if ( nPageId < HELP_INDEX_PAGE_LAST )
1865*cdf0e10cSrcweir 					nPageId++;
1866*cdf0e10cSrcweir 				else
1867*cdf0e10cSrcweir 					nPageId = HELP_INDEX_PAGE_FIRST;
1868*cdf0e10cSrcweir 				aTabCtrl.SetCurPageId( (sal_uInt16)nPageId );
1869*cdf0e10cSrcweir 				ActivatePageHdl( &aTabCtrl );
1870*cdf0e10cSrcweir 				nDone = 1;
1871*cdf0e10cSrcweir 			}
1872*cdf0e10cSrcweir  		}
1873*cdf0e10cSrcweir 		else if ( aTabCtrl.HasFocus() && ( KEY_LEFT == nCode || KEY_RIGHT == nCode ) )
1874*cdf0e10cSrcweir 		{
1875*cdf0e10cSrcweir 			bWasCursorLeftOrRight = true;
1876*cdf0e10cSrcweir 		}
1877*cdf0e10cSrcweir 	}
1878*cdf0e10cSrcweir 
1879*cdf0e10cSrcweir 	return nDone ? nDone : Window::PreNotify( rNEvt );
1880*cdf0e10cSrcweir }
1881*cdf0e10cSrcweir 
1882*cdf0e10cSrcweir // -----------------------------------------------------------------------
1883*cdf0e10cSrcweir 
1884*cdf0e10cSrcweir void SfxHelpIndexWindow_Impl::DataChanged( const DataChangedEvent& rDCEvt )
1885*cdf0e10cSrcweir {
1886*cdf0e10cSrcweir 	Window::DataChanged( rDCEvt );
1887*cdf0e10cSrcweir 
1888*cdf0e10cSrcweir 	if ( ( ( rDCEvt.GetType() == DATACHANGED_SETTINGS )	||
1889*cdf0e10cSrcweir 		   ( rDCEvt.GetType() == DATACHANGED_DISPLAY ) ) &&
1890*cdf0e10cSrcweir 		 ( rDCEvt.GetFlags() & SETTINGS_STYLE ) )
1891*cdf0e10cSrcweir 	{
1892*cdf0e10cSrcweir 		SetBackground( Wallpaper( GetSettings().GetStyleSettings().GetFaceColor() ) );
1893*cdf0e10cSrcweir 	}
1894*cdf0e10cSrcweir }
1895*cdf0e10cSrcweir 
1896*cdf0e10cSrcweir // -----------------------------------------------------------------------
1897*cdf0e10cSrcweir 
1898*cdf0e10cSrcweir void SfxHelpIndexWindow_Impl::SetDoubleClickHdl( const Link& rLink )
1899*cdf0e10cSrcweir {
1900*cdf0e10cSrcweir 	aPageDoubleClickLink = rLink;
1901*cdf0e10cSrcweir 	if ( pCPage )
1902*cdf0e10cSrcweir 		pCPage->SetOpenHdl( aPageDoubleClickLink );
1903*cdf0e10cSrcweir 	if ( pIPage )
1904*cdf0e10cSrcweir 		pIPage->SetDoubleClickHdl( aPageDoubleClickLink );
1905*cdf0e10cSrcweir 	if ( pSPage )
1906*cdf0e10cSrcweir 		pSPage->SetDoubleClickHdl( aPageDoubleClickLink );
1907*cdf0e10cSrcweir 	if ( pBPage )
1908*cdf0e10cSrcweir 		pBPage->SetDoubleClickHdl( aPageDoubleClickLink );
1909*cdf0e10cSrcweir }
1910*cdf0e10cSrcweir 
1911*cdf0e10cSrcweir // -----------------------------------------------------------------------
1912*cdf0e10cSrcweir 
1913*cdf0e10cSrcweir void SfxHelpIndexWindow_Impl::SetFactory( const String& rFactory, sal_Bool bActive )
1914*cdf0e10cSrcweir {
1915*cdf0e10cSrcweir 	if ( rFactory.Len() > 0 )
1916*cdf0e10cSrcweir 	{
1917*cdf0e10cSrcweir 		GetIndexPage()->SetFactory( rFactory );
1918*cdf0e10cSrcweir         // the index page did a check if rFactory is valid,
1919*cdf0e10cSrcweir         // so the index page always returns a valid factory
1920*cdf0e10cSrcweir         GetSearchPage()->SetFactory( GetIndexPage()->GetFactory() );
1921*cdf0e10cSrcweir 		if ( bActive )
1922*cdf0e10cSrcweir 			SetActiveFactory();
1923*cdf0e10cSrcweir 	}
1924*cdf0e10cSrcweir }
1925*cdf0e10cSrcweir 
1926*cdf0e10cSrcweir // -----------------------------------------------------------------------
1927*cdf0e10cSrcweir 
1928*cdf0e10cSrcweir String SfxHelpIndexWindow_Impl::GetSelectEntry() const
1929*cdf0e10cSrcweir {
1930*cdf0e10cSrcweir 	String sRet;
1931*cdf0e10cSrcweir 
1932*cdf0e10cSrcweir 	switch ( aTabCtrl.GetCurPageId() )
1933*cdf0e10cSrcweir 	{
1934*cdf0e10cSrcweir 		case HELP_INDEX_PAGE_CONTENTS:
1935*cdf0e10cSrcweir 			sRet = pCPage->GetSelectEntry();
1936*cdf0e10cSrcweir 			break;
1937*cdf0e10cSrcweir 
1938*cdf0e10cSrcweir 		case HELP_INDEX_PAGE_INDEX:
1939*cdf0e10cSrcweir 			sRet = pIPage->GetSelectEntry();
1940*cdf0e10cSrcweir 			break;
1941*cdf0e10cSrcweir 
1942*cdf0e10cSrcweir 		case HELP_INDEX_PAGE_SEARCH:
1943*cdf0e10cSrcweir 			sRet = pSPage->GetSelectEntry();
1944*cdf0e10cSrcweir 			break;
1945*cdf0e10cSrcweir 
1946*cdf0e10cSrcweir 		case HELP_INDEX_PAGE_BOOKMARKS:
1947*cdf0e10cSrcweir 			sRet = pBPage->GetSelectEntry();
1948*cdf0e10cSrcweir 			break;
1949*cdf0e10cSrcweir 	}
1950*cdf0e10cSrcweir 
1951*cdf0e10cSrcweir 	return sRet;
1952*cdf0e10cSrcweir }
1953*cdf0e10cSrcweir 
1954*cdf0e10cSrcweir // -----------------------------------------------------------------------
1955*cdf0e10cSrcweir 
1956*cdf0e10cSrcweir void SfxHelpIndexWindow_Impl::AddBookmarks( const String& rTitle, const String& rURL )
1957*cdf0e10cSrcweir {
1958*cdf0e10cSrcweir 	GetBookmarksPage()->AddBookmarks( rTitle, rURL );
1959*cdf0e10cSrcweir }
1960*cdf0e10cSrcweir 
1961*cdf0e10cSrcweir // -----------------------------------------------------------------------
1962*cdf0e10cSrcweir 
1963*cdf0e10cSrcweir bool SfxHelpIndexWindow_Impl::IsValidFactory( const String& _rFactory )
1964*cdf0e10cSrcweir {
1965*cdf0e10cSrcweir     bool bValid = false;
1966*cdf0e10cSrcweir     for ( sal_uInt16 i = 0; i < aActiveLB.GetEntryCount(); ++i )
1967*cdf0e10cSrcweir     {
1968*cdf0e10cSrcweir         String* pFactory = (String*)(sal_uIntPtr)aActiveLB.GetEntryData(i);
1969*cdf0e10cSrcweir         if ( *pFactory == _rFactory )
1970*cdf0e10cSrcweir         {
1971*cdf0e10cSrcweir             bValid = true;
1972*cdf0e10cSrcweir             break;
1973*cdf0e10cSrcweir         }
1974*cdf0e10cSrcweir     }
1975*cdf0e10cSrcweir     return bValid;
1976*cdf0e10cSrcweir }
1977*cdf0e10cSrcweir 
1978*cdf0e10cSrcweir // -----------------------------------------------------------------------
1979*cdf0e10cSrcweir 
1980*cdf0e10cSrcweir void SfxHelpIndexWindow_Impl::ClearSearchPage()
1981*cdf0e10cSrcweir {
1982*cdf0e10cSrcweir 	if ( pSPage )
1983*cdf0e10cSrcweir 		pSPage->ClearPage();
1984*cdf0e10cSrcweir }
1985*cdf0e10cSrcweir 
1986*cdf0e10cSrcweir // -----------------------------------------------------------------------
1987*cdf0e10cSrcweir 
1988*cdf0e10cSrcweir void SfxHelpIndexWindow_Impl::GrabFocusBack()
1989*cdf0e10cSrcweir {
1990*cdf0e10cSrcweir 	if ( aTabCtrl.GetCurPageId() == HELP_INDEX_PAGE_CONTENTS && pCPage )
1991*cdf0e10cSrcweir 		pCPage->SetFocusOnBox();
1992*cdf0e10cSrcweir 	else if ( aTabCtrl.GetCurPageId() == HELP_INDEX_PAGE_INDEX && pIPage )
1993*cdf0e10cSrcweir 		pIPage->SetFocusOnBox();
1994*cdf0e10cSrcweir 	else if ( aTabCtrl.GetCurPageId() == HELP_INDEX_PAGE_SEARCH && pSPage )
1995*cdf0e10cSrcweir 		pSPage->SetFocusOnBox();
1996*cdf0e10cSrcweir 	else if ( aTabCtrl.GetCurPageId() == HELP_INDEX_PAGE_BOOKMARKS && pBPage )
1997*cdf0e10cSrcweir 		pBPage->SetFocusOnBox();
1998*cdf0e10cSrcweir }
1999*cdf0e10cSrcweir 
2000*cdf0e10cSrcweir // -----------------------------------------------------------------------
2001*cdf0e10cSrcweir 
2002*cdf0e10cSrcweir sal_Bool SfxHelpIndexWindow_Impl::HasFocusOnEdit() const
2003*cdf0e10cSrcweir {
2004*cdf0e10cSrcweir 	sal_Bool bRet = sal_False;
2005*cdf0e10cSrcweir 	if ( aTabCtrl.GetCurPageId() == HELP_INDEX_PAGE_INDEX && pIPage )
2006*cdf0e10cSrcweir 		bRet = pIPage->HasFocusOnEdit();
2007*cdf0e10cSrcweir 	else if ( aTabCtrl.GetCurPageId() == HELP_INDEX_PAGE_SEARCH && pSPage )
2008*cdf0e10cSrcweir 		bRet = pSPage->HasFocusOnEdit();
2009*cdf0e10cSrcweir 	return bRet;
2010*cdf0e10cSrcweir }
2011*cdf0e10cSrcweir 
2012*cdf0e10cSrcweir // -----------------------------------------------------------------------
2013*cdf0e10cSrcweir 
2014*cdf0e10cSrcweir String SfxHelpIndexWindow_Impl::GetSearchText() const
2015*cdf0e10cSrcweir {
2016*cdf0e10cSrcweir 	String sRet;
2017*cdf0e10cSrcweir 	if ( aTabCtrl.GetCurPageId() == HELP_INDEX_PAGE_SEARCH && pSPage )
2018*cdf0e10cSrcweir 		sRet = pSPage->GetSearchText();
2019*cdf0e10cSrcweir 	return sRet;
2020*cdf0e10cSrcweir }
2021*cdf0e10cSrcweir 
2022*cdf0e10cSrcweir // -----------------------------------------------------------------------
2023*cdf0e10cSrcweir 
2024*cdf0e10cSrcweir sal_Bool SfxHelpIndexWindow_Impl::IsFullWordSearch() const
2025*cdf0e10cSrcweir {
2026*cdf0e10cSrcweir 	sal_Bool bRet = sal_False;
2027*cdf0e10cSrcweir 	if ( aTabCtrl.GetCurPageId() == HELP_INDEX_PAGE_SEARCH && pSPage )
2028*cdf0e10cSrcweir 		bRet = pSPage->IsFullWordSearch();
2029*cdf0e10cSrcweir 	return bRet;
2030*cdf0e10cSrcweir }
2031*cdf0e10cSrcweir 
2032*cdf0e10cSrcweir // -----------------------------------------------------------------------
2033*cdf0e10cSrcweir 
2034*cdf0e10cSrcweir void SfxHelpIndexWindow_Impl::OpenKeyword( const String& rKeyword )
2035*cdf0e10cSrcweir {
2036*cdf0e10cSrcweir 	sKeyword = rKeyword;
2037*cdf0e10cSrcweir 	DBG_ASSERT( pIPage, "invalid index page" );
2038*cdf0e10cSrcweir 	pIPage->SetKeyword( sKeyword );
2039*cdf0e10cSrcweir }
2040*cdf0e10cSrcweir 
2041*cdf0e10cSrcweir // -----------------------------------------------------------------------
2042*cdf0e10cSrcweir 
2043*cdf0e10cSrcweir void SfxHelpIndexWindow_Impl::SelectExecutableEntry()
2044*cdf0e10cSrcweir {
2045*cdf0e10cSrcweir 	if ( aTabCtrl.GetCurPageId() == HELP_INDEX_PAGE_INDEX && pIPage )
2046*cdf0e10cSrcweir 		pIPage->SelectExecutableEntry();
2047*cdf0e10cSrcweir }
2048*cdf0e10cSrcweir 
2049*cdf0e10cSrcweir // class TextWin_Impl ----------------------------------------------------
2050*cdf0e10cSrcweir 
2051*cdf0e10cSrcweir TextWin_Impl::TextWin_Impl( Window* p ) : DockingWindow( p, 0 )
2052*cdf0e10cSrcweir {
2053*cdf0e10cSrcweir }
2054*cdf0e10cSrcweir 
2055*cdf0e10cSrcweir TextWin_Impl::~TextWin_Impl()
2056*cdf0e10cSrcweir {
2057*cdf0e10cSrcweir }
2058*cdf0e10cSrcweir 
2059*cdf0e10cSrcweir long TextWin_Impl::Notify( NotifyEvent& rNEvt )
2060*cdf0e10cSrcweir {
2061*cdf0e10cSrcweir 	if( ( rNEvt.GetType() == EVENT_KEYINPUT ) && rNEvt.GetKeyEvent()->GetKeyCode().GetCode() == KEY_TAB )
2062*cdf0e10cSrcweir 		return GetParent()->Notify( rNEvt );
2063*cdf0e10cSrcweir 	else
2064*cdf0e10cSrcweir 		return DockingWindow::Notify( rNEvt );
2065*cdf0e10cSrcweir }
2066*cdf0e10cSrcweir 
2067*cdf0e10cSrcweir // -----------------------------------------------------------------------
2068*cdf0e10cSrcweir // remove docking area acceptor from layoutmanager, so it will not layout anything further .-)
2069*cdf0e10cSrcweir void lcl_disableLayoutOfFrame(const Reference< XFrame >& xFrame)
2070*cdf0e10cSrcweir {
2071*cdf0e10cSrcweir     static const ::rtl::OUString PROP_LAYOUT_MANAGER(DEFINE_CONST_UNICODE("LayoutManager"));
2072*cdf0e10cSrcweir 
2073*cdf0e10cSrcweir     Reference< XPropertySet > xPropSet(xFrame, UNO_QUERY_THROW);
2074*cdf0e10cSrcweir     xPropSet->setPropertyValue(PROP_LAYOUT_MANAGER, makeAny(Reference< XLayoutManager >()));
2075*cdf0e10cSrcweir }
2076*cdf0e10cSrcweir 
2077*cdf0e10cSrcweir // class SfxHelpTextWindow_Impl ------------------------------------------
2078*cdf0e10cSrcweir 
2079*cdf0e10cSrcweir SfxHelpTextWindow_Impl::SfxHelpTextWindow_Impl( SfxHelpWindow_Impl* pParent ) :
2080*cdf0e10cSrcweir 
2081*cdf0e10cSrcweir 	Window( pParent, WB_CLIPCHILDREN | WB_TABSTOP | WB_DIALOGCONTROL ),
2082*cdf0e10cSrcweir 
2083*cdf0e10cSrcweir 	aToolBox			( this, 0 ),
2084*cdf0e10cSrcweir     aOnStartupCB        ( this, SfxResId( RID_HELP_ONSTARTUP_BOX ) ),
2085*cdf0e10cSrcweir 	aIndexOnImage		( SfxResId( IMG_HELP_TOOLBOX_INDEX_ON ) ),
2086*cdf0e10cSrcweir     aIndexOffImage  	( SfxResId( IMG_HELP_TOOLBOX_INDEX_OFF ) ),
2087*cdf0e10cSrcweir 	aIndexOnText		( SfxResId( STR_HELP_BUTTON_INDEX_ON ) ),
2088*cdf0e10cSrcweir 	aIndexOffText		( SfxResId( STR_HELP_BUTTON_INDEX_OFF ) ),
2089*cdf0e10cSrcweir     aOnStartupText      ( SfxResId( RID_HELP_ONSTARTUP_TEXT ) ),
2090*cdf0e10cSrcweir 	pHelpWin			( pParent ),
2091*cdf0e10cSrcweir 	pTextWin			( new TextWin_Impl( this ) ),
2092*cdf0e10cSrcweir     pSrchDlg            ( NULL ),
2093*cdf0e10cSrcweir 	nMinPos				( 0 ),
2094*cdf0e10cSrcweir 	bIsDebug			( sal_False ),
2095*cdf0e10cSrcweir 	bIsIndexOn			( sal_False ),
2096*cdf0e10cSrcweir 	bIsInClose			( sal_False ),
2097*cdf0e10cSrcweir     bIsFullWordSearch   ( sal_False )
2098*cdf0e10cSrcweir 
2099*cdf0e10cSrcweir {
2100*cdf0e10cSrcweir 	sfx2::AddToTaskPaneList( &aToolBox );
2101*cdf0e10cSrcweir 
2102*cdf0e10cSrcweir     xFrame = Reference < XFrame > ( ::comphelper::getProcessServiceFactory()->createInstance(
2103*cdf0e10cSrcweir 		DEFINE_CONST_UNICODE("com.sun.star.frame.Frame") ), UNO_QUERY );
2104*cdf0e10cSrcweir     xFrame->initialize( VCLUnoHelper::GetInterface ( pTextWin ) );
2105*cdf0e10cSrcweir     xFrame->setName( DEFINE_CONST_UNICODE("OFFICE_HELP") );
2106*cdf0e10cSrcweir     lcl_disableLayoutOfFrame(xFrame);
2107*cdf0e10cSrcweir 
2108*cdf0e10cSrcweir 	aToolBox.SetHelpId( HID_HELP_TOOLBOX );
2109*cdf0e10cSrcweir 
2110*cdf0e10cSrcweir 	aToolBox.InsertItem( TBI_INDEX, aIndexOffText );
2111*cdf0e10cSrcweir 	aToolBox.SetHelpId( TBI_INDEX, HID_HELP_TOOLBOXITEM_INDEX );
2112*cdf0e10cSrcweir 	aToolBox.InsertSeparator();
2113*cdf0e10cSrcweir 	aToolBox.InsertItem( TBI_BACKWARD, String( SfxResId( STR_HELP_BUTTON_PREV ) ) );
2114*cdf0e10cSrcweir 	aToolBox.SetHelpId( TBI_BACKWARD, HID_HELP_TOOLBOXITEM_BACKWARD );
2115*cdf0e10cSrcweir 	aToolBox.InsertItem( TBI_FORWARD, String( SfxResId( STR_HELP_BUTTON_NEXT ) ) );
2116*cdf0e10cSrcweir 	aToolBox.SetHelpId( TBI_FORWARD, HID_HELP_TOOLBOXITEM_FORWARD );
2117*cdf0e10cSrcweir 	aToolBox.InsertItem( TBI_START, String( SfxResId( STR_HELP_BUTTON_START ) ) );
2118*cdf0e10cSrcweir 	aToolBox.SetHelpId( TBI_START, HID_HELP_TOOLBOXITEM_START );
2119*cdf0e10cSrcweir 	aToolBox.InsertSeparator();
2120*cdf0e10cSrcweir 	aToolBox.InsertItem( TBI_PRINT, String( SfxResId( STR_HELP_BUTTON_PRINT ) ) );
2121*cdf0e10cSrcweir 	aToolBox.SetHelpId( TBI_PRINT, HID_HELP_TOOLBOXITEM_PRINT );
2122*cdf0e10cSrcweir 	aToolBox.InsertItem( TBI_BOOKMARKS, String( SfxResId( STR_HELP_BUTTON_ADDBOOKMARK ) ) );
2123*cdf0e10cSrcweir 	aToolBox.SetHelpId( TBI_BOOKMARKS, HID_HELP_TOOLBOXITEM_BOOKMARKS );
2124*cdf0e10cSrcweir 	aToolBox.InsertItem( TBI_SEARCHDIALOG, String( SfxResId( STR_HELP_BUTTON_SEARCHDIALOG ) ) );
2125*cdf0e10cSrcweir 	aToolBox.SetHelpId( TBI_SEARCHDIALOG, HID_HELP_TOOLBOXITEM_SEARCHDIALOG );
2126*cdf0e10cSrcweir 
2127*cdf0e10cSrcweir     InitToolBoxImages();
2128*cdf0e10cSrcweir 	aToolBox.Show();
2129*cdf0e10cSrcweir 	InitOnStartupBox( false );
2130*cdf0e10cSrcweir 	aOnStartupCB.SetClickHdl( LINK( this, SfxHelpTextWindow_Impl, CheckHdl ) );
2131*cdf0e10cSrcweir 
2132*cdf0e10cSrcweir 	aSelectTimer.SetTimeoutHdl( LINK( this, SfxHelpTextWindow_Impl, SelectHdl ) );
2133*cdf0e10cSrcweir 	aSelectTimer.SetTimeout( 1000 );
2134*cdf0e10cSrcweir 
2135*cdf0e10cSrcweir 	char* pEnv = getenv( "help_debug" );
2136*cdf0e10cSrcweir 	if ( pEnv )
2137*cdf0e10cSrcweir 		bIsDebug = sal_True;
2138*cdf0e10cSrcweir 
2139*cdf0e10cSrcweir 	SvtMiscOptions().AddListenerLink( LINK( this, SfxHelpTextWindow_Impl, NotifyHdl ) );
2140*cdf0e10cSrcweir 
2141*cdf0e10cSrcweir 	if ( !aOnStartupCB.GetHelpId().getLength() )
2142*cdf0e10cSrcweir 		aOnStartupCB.SetHelpId( HID_HELP_ONSTARTUP_BOX );
2143*cdf0e10cSrcweir }
2144*cdf0e10cSrcweir 
2145*cdf0e10cSrcweir // -----------------------------------------------------------------------
2146*cdf0e10cSrcweir 
2147*cdf0e10cSrcweir SfxHelpTextWindow_Impl::~SfxHelpTextWindow_Impl()
2148*cdf0e10cSrcweir {
2149*cdf0e10cSrcweir 	sfx2::RemoveFromTaskPaneList( &aToolBox );
2150*cdf0e10cSrcweir 
2151*cdf0e10cSrcweir 	bIsInClose = sal_True;
2152*cdf0e10cSrcweir 	SvtMiscOptions().RemoveListenerLink( LINK( this, SfxHelpTextWindow_Impl, NotifyHdl ) );
2153*cdf0e10cSrcweir 	delete pSrchDlg;
2154*cdf0e10cSrcweir }
2155*cdf0e10cSrcweir 
2156*cdf0e10cSrcweir // -----------------------------------------------------------------------
2157*cdf0e10cSrcweir 
2158*cdf0e10cSrcweir sal_Bool SfxHelpTextWindow_Impl::HasSelection() const
2159*cdf0e10cSrcweir {
2160*cdf0e10cSrcweir 	// is there any selection in the text and not only a cursor?
2161*cdf0e10cSrcweir 	sal_Bool bRet = sal_False;
2162*cdf0e10cSrcweir 	Reference < XTextRange > xRange = getCursor();
2163*cdf0e10cSrcweir 	if ( xRange.is() )
2164*cdf0e10cSrcweir 	{
2165*cdf0e10cSrcweir 		Reference < XText > xText = xRange->getText();
2166*cdf0e10cSrcweir 		Reference < XTextCursor > xCursor = xText->createTextCursorByRange( xRange );
2167*cdf0e10cSrcweir 		bRet = !xCursor->isCollapsed();
2168*cdf0e10cSrcweir 	}
2169*cdf0e10cSrcweir 
2170*cdf0e10cSrcweir 	return bRet;
2171*cdf0e10cSrcweir }
2172*cdf0e10cSrcweir 
2173*cdf0e10cSrcweir // -----------------------------------------------------------------------
2174*cdf0e10cSrcweir 
2175*cdf0e10cSrcweir void SfxHelpTextWindow_Impl::InitToolBoxImages()
2176*cdf0e10cSrcweir {
2177*cdf0e10cSrcweir 	sal_Bool bLarge = SvtMiscOptions().AreCurrentSymbolsLarge();
2178*cdf0e10cSrcweir 	sal_Bool bHiContrast = GetSettings().GetStyleSettings().GetHighContrastMode();
2179*cdf0e10cSrcweir 
2180*cdf0e10cSrcweir 	aIndexOnImage = Image( SfxResId(
2181*cdf0e10cSrcweir 		bLarge ? bHiContrast ? IMG_HELP_TOOLBOX_HCL_INDEX_ON : IMG_HELP_TOOLBOX_L_INDEX_ON
2182*cdf0e10cSrcweir 			   : bHiContrast ? IMG_HELP_TOOLBOX_HC_INDEX_ON : IMG_HELP_TOOLBOX_INDEX_ON ) );
2183*cdf0e10cSrcweir 	aIndexOffImage = Image( SfxResId(
2184*cdf0e10cSrcweir 		bLarge ? bHiContrast ? IMG_HELP_TOOLBOX_HCL_INDEX_OFF : IMG_HELP_TOOLBOX_L_INDEX_OFF
2185*cdf0e10cSrcweir 			   : bHiContrast ? IMG_HELP_TOOLBOX_HC_INDEX_OFF : IMG_HELP_TOOLBOX_INDEX_OFF ) );
2186*cdf0e10cSrcweir 	aToolBox.SetItemImage( TBI_INDEX, bIsIndexOn ? aIndexOffImage : aIndexOnImage );
2187*cdf0e10cSrcweir 
2188*cdf0e10cSrcweir 	aToolBox.SetItemImage( TBI_BACKWARD, Image( SfxResId(
2189*cdf0e10cSrcweir 		bLarge ? bHiContrast ? IMG_HELP_TOOLBOX_HCL_PREV : IMG_HELP_TOOLBOX_L_PREV
2190*cdf0e10cSrcweir 			   : bHiContrast ? IMG_HELP_TOOLBOX_HC_PREV : IMG_HELP_TOOLBOX_PREV ) ) );
2191*cdf0e10cSrcweir 	aToolBox.SetItemImage( TBI_FORWARD, Image( SfxResId(
2192*cdf0e10cSrcweir 		bLarge ? bHiContrast ? IMG_HELP_TOOLBOX_HCL_NEXT : IMG_HELP_TOOLBOX_L_NEXT
2193*cdf0e10cSrcweir 			   : bHiContrast ? IMG_HELP_TOOLBOX_HC_NEXT : IMG_HELP_TOOLBOX_NEXT ) ) );
2194*cdf0e10cSrcweir 	aToolBox.SetItemImage( TBI_START, Image( SfxResId(
2195*cdf0e10cSrcweir 		bLarge ? bHiContrast ? IMG_HELP_TOOLBOX_HCL_START : IMG_HELP_TOOLBOX_L_START
2196*cdf0e10cSrcweir 			   : bHiContrast ? IMG_HELP_TOOLBOX_HC_START : IMG_HELP_TOOLBOX_START ) ) );
2197*cdf0e10cSrcweir 	aToolBox.SetItemImage( TBI_PRINT, Image( SfxResId(
2198*cdf0e10cSrcweir 		bLarge ? bHiContrast ? IMG_HELP_TOOLBOX_HCL_PRINT : IMG_HELP_TOOLBOX_L_PRINT
2199*cdf0e10cSrcweir 			   : bHiContrast ? IMG_HELP_TOOLBOX_HC_PRINT : IMG_HELP_TOOLBOX_PRINT ) ) );
2200*cdf0e10cSrcweir 	aToolBox.SetItemImage( TBI_BOOKMARKS, Image( SfxResId(
2201*cdf0e10cSrcweir 		bLarge ? bHiContrast ? IMG_HELP_TOOLBOX_HCL_BOOKMARKS : IMG_HELP_TOOLBOX_L_BOOKMARKS
2202*cdf0e10cSrcweir 			   : bHiContrast ? IMG_HELP_TOOLBOX_HC_BOOKMARKS : IMG_HELP_TOOLBOX_BOOKMARKS ) ) );
2203*cdf0e10cSrcweir 	aToolBox.SetItemImage( TBI_SEARCHDIALOG, Image( SfxResId(
2204*cdf0e10cSrcweir 		bLarge ? bHiContrast ? IMG_HELP_TOOLBOX_HCL_SEARCHDIALOG : IMG_HELP_TOOLBOX_L_SEARCHDIALOG
2205*cdf0e10cSrcweir 			   : bHiContrast ? IMG_HELP_TOOLBOX_HC_SEARCHDIALOG : IMG_HELP_TOOLBOX_SEARCHDIALOG ) ) );
2206*cdf0e10cSrcweir 
2207*cdf0e10cSrcweir 	Size aSize = aToolBox.CalcWindowSizePixel();
2208*cdf0e10cSrcweir 	aSize.Height() += TOOLBOX_OFFSET;
2209*cdf0e10cSrcweir 	aToolBox.SetPosSizePixel( Point( 0, TOOLBOX_OFFSET ), aSize );
2210*cdf0e10cSrcweir 
2211*cdf0e10cSrcweir 	SvtMiscOptions aMiscOptions;
2212*cdf0e10cSrcweir 	if ( aMiscOptions.GetToolboxStyle() != aToolBox.GetOutStyle() )
2213*cdf0e10cSrcweir 		aToolBox.SetOutStyle( aMiscOptions.GetToolboxStyle() );
2214*cdf0e10cSrcweir }
2215*cdf0e10cSrcweir 
2216*cdf0e10cSrcweir // -----------------------------------------------------------------------
2217*cdf0e10cSrcweir 
2218*cdf0e10cSrcweir void SfxHelpTextWindow_Impl::InitOnStartupBox( bool bOnlyText )
2219*cdf0e10cSrcweir {
2220*cdf0e10cSrcweir     sCurrentFactory = SfxHelp::GetCurrentModuleIdentifier();
2221*cdf0e10cSrcweir 
2222*cdf0e10cSrcweir     Reference< XMultiServiceFactory > xMultiServiceFac = ::comphelper::getProcessServiceFactory();
2223*cdf0e10cSrcweir     Reference< XInterface > xConfig;
2224*cdf0e10cSrcweir     ::rtl::OUString sPath( PATH_OFFICE_FACTORIES );
2225*cdf0e10cSrcweir     sPath += sCurrentFactory;
2226*cdf0e10cSrcweir     ::rtl::OUString sKey( KEY_HELP_ON_OPEN );
2227*cdf0e10cSrcweir 
2228*cdf0e10cSrcweir     // Attention: This check boy knows two states:
2229*cdf0e10cSrcweir     // 1) Reading of the config key fails with an exception or by getting an empty Any (!) => check box must be hidden
2230*cdf0e10cSrcweir     // 2) We read sal_True/sal_False => check box must be shown and enabled/disabled
2231*cdf0e10cSrcweir 
2232*cdf0e10cSrcweir     bool bHideBox = true;
2233*cdf0e10cSrcweir     sal_Bool bHelpAtStartup = sal_False;
2234*cdf0e10cSrcweir     try
2235*cdf0e10cSrcweir     {
2236*cdf0e10cSrcweir         xConfiguration = ConfigurationHelper::openConfig(
2237*cdf0e10cSrcweir             xMultiServiceFac, PACKAGE_SETUP, ConfigurationHelper::E_STANDARD );
2238*cdf0e10cSrcweir         if ( xConfiguration.is() )
2239*cdf0e10cSrcweir         {
2240*cdf0e10cSrcweir             Any aAny = ConfigurationHelper::readRelativeKey( xConfiguration, sPath, sKey );
2241*cdf0e10cSrcweir             if (aAny >>= bHelpAtStartup)
2242*cdf0e10cSrcweir                 bHideBox = false;
2243*cdf0e10cSrcweir         }
2244*cdf0e10cSrcweir     }
2245*cdf0e10cSrcweir     catch( Exception& )
2246*cdf0e10cSrcweir     {
2247*cdf0e10cSrcweir         bHideBox = true;
2248*cdf0e10cSrcweir     }
2249*cdf0e10cSrcweir 
2250*cdf0e10cSrcweir     if ( bHideBox )
2251*cdf0e10cSrcweir 		aOnStartupCB.Hide();
2252*cdf0e10cSrcweir 	else
2253*cdf0e10cSrcweir 	{
2254*cdf0e10cSrcweir 		// detect module name
2255*cdf0e10cSrcweir 		String sModuleName;
2256*cdf0e10cSrcweir 
2257*cdf0e10cSrcweir         if ( xConfiguration.is() )
2258*cdf0e10cSrcweir         {
2259*cdf0e10cSrcweir             ::rtl::OUString sTemp;
2260*cdf0e10cSrcweir             sKey = KEY_UI_NAME;
2261*cdf0e10cSrcweir             try
2262*cdf0e10cSrcweir             {
2263*cdf0e10cSrcweir                 Any aAny = ConfigurationHelper::readRelativeKey( xConfiguration, sPath, sKey );
2264*cdf0e10cSrcweir                 aAny >>= sTemp;
2265*cdf0e10cSrcweir             }
2266*cdf0e10cSrcweir             catch( Exception& )
2267*cdf0e10cSrcweir             {
2268*cdf0e10cSrcweir                 DBG_ERRORFILE( "SfxHelpTextWindow_Impl::InitOnStartupBox(): unexpected exception" );
2269*cdf0e10cSrcweir             }
2270*cdf0e10cSrcweir             sModuleName = String( sTemp );
2271*cdf0e10cSrcweir         }
2272*cdf0e10cSrcweir 
2273*cdf0e10cSrcweir         if ( sModuleName.Len() > 0 )
2274*cdf0e10cSrcweir 		{
2275*cdf0e10cSrcweir 			// set module name in checkbox text
2276*cdf0e10cSrcweir 			String sText( aOnStartupText );
2277*cdf0e10cSrcweir 			sText.SearchAndReplace( String::CreateFromAscii( "%MODULENAME" ), sModuleName );
2278*cdf0e10cSrcweir 			aOnStartupCB.SetText( sText );
2279*cdf0e10cSrcweir 			// and show it
2280*cdf0e10cSrcweir 			aOnStartupCB.Show();
2281*cdf0e10cSrcweir 			// set check state
2282*cdf0e10cSrcweir             aOnStartupCB.Check( bHelpAtStartup );
2283*cdf0e10cSrcweir 			aOnStartupCB.SaveValue();
2284*cdf0e10cSrcweir 
2285*cdf0e10cSrcweir 			// calculate and set optimal width of the onstartup checkbox
2286*cdf0e10cSrcweir 			String sCBText( DEFINE_CONST_UNICODE( "XXX" ) );
2287*cdf0e10cSrcweir 			sCBText += aOnStartupCB.GetText();
2288*cdf0e10cSrcweir 		    long nTextWidth = aOnStartupCB.GetTextWidth( sCBText );
2289*cdf0e10cSrcweir 			Size aSize = aOnStartupCB.GetSizePixel();
2290*cdf0e10cSrcweir 			aSize.Width() = nTextWidth;
2291*cdf0e10cSrcweir 			aOnStartupCB.SetSizePixel( aSize );
2292*cdf0e10cSrcweir 			SetOnStartupBoxPosition();
2293*cdf0e10cSrcweir 		}
2294*cdf0e10cSrcweir 
2295*cdf0e10cSrcweir 		if ( !bOnlyText )
2296*cdf0e10cSrcweir 		{
2297*cdf0e10cSrcweir 			// set position of the checkbox
2298*cdf0e10cSrcweir 			Size a3Size = LogicToPixel( Size( 3, 3 ), MAP_APPFONT );
2299*cdf0e10cSrcweir 			Size aTBSize = aToolBox.GetSizePixel();
2300*cdf0e10cSrcweir 			Size aCBSize = aOnStartupCB.GetSizePixel();
2301*cdf0e10cSrcweir 			Point aPnt = aToolBox.GetPosPixel();
2302*cdf0e10cSrcweir 			aPnt.X() += aTBSize.Width() + a3Size.Width();
2303*cdf0e10cSrcweir 			aPnt.Y() += ( ( aTBSize.Height() - aCBSize.Height() ) / 2 );
2304*cdf0e10cSrcweir 			aOnStartupCB.SetPosPixel( aPnt );
2305*cdf0e10cSrcweir 			nMinPos = aPnt.X();
2306*cdf0e10cSrcweir 		}
2307*cdf0e10cSrcweir 	}
2308*cdf0e10cSrcweir }
2309*cdf0e10cSrcweir 
2310*cdf0e10cSrcweir // -----------------------------------------------------------------------
2311*cdf0e10cSrcweir 
2312*cdf0e10cSrcweir void SfxHelpTextWindow_Impl::SetOnStartupBoxPosition()
2313*cdf0e10cSrcweir {
2314*cdf0e10cSrcweir 	long nX = Max( GetOutputSizePixel().Width() - aOnStartupCB.GetSizePixel().Width(), nMinPos );
2315*cdf0e10cSrcweir 	Point aPos = aOnStartupCB.GetPosPixel();
2316*cdf0e10cSrcweir 	aPos.X() = nX;
2317*cdf0e10cSrcweir 	aOnStartupCB.SetPosPixel( aPos );
2318*cdf0e10cSrcweir }
2319*cdf0e10cSrcweir 
2320*cdf0e10cSrcweir // -----------------------------------------------------------------------
2321*cdf0e10cSrcweir 
2322*cdf0e10cSrcweir Reference< XBreakIterator > SfxHelpTextWindow_Impl::GetBreakIterator()
2323*cdf0e10cSrcweir {
2324*cdf0e10cSrcweir 	if ( !xBreakIterator.is() )
2325*cdf0e10cSrcweir 		xBreakIterator = vcl::unohelper::CreateBreakIterator();
2326*cdf0e10cSrcweir     DBG_ASSERT( xBreakIterator.is(), "Could not create BreakIterator" );
2327*cdf0e10cSrcweir 	return xBreakIterator;
2328*cdf0e10cSrcweir }
2329*cdf0e10cSrcweir 
2330*cdf0e10cSrcweir // -----------------------------------------------------------------------
2331*cdf0e10cSrcweir 
2332*cdf0e10cSrcweir Reference< XTextRange > SfxHelpTextWindow_Impl::getCursor() const
2333*cdf0e10cSrcweir {
2334*cdf0e10cSrcweir 	// return the current cursor
2335*cdf0e10cSrcweir 	Reference< XTextRange > xCursor;
2336*cdf0e10cSrcweir 
2337*cdf0e10cSrcweir 	try
2338*cdf0e10cSrcweir 	{
2339*cdf0e10cSrcweir 		Reference < XSelectionSupplier > xSelSup( xFrame->getController(), UNO_QUERY );
2340*cdf0e10cSrcweir 		if ( xSelSup.is() )
2341*cdf0e10cSrcweir 		{
2342*cdf0e10cSrcweir 			Any aAny = xSelSup->getSelection();
2343*cdf0e10cSrcweir 			Reference < XIndexAccess > xSelection;
2344*cdf0e10cSrcweir 			if ( aAny >>= xSelection )
2345*cdf0e10cSrcweir 			{
2346*cdf0e10cSrcweir 				if ( xSelection->getCount() == 1 )
2347*cdf0e10cSrcweir 				{
2348*cdf0e10cSrcweir 					aAny = xSelection->getByIndex(0);
2349*cdf0e10cSrcweir 					aAny >>= xCursor;
2350*cdf0e10cSrcweir 				}
2351*cdf0e10cSrcweir 			}
2352*cdf0e10cSrcweir 		}
2353*cdf0e10cSrcweir 	}
2354*cdf0e10cSrcweir 	catch( Exception& )
2355*cdf0e10cSrcweir 	{
2356*cdf0e10cSrcweir 		DBG_ERROR( "SfxHelpTextWindow_Impl::getCursor(): unexpected exception" );
2357*cdf0e10cSrcweir 	}
2358*cdf0e10cSrcweir 
2359*cdf0e10cSrcweir 	return xCursor;
2360*cdf0e10cSrcweir }
2361*cdf0e10cSrcweir 
2362*cdf0e10cSrcweir // -----------------------------------------------------------------------
2363*cdf0e10cSrcweir 
2364*cdf0e10cSrcweir bool SfxHelpTextWindow_Impl::isHandledKey( const KeyCode& _rKeyCode )
2365*cdf0e10cSrcweir {
2366*cdf0e10cSrcweir 	bool bRet = false;
2367*cdf0e10cSrcweir 	sal_uInt16 nCode = _rKeyCode.GetCode();
2368*cdf0e10cSrcweir 
2369*cdf0e10cSrcweir 	// the keys <STRG><A> (select all), <STRG><C> (copy),
2370*cdf0e10cSrcweir 	//			<STRG><F> (find), <STRG><P> (print) and <STRG><W> (close window)
2371*cdf0e10cSrcweir 	// were handled in help
2372*cdf0e10cSrcweir 	if ( _rKeyCode.IsMod1() &&
2373*cdf0e10cSrcweir 		 ( KEY_A == nCode || KEY_C == nCode || KEY_F == nCode || KEY_P == nCode || KEY_W == nCode ) )
2374*cdf0e10cSrcweir 	{
2375*cdf0e10cSrcweir 		if ( KEY_F == nCode )
2376*cdf0e10cSrcweir 			DoSearch();
2377*cdf0e10cSrcweir 		else
2378*cdf0e10cSrcweir 			bRet = true;
2379*cdf0e10cSrcweir 	}
2380*cdf0e10cSrcweir 
2381*cdf0e10cSrcweir 	return bRet;
2382*cdf0e10cSrcweir }
2383*cdf0e10cSrcweir 
2384*cdf0e10cSrcweir // -----------------------------------------------------------------------
2385*cdf0e10cSrcweir 
2386*cdf0e10cSrcweir IMPL_LINK( SfxHelpTextWindow_Impl, SelectHdl, Timer*, EMPTYARG )
2387*cdf0e10cSrcweir {
2388*cdf0e10cSrcweir 	try
2389*cdf0e10cSrcweir 	{
2390*cdf0e10cSrcweir 		// select the words, which are equal to the search text of the search page
2391*cdf0e10cSrcweir 		Reference < XController > xController = xFrame->getController();
2392*cdf0e10cSrcweir 		if ( xController.is() )
2393*cdf0e10cSrcweir 		{
2394*cdf0e10cSrcweir 			// get document
2395*cdf0e10cSrcweir 			Reference < XSearchable > xSearchable( xController->getModel(), UNO_QUERY );
2396*cdf0e10cSrcweir 			if ( xSearchable.is() )
2397*cdf0e10cSrcweir 			{
2398*cdf0e10cSrcweir 				// create descriptor, set string and find all words
2399*cdf0e10cSrcweir 				Reference < XSearchDescriptor > xSrchDesc = xSearchable->createSearchDescriptor();
2400*cdf0e10cSrcweir 				Reference < XPropertySet > xPropSet( xSrchDesc, UNO_QUERY );
2401*cdf0e10cSrcweir 				xPropSet->setPropertyValue( DEFINE_CONST_OUSTRING("SearchRegularExpression"),
2402*cdf0e10cSrcweir 											makeAny( sal_Bool( sal_True ) ) );
2403*cdf0e10cSrcweir 				if ( bIsFullWordSearch )
2404*cdf0e10cSrcweir 					xPropSet->setPropertyValue( DEFINE_CONST_OUSTRING("SearchWords"),
2405*cdf0e10cSrcweir 												makeAny( sal_Bool( sal_True ) ) );
2406*cdf0e10cSrcweir 
2407*cdf0e10cSrcweir 				String sSearchString = sfx2::PrepareSearchString( aSearchText, GetBreakIterator(), false );
2408*cdf0e10cSrcweir 				xSrchDesc->setSearchString( sSearchString );
2409*cdf0e10cSrcweir 				Reference< XIndexAccess > xSelection = xSearchable->findAll( xSrchDesc );
2410*cdf0e10cSrcweir 
2411*cdf0e10cSrcweir 				// then select all found words
2412*cdf0e10cSrcweir 				Reference < XSelectionSupplier > xSelectionSup( xController, UNO_QUERY );
2413*cdf0e10cSrcweir 				if ( xSelectionSup.is() )
2414*cdf0e10cSrcweir 				{
2415*cdf0e10cSrcweir 			    	Any aAny;
2416*cdf0e10cSrcweir 					aAny <<= xSelection;
2417*cdf0e10cSrcweir 					xSelectionSup->select( aAny );
2418*cdf0e10cSrcweir 				}
2419*cdf0e10cSrcweir 			}
2420*cdf0e10cSrcweir 		}
2421*cdf0e10cSrcweir 	}
2422*cdf0e10cSrcweir 	catch( Exception& )
2423*cdf0e10cSrcweir 	{
2424*cdf0e10cSrcweir 		DBG_ERROR( "SfxHelpTextWindow_Impl::SelectHdl(): unexpected exception" );
2425*cdf0e10cSrcweir 	}
2426*cdf0e10cSrcweir 
2427*cdf0e10cSrcweir 	return 1;
2428*cdf0e10cSrcweir }
2429*cdf0e10cSrcweir 
2430*cdf0e10cSrcweir // -----------------------------------------------------------------------
2431*cdf0e10cSrcweir 
2432*cdf0e10cSrcweir IMPL_LINK( SfxHelpTextWindow_Impl, NotifyHdl, SvtMiscOptions*, pOptions )
2433*cdf0e10cSrcweir {
2434*cdf0e10cSrcweir     (void)pOptions; // unused variable
2435*cdf0e10cSrcweir     InitToolBoxImages();
2436*cdf0e10cSrcweir 	Resize();
2437*cdf0e10cSrcweir 	aToolBox.Invalidate();
2438*cdf0e10cSrcweir 	return 0;
2439*cdf0e10cSrcweir }
2440*cdf0e10cSrcweir 
2441*cdf0e10cSrcweir // -----------------------------------------------------------------------
2442*cdf0e10cSrcweir 
2443*cdf0e10cSrcweir IMPL_LINK( SfxHelpTextWindow_Impl, FindHdl, sfx2::SearchDialog*, pDlg )
2444*cdf0e10cSrcweir {
2445*cdf0e10cSrcweir 	bool bWrapAround = ( NULL == pDlg );
2446*cdf0e10cSrcweir 	if ( bWrapAround )
2447*cdf0e10cSrcweir 		pDlg = pSrchDlg;
2448*cdf0e10cSrcweir 	DBG_ASSERT( pDlg, "invalid search dialog" );
2449*cdf0e10cSrcweir 	String sSearchText = pDlg->GetSearchText();
2450*cdf0e10cSrcweir 	try
2451*cdf0e10cSrcweir 	{
2452*cdf0e10cSrcweir 		// select the words, which are equal to the search text of the search page
2453*cdf0e10cSrcweir 		Reference < XController > xController = xFrame->getController();
2454*cdf0e10cSrcweir 		if ( xController.is() )
2455*cdf0e10cSrcweir 		{
2456*cdf0e10cSrcweir 			// get document
2457*cdf0e10cSrcweir 			Reference < XSearchable > xSearchable( xController->getModel(), UNO_QUERY );
2458*cdf0e10cSrcweir 			if ( xSearchable.is() )
2459*cdf0e10cSrcweir 			{
2460*cdf0e10cSrcweir 				// create descriptor, set string and find all words
2461*cdf0e10cSrcweir 				Reference < XSearchDescriptor > xSrchDesc = xSearchable->createSearchDescriptor();
2462*cdf0e10cSrcweir 				Reference < XPropertySet > xPropSet( xSrchDesc, UNO_QUERY );
2463*cdf0e10cSrcweir 				xPropSet->setPropertyValue( DEFINE_CONST_OUSTRING("SearchWords"), makeAny( sal_Bool( pDlg->IsOnlyWholeWords() != false ) ) );
2464*cdf0e10cSrcweir 				xPropSet->setPropertyValue( DEFINE_CONST_OUSTRING("SearchCaseSensitive"), makeAny( sal_Bool( pDlg->IsMarchCase() != false ) ) );
2465*cdf0e10cSrcweir 				xPropSet->setPropertyValue( DEFINE_CONST_OUSTRING("SearchBackwards"), makeAny( sal_Bool( pDlg->IsSearchBackwards() != false ) ) );
2466*cdf0e10cSrcweir 				xSrchDesc->setSearchString( sSearchText );
2467*cdf0e10cSrcweir 				Reference< XInterface > xSelection;
2468*cdf0e10cSrcweir 				Reference< XTextRange > xCursor = getCursor();
2469*cdf0e10cSrcweir 
2470*cdf0e10cSrcweir 				if ( xCursor.is() )
2471*cdf0e10cSrcweir 				{
2472*cdf0e10cSrcweir 					if ( pDlg->IsSearchBackwards() )
2473*cdf0e10cSrcweir 						xCursor = xCursor->getStart();
2474*cdf0e10cSrcweir 					xSelection = xSearchable->findNext( xCursor, xSrchDesc );
2475*cdf0e10cSrcweir 				}
2476*cdf0e10cSrcweir 				else
2477*cdf0e10cSrcweir 					xSelection = xSearchable->findFirst( xSrchDesc );
2478*cdf0e10cSrcweir 
2479*cdf0e10cSrcweir 				// then select the found word
2480*cdf0e10cSrcweir 				if ( xSelection.is() )
2481*cdf0e10cSrcweir 				{
2482*cdf0e10cSrcweir 					Reference < XSelectionSupplier > xSelectionSup( xController, UNO_QUERY );
2483*cdf0e10cSrcweir 					if ( xSelectionSup.is() )
2484*cdf0e10cSrcweir 					{
2485*cdf0e10cSrcweir 				    	Any aAny;
2486*cdf0e10cSrcweir 						aAny <<= xSelection;
2487*cdf0e10cSrcweir 						xSelectionSup->select( aAny );
2488*cdf0e10cSrcweir 					}
2489*cdf0e10cSrcweir 				}
2490*cdf0e10cSrcweir 				else if ( pDlg->IsWrapAround() && !bWrapAround )
2491*cdf0e10cSrcweir 				{
2492*cdf0e10cSrcweir 			        Reference < text::XTextViewCursorSupplier > xCrsrSupp( xController, uno::UNO_QUERY );
2493*cdf0e10cSrcweir 					Reference < text::XTextViewCursor > xTVCrsr( xCrsrSupp->getViewCursor(), uno::UNO_QUERY );
2494*cdf0e10cSrcweir 			        if ( xTVCrsr.is() )
2495*cdf0e10cSrcweir 					{
2496*cdf0e10cSrcweir 						Reference < text::XTextDocument > xDoc( xController->getModel(), uno::UNO_QUERY );
2497*cdf0e10cSrcweir 						Reference < text::XText > xText = xDoc->getText();
2498*cdf0e10cSrcweir 						if ( xText.is() )
2499*cdf0e10cSrcweir 						{
2500*cdf0e10cSrcweir 							if ( pDlg->IsSearchBackwards() )
2501*cdf0e10cSrcweir 								xTVCrsr->gotoRange( xText->getEnd(), sal_False );
2502*cdf0e10cSrcweir 							else
2503*cdf0e10cSrcweir 								xTVCrsr->gotoRange( xText->getStart(), sal_False );
2504*cdf0e10cSrcweir 							FindHdl( NULL );
2505*cdf0e10cSrcweir 						}
2506*cdf0e10cSrcweir 					}
2507*cdf0e10cSrcweir 				}
2508*cdf0e10cSrcweir 				else
2509*cdf0e10cSrcweir 				{
2510*cdf0e10cSrcweir 					DBG_ASSERT( pSrchDlg, "no search dialog" );
2511*cdf0e10cSrcweir 					InfoBox aBox( pSrchDlg, SfxResId( RID_INFO_NOSEARCHTEXTFOUND ) );
2512*cdf0e10cSrcweir 					aBox.Execute();
2513*cdf0e10cSrcweir 					pSrchDlg->SetFocusOnEdit();
2514*cdf0e10cSrcweir 				}
2515*cdf0e10cSrcweir 			}
2516*cdf0e10cSrcweir 		}
2517*cdf0e10cSrcweir 	}
2518*cdf0e10cSrcweir 	catch( Exception& )
2519*cdf0e10cSrcweir 	{
2520*cdf0e10cSrcweir 		DBG_ERROR( "SfxHelpTextWindow_Impl::SelectHdl(): unexpected exception" );
2521*cdf0e10cSrcweir 	}
2522*cdf0e10cSrcweir 
2523*cdf0e10cSrcweir 	return 0;
2524*cdf0e10cSrcweir }
2525*cdf0e10cSrcweir 
2526*cdf0e10cSrcweir // -----------------------------------------------------------------------
2527*cdf0e10cSrcweir 
2528*cdf0e10cSrcweir IMPL_LINK( SfxHelpTextWindow_Impl, CloseHdl, sfx2::SearchDialog*, pDlg )
2529*cdf0e10cSrcweir {
2530*cdf0e10cSrcweir     if ( pDlg )
2531*cdf0e10cSrcweir         delete pSrchDlg;
2532*cdf0e10cSrcweir 	pSrchDlg = NULL;
2533*cdf0e10cSrcweir 	return 0;
2534*cdf0e10cSrcweir }
2535*cdf0e10cSrcweir 
2536*cdf0e10cSrcweir // -----------------------------------------------------------------------
2537*cdf0e10cSrcweir 
2538*cdf0e10cSrcweir IMPL_LINK( SfxHelpTextWindow_Impl, CheckHdl, CheckBox*, pBox )
2539*cdf0e10cSrcweir {
2540*cdf0e10cSrcweir     if ( xConfiguration.is() )
2541*cdf0e10cSrcweir     {
2542*cdf0e10cSrcweir         sal_Bool bChecked = pBox->IsChecked();
2543*cdf0e10cSrcweir         ::rtl::OUString sPath( PATH_OFFICE_FACTORIES );
2544*cdf0e10cSrcweir         sPath += sCurrentFactory;
2545*cdf0e10cSrcweir         try
2546*cdf0e10cSrcweir         {
2547*cdf0e10cSrcweir             ConfigurationHelper::writeRelativeKey(
2548*cdf0e10cSrcweir                 xConfiguration, sPath, KEY_HELP_ON_OPEN, makeAny( bChecked ) );
2549*cdf0e10cSrcweir             ConfigurationHelper::flush( xConfiguration );
2550*cdf0e10cSrcweir         }
2551*cdf0e10cSrcweir         catch( Exception& )
2552*cdf0e10cSrcweir         {
2553*cdf0e10cSrcweir             DBG_ERRORFILE( "SfxHelpTextWindow_Impl::CheckHdl(): unexpected exception" );
2554*cdf0e10cSrcweir         }
2555*cdf0e10cSrcweir     }
2556*cdf0e10cSrcweir 
2557*cdf0e10cSrcweir     return 0;
2558*cdf0e10cSrcweir }
2559*cdf0e10cSrcweir 
2560*cdf0e10cSrcweir // -----------------------------------------------------------------------
2561*cdf0e10cSrcweir 
2562*cdf0e10cSrcweir void SfxHelpTextWindow_Impl::Resize()
2563*cdf0e10cSrcweir {
2564*cdf0e10cSrcweir 	Size aSize = GetOutputSizePixel();
2565*cdf0e10cSrcweir 	long nToolBoxHeight = aToolBox.GetSizePixel().Height() + TOOLBOX_OFFSET;
2566*cdf0e10cSrcweir 	aSize.Height() -= nToolBoxHeight;
2567*cdf0e10cSrcweir 	pTextWin->SetPosSizePixel( Point( 0, nToolBoxHeight  ), aSize );
2568*cdf0e10cSrcweir 	SetOnStartupBoxPosition();
2569*cdf0e10cSrcweir }
2570*cdf0e10cSrcweir 
2571*cdf0e10cSrcweir // -----------------------------------------------------------------------
2572*cdf0e10cSrcweir 
2573*cdf0e10cSrcweir long SfxHelpTextWindow_Impl::PreNotify( NotifyEvent& rNEvt )
2574*cdf0e10cSrcweir {
2575*cdf0e10cSrcweir 	long nDone = 0;
2576*cdf0e10cSrcweir 	sal_uInt16 nType = rNEvt.GetType();
2577*cdf0e10cSrcweir 	if ( EVENT_COMMAND == nType && rNEvt.GetCommandEvent() )
2578*cdf0e10cSrcweir 	{
2579*cdf0e10cSrcweir 		const CommandEvent* pCmdEvt = rNEvt.GetCommandEvent();
2580*cdf0e10cSrcweir 		Window* pCmdWin = rNEvt.GetWindow();
2581*cdf0e10cSrcweir 
2582*cdf0e10cSrcweir 		if ( pCmdEvt->GetCommand() == COMMAND_CONTEXTMENU && pCmdWin != this && pCmdWin != &aToolBox )
2583*cdf0e10cSrcweir 		{
2584*cdf0e10cSrcweir 			sal_Bool bHiContrast = GetSettings().GetStyleSettings().GetHighContrastMode();
2585*cdf0e10cSrcweir 			Point aPos;
2586*cdf0e10cSrcweir 			if ( pCmdEvt->IsMouseEvent() )
2587*cdf0e10cSrcweir 				aPos = pCmdEvt->GetMousePosPixel();
2588*cdf0e10cSrcweir 			else
2589*cdf0e10cSrcweir 				aPos = Point( pTextWin->GetPosPixel().X() + 20, 20 );
2590*cdf0e10cSrcweir 			aPos.Y() += pTextWin->GetPosPixel().Y();
2591*cdf0e10cSrcweir 			PopupMenu aMenu;
2592*cdf0e10cSrcweir 			if ( bIsIndexOn )
2593*cdf0e10cSrcweir 				aMenu.InsertItem( TBI_INDEX, aIndexOffText, Image( SfxResId(
2594*cdf0e10cSrcweir 					bHiContrast ? IMG_HELP_TOOLBOX_HC_INDEX_OFF : IMG_HELP_TOOLBOX_INDEX_OFF ) ) );
2595*cdf0e10cSrcweir 			else
2596*cdf0e10cSrcweir 				aMenu.InsertItem( TBI_INDEX, aIndexOnText, Image( SfxResId(
2597*cdf0e10cSrcweir 					bHiContrast ? IMG_HELP_TOOLBOX_HC_INDEX_ON : IMG_HELP_TOOLBOX_INDEX_ON ) ) );
2598*cdf0e10cSrcweir 			aMenu.SetHelpId( TBI_INDEX, HID_HELP_TOOLBOXITEM_INDEX );
2599*cdf0e10cSrcweir 			aMenu.InsertSeparator();
2600*cdf0e10cSrcweir 			aMenu.InsertItem( TBI_BACKWARD, String( SfxResId( STR_HELP_BUTTON_PREV ) ),
2601*cdf0e10cSrcweir 				Image( SfxResId( bHiContrast ? IMG_HELP_TOOLBOX_HC_PREV : IMG_HELP_TOOLBOX_PREV ) ) );
2602*cdf0e10cSrcweir 			aMenu.SetHelpId( TBI_BACKWARD, HID_HELP_TOOLBOXITEM_BACKWARD );
2603*cdf0e10cSrcweir 			aMenu.EnableItem( TBI_BACKWARD, pHelpWin->HasHistoryPredecessor() );
2604*cdf0e10cSrcweir 			aMenu.InsertItem( TBI_FORWARD, String( SfxResId( STR_HELP_BUTTON_NEXT ) ),
2605*cdf0e10cSrcweir 				Image( SfxResId( bHiContrast ? IMG_HELP_TOOLBOX_HC_NEXT : IMG_HELP_TOOLBOX_NEXT ) ) );
2606*cdf0e10cSrcweir 			aMenu.SetHelpId( TBI_FORWARD, HID_HELP_TOOLBOXITEM_FORWARD );
2607*cdf0e10cSrcweir 			aMenu.EnableItem( TBI_FORWARD, pHelpWin->HasHistorySuccessor() );
2608*cdf0e10cSrcweir 			aMenu.InsertItem( TBI_START, String( SfxResId( STR_HELP_BUTTON_START ) ),
2609*cdf0e10cSrcweir 				Image( SfxResId( bHiContrast ? IMG_HELP_TOOLBOX_HC_START : IMG_HELP_TOOLBOX_START ) ) );
2610*cdf0e10cSrcweir 			aMenu.SetHelpId( TBI_START, HID_HELP_TOOLBOXITEM_START );
2611*cdf0e10cSrcweir 			aMenu.InsertSeparator();
2612*cdf0e10cSrcweir 			aMenu.InsertItem( TBI_PRINT, String( SfxResId( STR_HELP_BUTTON_PRINT ) ),
2613*cdf0e10cSrcweir 				Image( SfxResId( bHiContrast ? IMG_HELP_TOOLBOX_HC_PRINT : IMG_HELP_TOOLBOX_PRINT ) ) );
2614*cdf0e10cSrcweir 			aMenu.SetHelpId( TBI_PRINT, HID_HELP_TOOLBOXITEM_PRINT );
2615*cdf0e10cSrcweir 			aMenu.InsertItem( TBI_BOOKMARKS, String( SfxResId( STR_HELP_BUTTON_ADDBOOKMARK ) ),
2616*cdf0e10cSrcweir 				Image( SfxResId( bHiContrast ? IMG_HELP_TOOLBOX_HC_BOOKMARKS : IMG_HELP_TOOLBOX_BOOKMARKS ) ) );
2617*cdf0e10cSrcweir 			aMenu.SetHelpId( TBI_BOOKMARKS, HID_HELP_TOOLBOXITEM_BOOKMARKS );
2618*cdf0e10cSrcweir 			aMenu.InsertItem( TBI_SEARCHDIALOG, String( SfxResId( STR_HELP_BUTTON_SEARCHDIALOG ) ),
2619*cdf0e10cSrcweir 				Image( SfxResId( bHiContrast ? IMG_HELP_TOOLBOX_HC_SEARCHDIALOG : IMG_HELP_TOOLBOX_SEARCHDIALOG ) ) );
2620*cdf0e10cSrcweir 			aMenu.SetHelpId( TBI_SEARCHDIALOG, HID_HELP_TOOLBOXITEM_SEARCHDIALOG );
2621*cdf0e10cSrcweir 			aMenu.InsertSeparator();
2622*cdf0e10cSrcweir             aMenu.InsertItem( TBI_SELECTIONMODE, String( SfxResId( STR_HELP_MENU_TEXT_SELECTION_MODE ) ) );
2623*cdf0e10cSrcweir             aMenu.SetHelpId( TBI_SELECTIONMODE, HID_HELP_TEXT_SELECTION_MODE );
2624*cdf0e10cSrcweir             Reference < XDispatchProvider > xProv( xFrame, UNO_QUERY );
2625*cdf0e10cSrcweir             URL aURL;
2626*cdf0e10cSrcweir             aURL.Complete = DEFINE_CONST_UNICODE(".uno:SelectTextMode");
2627*cdf0e10cSrcweir 			PARSE_URL( aURL );
2628*cdf0e10cSrcweir 			Reference < XDispatch > xDisp = xProv.is() ?
2629*cdf0e10cSrcweir                     xProv->queryDispatch( aURL, rtl::OUString(), 0 ) : Reference < XDispatch >();
2630*cdf0e10cSrcweir             if(xDisp.is())
2631*cdf0e10cSrcweir             {
2632*cdf0e10cSrcweir                 HelpStatusListener_Impl* pStateListener;
2633*cdf0e10cSrcweir                 Reference<XStatusListener>xStateListener = pStateListener =
2634*cdf0e10cSrcweir                                         new HelpStatusListener_Impl(xDisp, aURL );
2635*cdf0e10cSrcweir                 FeatureStateEvent rEvent = pStateListener->GetStateEvent();
2636*cdf0e10cSrcweir 				sal_Bool bCheck = sal_False;
2637*cdf0e10cSrcweir                 rEvent.State >>= bCheck;
2638*cdf0e10cSrcweir                 aMenu.CheckItem(TBI_SELECTIONMODE, bCheck);
2639*cdf0e10cSrcweir             }
2640*cdf0e10cSrcweir             aMenu.InsertSeparator();
2641*cdf0e10cSrcweir             aMenu.InsertItem( TBI_COPY, String( SfxResId( STR_HELP_MENU_TEXT_COPY ) ),
2642*cdf0e10cSrcweir 				Image( SfxResId( bHiContrast ? IMG_HELP_TOOLBOX_HC_COPY : IMG_HELP_TOOLBOX_COPY ) ) );
2643*cdf0e10cSrcweir 			aMenu.SetHelpId( TBI_COPY, ".uno:Copy" );
2644*cdf0e10cSrcweir 			aMenu.EnableItem( TBI_COPY, HasSelection() );
2645*cdf0e10cSrcweir 
2646*cdf0e10cSrcweir 			if ( bIsDebug )
2647*cdf0e10cSrcweir 			{
2648*cdf0e10cSrcweir 				aMenu.InsertSeparator();
2649*cdf0e10cSrcweir 				aMenu.InsertItem( TBI_SOURCEVIEW, String( SfxResId( STR_HELP_BUTTON_SOURCEVIEW ) ) );
2650*cdf0e10cSrcweir 			}
2651*cdf0e10cSrcweir 
2652*cdf0e10cSrcweir 			if( SvtMenuOptions().IsEntryHidingEnabled() == sal_False )
2653*cdf0e10cSrcweir 				aMenu.SetMenuFlags( aMenu.GetMenuFlags() | MENU_FLAG_HIDEDISABLEDENTRIES );
2654*cdf0e10cSrcweir 
2655*cdf0e10cSrcweir 			sal_uInt16 nId = aMenu.Execute( this, aPos );
2656*cdf0e10cSrcweir 			pHelpWin->DoAction( nId );
2657*cdf0e10cSrcweir 			nDone = 1;
2658*cdf0e10cSrcweir 		}
2659*cdf0e10cSrcweir 	}
2660*cdf0e10cSrcweir 	else if ( EVENT_KEYINPUT == nType && rNEvt.GetKeyEvent() )
2661*cdf0e10cSrcweir 	{
2662*cdf0e10cSrcweir 	 	const KeyEvent* pKEvt = rNEvt.GetKeyEvent();
2663*cdf0e10cSrcweir 	 	const KeyCode& rKeyCode = pKEvt->GetKeyCode();
2664*cdf0e10cSrcweir 		sal_uInt16 nKeyGroup = rKeyCode.GetGroup();
2665*cdf0e10cSrcweir 		sal_uInt16 nKey = rKeyCode.GetCode();
2666*cdf0e10cSrcweir 		if ( KEYGROUP_ALPHA == nKeyGroup &&  !isHandledKey( rKeyCode ) )
2667*cdf0e10cSrcweir 		{
2668*cdf0e10cSrcweir 			// do nothing disables the writer accelerators
2669*cdf0e10cSrcweir 			nDone = 1;
2670*cdf0e10cSrcweir  		}
2671*cdf0e10cSrcweir 		else if ( rKeyCode.IsMod1() && ( KEY_F4 == nKey || KEY_W == nKey ) )
2672*cdf0e10cSrcweir 		{
2673*cdf0e10cSrcweir 			// <STRG><F4> or <STRG><W> -> close top frame
2674*cdf0e10cSrcweir 			pHelpWin->CloseWindow();
2675*cdf0e10cSrcweir 			nDone = 1;
2676*cdf0e10cSrcweir 		}
2677*cdf0e10cSrcweir         else if ( KEY_TAB == nKey && aOnStartupCB.HasChildPathFocus() )
2678*cdf0e10cSrcweir 		{
2679*cdf0e10cSrcweir 			aToolBox.GrabFocus();
2680*cdf0e10cSrcweir 			nDone = 1;
2681*cdf0e10cSrcweir 		}
2682*cdf0e10cSrcweir 	}
2683*cdf0e10cSrcweir 
2684*cdf0e10cSrcweir 	return nDone ? nDone : Window::PreNotify( rNEvt );
2685*cdf0e10cSrcweir }
2686*cdf0e10cSrcweir 
2687*cdf0e10cSrcweir // -----------------------------------------------------------------------
2688*cdf0e10cSrcweir 
2689*cdf0e10cSrcweir void SfxHelpTextWindow_Impl::GetFocus()
2690*cdf0e10cSrcweir {
2691*cdf0e10cSrcweir 	if ( !bIsInClose )
2692*cdf0e10cSrcweir 	{
2693*cdf0e10cSrcweir 		try
2694*cdf0e10cSrcweir 		{
2695*cdf0e10cSrcweir 			if( xFrame.is() )
2696*cdf0e10cSrcweir 			{
2697*cdf0e10cSrcweir 				Reference< ::com::sun::star::awt::XWindow >	xWindow = xFrame->getComponentWindow();
2698*cdf0e10cSrcweir 				if( xWindow.is() )
2699*cdf0e10cSrcweir 					xWindow->setFocus();
2700*cdf0e10cSrcweir 			}
2701*cdf0e10cSrcweir 		}
2702*cdf0e10cSrcweir 		catch( Exception& )
2703*cdf0e10cSrcweir 		{
2704*cdf0e10cSrcweir 			DBG_ERRORFILE( "SfxHelpTextWindow_Impl::GetFocus(): unexpected exception" );
2705*cdf0e10cSrcweir 		}
2706*cdf0e10cSrcweir 	}
2707*cdf0e10cSrcweir }
2708*cdf0e10cSrcweir 
2709*cdf0e10cSrcweir // -----------------------------------------------------------------------
2710*cdf0e10cSrcweir 
2711*cdf0e10cSrcweir void SfxHelpTextWindow_Impl::DataChanged( const DataChangedEvent& rDCEvt )
2712*cdf0e10cSrcweir {
2713*cdf0e10cSrcweir 	Window::DataChanged( rDCEvt );
2714*cdf0e10cSrcweir 
2715*cdf0e10cSrcweir 	if ( ( ( rDCEvt.GetType() == DATACHANGED_SETTINGS )	||
2716*cdf0e10cSrcweir 		   ( rDCEvt.GetType() == DATACHANGED_DISPLAY ) ) &&
2717*cdf0e10cSrcweir 		 ( rDCEvt.GetFlags() & SETTINGS_STYLE ) )
2718*cdf0e10cSrcweir 	{
2719*cdf0e10cSrcweir 		SetBackground( Wallpaper( GetSettings().GetStyleSettings().GetFaceColor() ) );
2720*cdf0e10cSrcweir 		InitToolBoxImages();
2721*cdf0e10cSrcweir 	}
2722*cdf0e10cSrcweir }
2723*cdf0e10cSrcweir 
2724*cdf0e10cSrcweir // -----------------------------------------------------------------------
2725*cdf0e10cSrcweir 
2726*cdf0e10cSrcweir void SfxHelpTextWindow_Impl::ToggleIndex( sal_Bool bOn )
2727*cdf0e10cSrcweir {
2728*cdf0e10cSrcweir 	bIsIndexOn = bOn;
2729*cdf0e10cSrcweir 	if ( bIsIndexOn )
2730*cdf0e10cSrcweir 	{
2731*cdf0e10cSrcweir 		aToolBox.SetItemImage( TBI_INDEX, aIndexOffImage );
2732*cdf0e10cSrcweir 		aToolBox.SetItemText( TBI_INDEX, aIndexOffText );
2733*cdf0e10cSrcweir 	}
2734*cdf0e10cSrcweir 	else
2735*cdf0e10cSrcweir 	{
2736*cdf0e10cSrcweir 		aToolBox.SetItemImage( TBI_INDEX, aIndexOnImage );
2737*cdf0e10cSrcweir 		aToolBox.SetItemText( TBI_INDEX, aIndexOnText );
2738*cdf0e10cSrcweir 	}
2739*cdf0e10cSrcweir }
2740*cdf0e10cSrcweir 
2741*cdf0e10cSrcweir // -----------------------------------------------------------------------
2742*cdf0e10cSrcweir 
2743*cdf0e10cSrcweir void SfxHelpTextWindow_Impl::SelectSearchText( const String& rSearchText, sal_Bool _bIsFullWordSearch )
2744*cdf0e10cSrcweir {
2745*cdf0e10cSrcweir 	aSearchText = rSearchText;
2746*cdf0e10cSrcweir 	bIsFullWordSearch = _bIsFullWordSearch;
2747*cdf0e10cSrcweir 	aSelectTimer.Start();
2748*cdf0e10cSrcweir }
2749*cdf0e10cSrcweir 
2750*cdf0e10cSrcweir // -----------------------------------------------------------------------
2751*cdf0e10cSrcweir 
2752*cdf0e10cSrcweir void SfxHelpTextWindow_Impl::SetPageStyleHeaderOff() const
2753*cdf0e10cSrcweir {
2754*cdf0e10cSrcweir #ifdef DBG_UTIL
2755*cdf0e10cSrcweir 	sal_Bool bSetOff = sal_False;
2756*cdf0e10cSrcweir #endif
2757*cdf0e10cSrcweir 	// set off the pagestyle header to prevent print output of the help URL
2758*cdf0e10cSrcweir 	try
2759*cdf0e10cSrcweir 	{
2760*cdf0e10cSrcweir 		Reference < XController > xController = xFrame->getController();
2761*cdf0e10cSrcweir 		Reference < XSelectionSupplier > xSelSup( xController, UNO_QUERY );
2762*cdf0e10cSrcweir 		if ( xSelSup.is() )
2763*cdf0e10cSrcweir 		{
2764*cdf0e10cSrcweir 			Reference < XIndexAccess > xSelection;
2765*cdf0e10cSrcweir 			if ( xSelSup->getSelection() >>= xSelection )
2766*cdf0e10cSrcweir 			{
2767*cdf0e10cSrcweir 				Reference < XTextRange > xRange;
2768*cdf0e10cSrcweir 				if ( xSelection->getByIndex(0) >>= xRange )
2769*cdf0e10cSrcweir 				{
2770*cdf0e10cSrcweir 					Reference < XText > xText = xRange->getText();
2771*cdf0e10cSrcweir 					Reference < XPropertySet > xProps( xText->createTextCursorByRange( xRange ), UNO_QUERY );
2772*cdf0e10cSrcweir 					::rtl::OUString sStyleName;
2773*cdf0e10cSrcweir 					if ( xProps->getPropertyValue( DEFINE_CONST_OUSTRING("PageStyleName") ) >>= sStyleName )
2774*cdf0e10cSrcweir 					{
2775*cdf0e10cSrcweir 						Reference < XStyleFamiliesSupplier > xStyles( xController->getModel(), UNO_QUERY );
2776*cdf0e10cSrcweir 						Reference < XNameContainer > xContainer;
2777*cdf0e10cSrcweir 						if ( xStyles->getStyleFamilies()->getByName( DEFINE_CONST_OUSTRING("PageStyles") )
2778*cdf0e10cSrcweir 							 >>= xContainer )
2779*cdf0e10cSrcweir 						{
2780*cdf0e10cSrcweir 							Reference < XStyle > xStyle;
2781*cdf0e10cSrcweir 							if ( xContainer->getByName( sStyleName ) >>= xStyle )
2782*cdf0e10cSrcweir 							{
2783*cdf0e10cSrcweir 								Reference < XPropertySet > xPropSet( xStyle, UNO_QUERY );
2784*cdf0e10cSrcweir 								xPropSet->setPropertyValue( DEFINE_CONST_OUSTRING("HeaderIsOn"),
2785*cdf0e10cSrcweir 															makeAny( sal_Bool( sal_False ) ) );
2786*cdf0e10cSrcweir 
2787*cdf0e10cSrcweir                                 Reference< XModifiable > xReset(xStyles, UNO_QUERY);
2788*cdf0e10cSrcweir                                 xReset->setModified(sal_False);
2789*cdf0e10cSrcweir #ifdef DBG_UTIL
2790*cdf0e10cSrcweir 								bSetOff = sal_True;
2791*cdf0e10cSrcweir #endif
2792*cdf0e10cSrcweir 							}
2793*cdf0e10cSrcweir 						}
2794*cdf0e10cSrcweir 					}
2795*cdf0e10cSrcweir 				}
2796*cdf0e10cSrcweir 			}
2797*cdf0e10cSrcweir 		}
2798*cdf0e10cSrcweir 	}
2799*cdf0e10cSrcweir 	catch( Exception& )
2800*cdf0e10cSrcweir 	{
2801*cdf0e10cSrcweir 		DBG_ERRORFILE( "SfxHelpTextWindow_Impl::SetPageStyleHeaderOff(): unexpected exception" );
2802*cdf0e10cSrcweir 	}
2803*cdf0e10cSrcweir 
2804*cdf0e10cSrcweir #ifdef DBG_UTIL
2805*cdf0e10cSrcweir 	if ( !bSetOff )
2806*cdf0e10cSrcweir 	{
2807*cdf0e10cSrcweir 		DBG_ERRORFILE( "SfxHelpTextWindow_Impl::SetPageStyleHeaderOff(): set off failed" );
2808*cdf0e10cSrcweir 	}
2809*cdf0e10cSrcweir #endif
2810*cdf0e10cSrcweir }
2811*cdf0e10cSrcweir 
2812*cdf0e10cSrcweir // -----------------------------------------------------------------------
2813*cdf0e10cSrcweir 
2814*cdf0e10cSrcweir void SfxHelpTextWindow_Impl::CloseFrame()
2815*cdf0e10cSrcweir {
2816*cdf0e10cSrcweir 	bIsInClose = sal_True;
2817*cdf0e10cSrcweir     try
2818*cdf0e10cSrcweir     {
2819*cdf0e10cSrcweir         ::com::sun::star::uno::Reference< ::com::sun::star::util::XCloseable > xCloseable  ( xFrame, ::com::sun::star::uno::UNO_QUERY );
2820*cdf0e10cSrcweir         if (xCloseable.is())
2821*cdf0e10cSrcweir             xCloseable->close(sal_True);
2822*cdf0e10cSrcweir     }
2823*cdf0e10cSrcweir     catch( ::com::sun::star::util::CloseVetoException& )
2824*cdf0e10cSrcweir     {
2825*cdf0e10cSrcweir     }
2826*cdf0e10cSrcweir }
2827*cdf0e10cSrcweir 
2828*cdf0e10cSrcweir // -----------------------------------------------------------------------
2829*cdf0e10cSrcweir 
2830*cdf0e10cSrcweir void SfxHelpTextWindow_Impl::DoSearch()
2831*cdf0e10cSrcweir {
2832*cdf0e10cSrcweir 	if ( !pSrchDlg )
2833*cdf0e10cSrcweir 	{
2834*cdf0e10cSrcweir 		// create the search dialog
2835*cdf0e10cSrcweir 		pSrchDlg = new sfx2::SearchDialog( pTextWin, DEFINE_CONST_UNICODE("HelpSearchDialog") );
2836*cdf0e10cSrcweir 		// set handler
2837*cdf0e10cSrcweir 		pSrchDlg->SetFindHdl( LINK( this, SfxHelpTextWindow_Impl, FindHdl ) );
2838*cdf0e10cSrcweir 		pSrchDlg->SetCloseHdl( LINK( this, SfxHelpTextWindow_Impl, CloseHdl ) );
2839*cdf0e10cSrcweir 		// get selected text of the help page to set it as the search text
2840*cdf0e10cSrcweir 		Reference< XTextRange > xCursor = getCursor();
2841*cdf0e10cSrcweir 		if ( xCursor.is() )
2842*cdf0e10cSrcweir 		{
2843*cdf0e10cSrcweir 			String sText = xCursor->getString();
2844*cdf0e10cSrcweir 			if ( sText.Len() > 0 )
2845*cdf0e10cSrcweir 				pSrchDlg->SetSearchText( sText );
2846*cdf0e10cSrcweir 		}
2847*cdf0e10cSrcweir 		pSrchDlg->Show();
2848*cdf0e10cSrcweir 	}
2849*cdf0e10cSrcweir }
2850*cdf0e10cSrcweir 
2851*cdf0e10cSrcweir // class SfxHelpWindow_Impl ----------------------------------------------
2852*cdf0e10cSrcweir 
2853*cdf0e10cSrcweir void SfxHelpWindow_Impl::Resize()
2854*cdf0e10cSrcweir {
2855*cdf0e10cSrcweir 	SplitWindow::Resize();
2856*cdf0e10cSrcweir 	InitSizes();
2857*cdf0e10cSrcweir }
2858*cdf0e10cSrcweir 
2859*cdf0e10cSrcweir // -----------------------------------------------------------------------
2860*cdf0e10cSrcweir 
2861*cdf0e10cSrcweir void SfxHelpWindow_Impl::Split()
2862*cdf0e10cSrcweir {
2863*cdf0e10cSrcweir 	static long	nMinSplitSize = 5;
2864*cdf0e10cSrcweir 	static long nMaxSplitSize = 99 - nMinSplitSize;
2865*cdf0e10cSrcweir 
2866*cdf0e10cSrcweir 	SplitWindow::Split();
2867*cdf0e10cSrcweir 
2868*cdf0e10cSrcweir 	nIndexSize = GetItemSize( INDEXWIN_ID );
2869*cdf0e10cSrcweir 	nTextSize = GetItemSize( TEXTWIN_ID );
2870*cdf0e10cSrcweir 
2871*cdf0e10cSrcweir 	sal_Bool		bMod = sal_False;
2872*cdf0e10cSrcweir 	if( nIndexSize < nMinSplitSize )
2873*cdf0e10cSrcweir 	{
2874*cdf0e10cSrcweir 		nIndexSize = nMinSplitSize;
2875*cdf0e10cSrcweir 		nTextSize = nMaxSplitSize;
2876*cdf0e10cSrcweir 
2877*cdf0e10cSrcweir 		bMod = sal_True;
2878*cdf0e10cSrcweir 	}
2879*cdf0e10cSrcweir 	else if( nTextSize < nMinSplitSize )
2880*cdf0e10cSrcweir 	{
2881*cdf0e10cSrcweir 		nTextSize = nMinSplitSize;
2882*cdf0e10cSrcweir 		nIndexSize = nMaxSplitSize;
2883*cdf0e10cSrcweir 
2884*cdf0e10cSrcweir 		bMod = sal_True;
2885*cdf0e10cSrcweir 	}
2886*cdf0e10cSrcweir 	else
2887*cdf0e10cSrcweir 		bMod = sal_False;
2888*cdf0e10cSrcweir 
2889*cdf0e10cSrcweir 	if( bMod )
2890*cdf0e10cSrcweir 	{
2891*cdf0e10cSrcweir 		SetItemSize( INDEXWIN_ID, nIndexSize );
2892*cdf0e10cSrcweir 		SetItemSize( TEXTWIN_ID, nTextSize );
2893*cdf0e10cSrcweir 	}
2894*cdf0e10cSrcweir 
2895*cdf0e10cSrcweir 	InitSizes();
2896*cdf0e10cSrcweir }
2897*cdf0e10cSrcweir 
2898*cdf0e10cSrcweir // -----------------------------------------------------------------------
2899*cdf0e10cSrcweir 
2900*cdf0e10cSrcweir void SfxHelpWindow_Impl::GetFocus()
2901*cdf0e10cSrcweir {
2902*cdf0e10cSrcweir 	pTextWin->GrabFocus();
2903*cdf0e10cSrcweir }
2904*cdf0e10cSrcweir 
2905*cdf0e10cSrcweir // -----------------------------------------------------------------------
2906*cdf0e10cSrcweir 
2907*cdf0e10cSrcweir void SfxHelpWindow_Impl::MakeLayout()
2908*cdf0e10cSrcweir {
2909*cdf0e10cSrcweir 	if ( nHeight > 0 && xWindow.is() )
2910*cdf0e10cSrcweir 	{
2911*cdf0e10cSrcweir        	Window* pScreenWin = VCLUnoHelper::GetWindow( xWindow );
2912*cdf0e10cSrcweir 
2913*cdf0e10cSrcweir         /* #i55528#
2914*cdf0e10cSrcweir             Hide() / Show() will produce starnge effects.
2915*cdf0e10cSrcweir             The returned size (used later to be written back into the configuration)
2916*cdf0e10cSrcweir             isnt the right after a resize during the window is hidden.
2917*cdf0e10cSrcweir             If this resize is done if the window is visible evyrthing works as aspected.
2918*cdf0e10cSrcweir             Some VCL-patches could not solve this problem so I've established the
2919*cdf0e10cSrcweir             workaround: resize the help window if it's visible .-)
2920*cdf0e10cSrcweir         */
2921*cdf0e10cSrcweir //      pScreenWin->Hide();
2922*cdf0e10cSrcweir 
2923*cdf0e10cSrcweir 		::com::sun::star::awt::Rectangle aRect = xWindow->getPosSize();
2924*cdf0e10cSrcweir 		sal_Int32 nOldWidth = bIndex ? nCollapseWidth : nExpandWidth;
2925*cdf0e10cSrcweir 		sal_Int32 nWidth = bIndex ? nExpandWidth : nCollapseWidth;
2926*cdf0e10cSrcweir     	xWindow->setPosSize( aRect.X, aRect.Y, nWidth, nHeight, ::com::sun::star::awt::PosSize::SIZE );
2927*cdf0e10cSrcweir 
2928*cdf0e10cSrcweir 		if ( aRect.Width > 0 && aRect.Height > 0 )
2929*cdf0e10cSrcweir 		{
2930*cdf0e10cSrcweir 			Rectangle aScreenRect = pScreenWin->GetClientWindowExtentsRelative( NULL );
2931*cdf0e10cSrcweir     		Point aNewPos = aScreenRect.TopLeft();
2932*cdf0e10cSrcweir 			sal_Int32 nDiffWidth = nOldWidth - nWidth;
2933*cdf0e10cSrcweir 			aNewPos.X() += nDiffWidth;
2934*cdf0e10cSrcweir 			pScreenWin->SetPosPixel( aNewPos );
2935*cdf0e10cSrcweir 		}
2936*cdf0e10cSrcweir 		else if ( aWinPos.X() > 0 && aWinPos.Y() > 0 )
2937*cdf0e10cSrcweir 			pScreenWin->SetPosPixel( aWinPos );
2938*cdf0e10cSrcweir 
2939*cdf0e10cSrcweir //      pScreenWin->Show();
2940*cdf0e10cSrcweir 	}
2941*cdf0e10cSrcweir 
2942*cdf0e10cSrcweir 	Clear();
2943*cdf0e10cSrcweir 
2944*cdf0e10cSrcweir 	if ( bIndex )
2945*cdf0e10cSrcweir 	{
2946*cdf0e10cSrcweir 		pIndexWin->Show();
2947*cdf0e10cSrcweir 		InsertItem( COLSET_ID, 100, SPLITWINDOW_APPEND, SPLITSET_ID, SWIB_PERCENTSIZE | SWIB_COLSET );
2948*cdf0e10cSrcweir 		InsertItem( INDEXWIN_ID, pIndexWin, nIndexSize, SPLITWINDOW_APPEND, COLSET_ID, SWIB_PERCENTSIZE );
2949*cdf0e10cSrcweir 		InsertItem( TEXTWIN_ID, pTextWin, nTextSize, SPLITWINDOW_APPEND, COLSET_ID, SWIB_PERCENTSIZE );
2950*cdf0e10cSrcweir 	}
2951*cdf0e10cSrcweir 	else
2952*cdf0e10cSrcweir 	{
2953*cdf0e10cSrcweir 		pIndexWin->Hide();
2954*cdf0e10cSrcweir 		InsertItem( COLSET_ID, 100, SPLITWINDOW_APPEND, SPLITSET_ID, SWIB_PERCENTSIZE | SWIB_COLSET );
2955*cdf0e10cSrcweir 		InsertItem( TEXTWIN_ID, pTextWin, 100, SPLITWINDOW_APPEND, 1, SWIB_PERCENTSIZE );
2956*cdf0e10cSrcweir 	}
2957*cdf0e10cSrcweir }
2958*cdf0e10cSrcweir 
2959*cdf0e10cSrcweir // -----------------------------------------------------------------------
2960*cdf0e10cSrcweir 
2961*cdf0e10cSrcweir void SfxHelpWindow_Impl::InitSizes()
2962*cdf0e10cSrcweir {
2963*cdf0e10cSrcweir 	if ( xWindow.is() )
2964*cdf0e10cSrcweir 	{
2965*cdf0e10cSrcweir 		::com::sun::star::awt::Rectangle aRect = xWindow->getPosSize();
2966*cdf0e10cSrcweir 		nHeight = aRect.Height;
2967*cdf0e10cSrcweir 
2968*cdf0e10cSrcweir 		if ( bIndex )
2969*cdf0e10cSrcweir 		{
2970*cdf0e10cSrcweir 			nExpandWidth = aRect.Width;
2971*cdf0e10cSrcweir 			nCollapseWidth = nExpandWidth * nTextSize / 100;
2972*cdf0e10cSrcweir 		}
2973*cdf0e10cSrcweir 		else
2974*cdf0e10cSrcweir 		{
2975*cdf0e10cSrcweir 			nCollapseWidth = aRect.Width;
2976*cdf0e10cSrcweir 			nExpandWidth = nCollapseWidth * 100 / nTextSize;
2977*cdf0e10cSrcweir 		}
2978*cdf0e10cSrcweir 	}
2979*cdf0e10cSrcweir }
2980*cdf0e10cSrcweir 
2981*cdf0e10cSrcweir // -----------------------------------------------------------------------
2982*cdf0e10cSrcweir 
2983*cdf0e10cSrcweir void SfxHelpWindow_Impl::LoadConfig()
2984*cdf0e10cSrcweir {
2985*cdf0e10cSrcweir  	SvtViewOptions aViewOpt( E_WINDOW, CONFIGNAME_HELPWIN );
2986*cdf0e10cSrcweir 	if ( aViewOpt.Exists() )
2987*cdf0e10cSrcweir 	{
2988*cdf0e10cSrcweir 		bIndex = aViewOpt.IsVisible();
2989*cdf0e10cSrcweir 		String aUserData;
2990*cdf0e10cSrcweir         Any aUserItem = aViewOpt.GetUserItem( USERITEM_NAME );
2991*cdf0e10cSrcweir 		rtl::OUString aTemp;
2992*cdf0e10cSrcweir 		if ( aUserItem >>= aTemp )
2993*cdf0e10cSrcweir 		{
2994*cdf0e10cSrcweir 			aUserData = String( aTemp );
2995*cdf0e10cSrcweir 			DBG_ASSERT( aUserData.GetTokenCount() == 6, "invalid user data" );
2996*cdf0e10cSrcweir 			sal_uInt16 nIdx = 0;
2997*cdf0e10cSrcweir 			nIndexSize = aUserData.GetToken( 0, ';', nIdx ).ToInt32();
2998*cdf0e10cSrcweir 			nTextSize = aUserData.GetToken( 0, ';', nIdx ).ToInt32();
2999*cdf0e10cSrcweir 			sal_Int32 nWidth = aUserData.GetToken( 0, ';', nIdx ).ToInt32();
3000*cdf0e10cSrcweir 			nHeight = aUserData.GetToken( 0, ';', nIdx ).ToInt32();
3001*cdf0e10cSrcweir 			aWinPos.X() = aUserData.GetToken( 0, ';', nIdx ).ToInt32();
3002*cdf0e10cSrcweir 			aWinPos.Y() = aUserData.GetToken( 0, ';', nIdx ).ToInt32();
3003*cdf0e10cSrcweir 			if ( bIndex )
3004*cdf0e10cSrcweir 			{
3005*cdf0e10cSrcweir 				nExpandWidth = nWidth;
3006*cdf0e10cSrcweir 				nCollapseWidth = nExpandWidth * nTextSize / 100;
3007*cdf0e10cSrcweir 			}
3008*cdf0e10cSrcweir 			else
3009*cdf0e10cSrcweir 			{
3010*cdf0e10cSrcweir 				nCollapseWidth = nWidth;
3011*cdf0e10cSrcweir 				nExpandWidth = nCollapseWidth * 100 / nTextSize;
3012*cdf0e10cSrcweir 			}
3013*cdf0e10cSrcweir 		}
3014*cdf0e10cSrcweir 
3015*cdf0e10cSrcweir 		pTextWin->ToggleIndex( bIndex );
3016*cdf0e10cSrcweir 	}
3017*cdf0e10cSrcweir }
3018*cdf0e10cSrcweir 
3019*cdf0e10cSrcweir // -----------------------------------------------------------------------
3020*cdf0e10cSrcweir 
3021*cdf0e10cSrcweir void SfxHelpWindow_Impl::SaveConfig()
3022*cdf0e10cSrcweir {
3023*cdf0e10cSrcweir 	SvtViewOptions aViewOpt( E_WINDOW, CONFIGNAME_HELPWIN );
3024*cdf0e10cSrcweir 	sal_Int32 nW = 0, nH = 0;
3025*cdf0e10cSrcweir 
3026*cdf0e10cSrcweir 	if ( xWindow.is() )
3027*cdf0e10cSrcweir 	{
3028*cdf0e10cSrcweir 		::com::sun::star::awt::Rectangle aRect = xWindow->getPosSize();
3029*cdf0e10cSrcweir 		nW = aRect.Width;
3030*cdf0e10cSrcweir 		nH = aRect.Height;
3031*cdf0e10cSrcweir 	}
3032*cdf0e10cSrcweir 
3033*cdf0e10cSrcweir 	aViewOpt.SetVisible( bIndex );
3034*cdf0e10cSrcweir 	String aUserData = String::CreateFromInt32( nIndexSize );
3035*cdf0e10cSrcweir 	aUserData += ';';
3036*cdf0e10cSrcweir 	aUserData += String::CreateFromInt32( nTextSize );
3037*cdf0e10cSrcweir 	aUserData += ';';
3038*cdf0e10cSrcweir 	aUserData += String::CreateFromInt32( nW );
3039*cdf0e10cSrcweir 	aUserData += ';';
3040*cdf0e10cSrcweir 	aUserData += String::CreateFromInt32( nH );
3041*cdf0e10cSrcweir 
3042*cdf0e10cSrcweir    	Window* pScreenWin = VCLUnoHelper::GetWindow( xWindow );
3043*cdf0e10cSrcweir 	aWinPos = pScreenWin->GetWindowExtentsRelative( NULL ).TopLeft();
3044*cdf0e10cSrcweir 	aUserData += ';';
3045*cdf0e10cSrcweir 	aUserData += String::CreateFromInt32( aWinPos.X() );
3046*cdf0e10cSrcweir 	aUserData += ';';
3047*cdf0e10cSrcweir 	aUserData += String::CreateFromInt32( aWinPos.Y() );
3048*cdf0e10cSrcweir 
3049*cdf0e10cSrcweir     aViewOpt.SetUserItem( USERITEM_NAME, makeAny( rtl::OUString( aUserData ) ) );
3050*cdf0e10cSrcweir }
3051*cdf0e10cSrcweir 
3052*cdf0e10cSrcweir // -----------------------------------------------------------------------
3053*cdf0e10cSrcweir 
3054*cdf0e10cSrcweir void SfxHelpWindow_Impl::ShowStartPage()
3055*cdf0e10cSrcweir {
3056*cdf0e10cSrcweir     ::rtl::OUString sHelpURL = SfxHelpWindow_Impl::buildHelpURL(pIndexWin->GetFactory(),
3057*cdf0e10cSrcweir                                                                 DEFINE_CONST_UNICODE("/start"),
3058*cdf0e10cSrcweir                                                                 ::rtl::OUString(),
3059*cdf0e10cSrcweir                                                                 sal_True);
3060*cdf0e10cSrcweir     loadHelpContent(sHelpURL);
3061*cdf0e10cSrcweir }
3062*cdf0e10cSrcweir 
3063*cdf0e10cSrcweir // -----------------------------------------------------------------------
3064*cdf0e10cSrcweir 
3065*cdf0e10cSrcweir IMPL_LINK( SfxHelpWindow_Impl, SelectHdl, ToolBox* , pToolBox )
3066*cdf0e10cSrcweir {
3067*cdf0e10cSrcweir 	if ( pToolBox )
3068*cdf0e10cSrcweir 	{
3069*cdf0e10cSrcweir 		bGrabFocusToToolBox = pToolBox->HasChildPathFocus();
3070*cdf0e10cSrcweir 		DoAction( pToolBox->GetCurItemId() );
3071*cdf0e10cSrcweir 	}
3072*cdf0e10cSrcweir 
3073*cdf0e10cSrcweir 	return 1;
3074*cdf0e10cSrcweir }
3075*cdf0e10cSrcweir 
3076*cdf0e10cSrcweir //-------------------------------------------------------------------------
3077*cdf0e10cSrcweir 
3078*cdf0e10cSrcweir IMPL_LINK( SfxHelpWindow_Impl, OpenHdl, SfxHelpIndexWindow_Impl* , EMPTYARG )
3079*cdf0e10cSrcweir {
3080*cdf0e10cSrcweir 	pIndexWin->SelectExecutableEntry();
3081*cdf0e10cSrcweir 	String aEntry = pIndexWin->GetSelectEntry();
3082*cdf0e10cSrcweir 
3083*cdf0e10cSrcweir 	if ( aEntry.Len() < 1 )
3084*cdf0e10cSrcweir         return 0;
3085*cdf0e10cSrcweir 
3086*cdf0e10cSrcweir     ::rtl::OUString sHelpURL;
3087*cdf0e10cSrcweir 
3088*cdf0e10cSrcweir // 	INetURLObject aObj(aEntry);
3089*cdf0e10cSrcweir //  sal_Bool bComplete = ( aObj.GetProtocol() == INET_PROT_VND_SUN_STAR_HELP );
3090*cdf0e10cSrcweir 
3091*cdf0e10cSrcweir     sal_Bool bComplete = rtl::OUString(aEntry).toAsciiLowerCase().match(rtl::OUString::createFromAscii("vnd.sun.star.help"),0);
3092*cdf0e10cSrcweir 
3093*cdf0e10cSrcweir 	if (bComplete)
3094*cdf0e10cSrcweir         sHelpURL = ::rtl::OUString(aEntry);
3095*cdf0e10cSrcweir     else
3096*cdf0e10cSrcweir 	{
3097*cdf0e10cSrcweir 		String aId;
3098*cdf0e10cSrcweir         String aAnchor = String('#');
3099*cdf0e10cSrcweir 		if ( aEntry.GetTokenCount( '#' ) == 2 )
3100*cdf0e10cSrcweir 		{
3101*cdf0e10cSrcweir 			aId = aEntry.GetToken( 0, '#' );
3102*cdf0e10cSrcweir 			aAnchor += aEntry.GetToken( 1, '#' );
3103*cdf0e10cSrcweir 		}
3104*cdf0e10cSrcweir 		else
3105*cdf0e10cSrcweir 			aId = aEntry;
3106*cdf0e10cSrcweir 
3107*cdf0e10cSrcweir 		aEntry  = '/';
3108*cdf0e10cSrcweir 		aEntry += aId;
3109*cdf0e10cSrcweir 
3110*cdf0e10cSrcweir         sHelpURL = SfxHelpWindow_Impl::buildHelpURL(pIndexWin->GetFactory(),
3111*cdf0e10cSrcweir                                                     aEntry,
3112*cdf0e10cSrcweir                                                     aAnchor,
3113*cdf0e10cSrcweir                                                     sal_True);
3114*cdf0e10cSrcweir 	}
3115*cdf0e10cSrcweir 
3116*cdf0e10cSrcweir     loadHelpContent(sHelpURL);
3117*cdf0e10cSrcweir 
3118*cdf0e10cSrcweir 	return 0;
3119*cdf0e10cSrcweir }
3120*cdf0e10cSrcweir 
3121*cdf0e10cSrcweir //-------------------------------------------------------------------------
3122*cdf0e10cSrcweir 
3123*cdf0e10cSrcweir IMPL_LINK( SfxHelpWindow_Impl, SelectFactoryHdl, SfxHelpIndexWindow_Impl* , pWin )
3124*cdf0e10cSrcweir {
3125*cdf0e10cSrcweir     if ( sTitle.Len() == 0 )
3126*cdf0e10cSrcweir         sTitle = GetParent()->GetText();
3127*cdf0e10cSrcweir 
3128*cdf0e10cSrcweir 	String aNewTitle = sTitle;
3129*cdf0e10cSrcweir 	aNewTitle += DEFINE_CONST_UNICODE(" - ");
3130*cdf0e10cSrcweir 	aNewTitle += pIndexWin->GetActiveFactoryTitle();
3131*cdf0e10cSrcweir 
3132*cdf0e10cSrcweir     Reference< XTitle > xTitle(xFrame, UNO_QUERY);
3133*cdf0e10cSrcweir     if (xTitle.is ())
3134*cdf0e10cSrcweir         xTitle->setTitle (aNewTitle);
3135*cdf0e10cSrcweir 
3136*cdf0e10cSrcweir 	if ( pWin )
3137*cdf0e10cSrcweir 		ShowStartPage();
3138*cdf0e10cSrcweir 	pIndexWin->ClearSearchPage();
3139*cdf0e10cSrcweir 
3140*cdf0e10cSrcweir 	return 0;
3141*cdf0e10cSrcweir }
3142*cdf0e10cSrcweir 
3143*cdf0e10cSrcweir // -----------------------------------------------------------------------
3144*cdf0e10cSrcweir 
3145*cdf0e10cSrcweir IMPL_LINK( SfxHelpWindow_Impl, ChangeHdl, HelpListener_Impl*, pListener )
3146*cdf0e10cSrcweir {
3147*cdf0e10cSrcweir 	SetFactory( pListener->GetFactory() );
3148*cdf0e10cSrcweir 	return 0;
3149*cdf0e10cSrcweir }
3150*cdf0e10cSrcweir 
3151*cdf0e10cSrcweir // -----------------------------------------------------------------------
3152*cdf0e10cSrcweir 
3153*cdf0e10cSrcweir void SfxHelpWindow_Impl::openDone(const ::rtl::OUString& sURL    ,
3154*cdf0e10cSrcweir                                         sal_Bool         bSuccess)
3155*cdf0e10cSrcweir {
3156*cdf0e10cSrcweir 	INetURLObject aObj( sURL );
3157*cdf0e10cSrcweir 	if ( aObj.GetProtocol() == INET_PROT_VND_SUN_STAR_HELP )
3158*cdf0e10cSrcweir 		SetFactory( aObj.GetHost() );
3159*cdf0e10cSrcweir 	if ( IsWait() )
3160*cdf0e10cSrcweir 		LeaveWait();
3161*cdf0e10cSrcweir 	if ( bGrabFocusToToolBox )
3162*cdf0e10cSrcweir 	{
3163*cdf0e10cSrcweir 		pTextWin->GetToolBox().GrabFocus();
3164*cdf0e10cSrcweir 		bGrabFocusToToolBox = sal_False;
3165*cdf0e10cSrcweir 	}
3166*cdf0e10cSrcweir 	else
3167*cdf0e10cSrcweir 		pIndexWin->GrabFocusBack();
3168*cdf0e10cSrcweir 	if ( bSuccess )
3169*cdf0e10cSrcweir 	{
3170*cdf0e10cSrcweir 		// set some view settings: "prevent help tips" and "helpid == 68245"
3171*cdf0e10cSrcweir 		try
3172*cdf0e10cSrcweir 		{
3173*cdf0e10cSrcweir 			Reference < XController > xController = pTextWin->getFrame()->getController();
3174*cdf0e10cSrcweir 			if ( xController.is() )
3175*cdf0e10cSrcweir 			{
3176*cdf0e10cSrcweir 				Reference < XViewSettingsSupplier > xSettings( xController, UNO_QUERY );
3177*cdf0e10cSrcweir 				Reference < XPropertySet > xViewProps = xSettings->getViewSettings();
3178*cdf0e10cSrcweir                 Reference< XPropertySetInfo > xInfo = xViewProps->getPropertySetInfo();
3179*cdf0e10cSrcweir 				Any aBoolAny = makeAny( sal_Bool( sal_True ) );
3180*cdf0e10cSrcweir 				xViewProps->setPropertyValue( DEFINE_CONST_OUSTRING("PreventHelpTips"), aBoolAny );
3181*cdf0e10cSrcweir 				xViewProps->setPropertyValue( DEFINE_CONST_OUSTRING("ShowGraphics"), aBoolAny );
3182*cdf0e10cSrcweir 				xViewProps->setPropertyValue( DEFINE_CONST_OUSTRING("ShowTables"), aBoolAny );
3183*cdf0e10cSrcweir                 xViewProps->setPropertyValue( DEFINE_CONST_OUSTRING("HelpURL"), makeAny( DEFINE_CONST_OUSTRING("HID:SFX2_HID_HELP_ONHELP") ) );
3184*cdf0e10cSrcweir                 ::rtl::OUString sProperty( DEFINE_CONST_OUSTRING("IsExecuteHyperlinks") );
3185*cdf0e10cSrcweir                 if ( xInfo->hasPropertyByName( sProperty ) )
3186*cdf0e10cSrcweir                     xViewProps->setPropertyValue( sProperty, aBoolAny );
3187*cdf0e10cSrcweir                 xController->restoreViewData(pHelpInterceptor->GetViewData());
3188*cdf0e10cSrcweir 			}
3189*cdf0e10cSrcweir 		}
3190*cdf0e10cSrcweir 		catch( Exception& )
3191*cdf0e10cSrcweir 		{
3192*cdf0e10cSrcweir 			DBG_ERROR( "SfxHelpWindow_Impl::OpenDoneHdl(): unexpected exception" );
3193*cdf0e10cSrcweir 		}
3194*cdf0e10cSrcweir 
3195*cdf0e10cSrcweir 		// When the SearchPage opens the help doc, then select all words, which are equal to its text
3196*cdf0e10cSrcweir 		String sSearchText = TRIM( pIndexWin->GetSearchText() );
3197*cdf0e10cSrcweir 		if ( sSearchText.Len() > 0 )
3198*cdf0e10cSrcweir 			pTextWin->SelectSearchText( sSearchText, pIndexWin->IsFullWordSearch() );
3199*cdf0e10cSrcweir 
3200*cdf0e10cSrcweir 		// no page style header -> this prevents a print output of the URL
3201*cdf0e10cSrcweir 		pTextWin->SetPageStyleHeaderOff();
3202*cdf0e10cSrcweir 	}
3203*cdf0e10cSrcweir }
3204*cdf0e10cSrcweir 
3205*cdf0e10cSrcweir // -----------------------------------------------------------------------
3206*cdf0e10cSrcweir 
3207*cdf0e10cSrcweir SfxHelpWindow_Impl::SfxHelpWindow_Impl(
3208*cdf0e10cSrcweir 	const ::com::sun::star::uno::Reference < ::com::sun::star::frame::XFrame >& rFrame,
3209*cdf0e10cSrcweir 	Window* pParent, WinBits ) :
3210*cdf0e10cSrcweir 
3211*cdf0e10cSrcweir 	SplitWindow( pParent, WB_3DLOOK | WB_NOSPLITDRAW ),
3212*cdf0e10cSrcweir 
3213*cdf0e10cSrcweir 	xFrame				( rFrame ),
3214*cdf0e10cSrcweir 	pIndexWin			( NULL ),
3215*cdf0e10cSrcweir 	pTextWin	   		( NULL ),
3216*cdf0e10cSrcweir 	pHelpInterceptor	( new HelpInterceptor_Impl() ),
3217*cdf0e10cSrcweir 	pHelpListener		( new HelpListener_Impl( pHelpInterceptor ) ),
3218*cdf0e10cSrcweir 	nExpandWidth		( 0 ),
3219*cdf0e10cSrcweir 	nCollapseWidth		( 0 ),
3220*cdf0e10cSrcweir 	nHeight				( 0 ),
3221*cdf0e10cSrcweir 	nIndexSize			( 40 ),
3222*cdf0e10cSrcweir 	nTextSize			( 60 ),
3223*cdf0e10cSrcweir 	bIndex				( sal_True ),
3224*cdf0e10cSrcweir 	bGrabFocusToToolBox	( sal_False ),
3225*cdf0e10cSrcweir 	aWinPos				( 0, 0 ),
3226*cdf0e10cSrcweir 	sTitle				( pParent->GetText() )
3227*cdf0e10cSrcweir {
3228*cdf0e10cSrcweir 	SetHelpId( HID_HELP_WINDOW );
3229*cdf0e10cSrcweir 	SetStyle( GetStyle() | WB_DIALOGCONTROL );
3230*cdf0e10cSrcweir 
3231*cdf0e10cSrcweir 	pHelpInterceptor->InitWaiter( this );
3232*cdf0e10cSrcweir 	pIndexWin = new SfxHelpIndexWindow_Impl( this );
3233*cdf0e10cSrcweir 	pIndexWin->SetDoubleClickHdl( LINK( this, SfxHelpWindow_Impl, OpenHdl ) );
3234*cdf0e10cSrcweir 	pIndexWin->SetSelectFactoryHdl( LINK( this, SfxHelpWindow_Impl, SelectFactoryHdl ) );
3235*cdf0e10cSrcweir 	pIndexWin->Show();
3236*cdf0e10cSrcweir 	pTextWin = new SfxHelpTextWindow_Impl( this );
3237*cdf0e10cSrcweir     Reference < XFramesSupplier > xSup( rFrame, UNO_QUERY );
3238*cdf0e10cSrcweir     Reference < XFrames > xFrames = xSup->getFrames();
3239*cdf0e10cSrcweir     xFrames->append( pTextWin->getFrame() );
3240*cdf0e10cSrcweir 	pTextWin->SetSelectHdl( LINK( this, SfxHelpWindow_Impl, SelectHdl ) );
3241*cdf0e10cSrcweir 	pTextWin->Show();
3242*cdf0e10cSrcweir 	pHelpInterceptor->setInterception( pTextWin->getFrame() );
3243*cdf0e10cSrcweir 	pHelpListener->SetChangeHdl( LINK( this, SfxHelpWindow_Impl, ChangeHdl ) );
3244*cdf0e10cSrcweir 	LoadConfig();
3245*cdf0e10cSrcweir }
3246*cdf0e10cSrcweir 
3247*cdf0e10cSrcweir // -----------------------------------------------------------------------
3248*cdf0e10cSrcweir 
3249*cdf0e10cSrcweir SfxHelpWindow_Impl::~SfxHelpWindow_Impl()
3250*cdf0e10cSrcweir {
3251*cdf0e10cSrcweir 	SaveConfig();
3252*cdf0e10cSrcweir 	Window*	pDel = pIndexWin;
3253*cdf0e10cSrcweir 	pIndexWin = NULL;
3254*cdf0e10cSrcweir 	delete pDel;
3255*cdf0e10cSrcweir 
3256*cdf0e10cSrcweir 	pTextWin->CloseFrame();
3257*cdf0e10cSrcweir 	delete pTextWin;
3258*cdf0e10cSrcweir }
3259*cdf0e10cSrcweir 
3260*cdf0e10cSrcweir // -----------------------------------------------------------------------
3261*cdf0e10cSrcweir 
3262*cdf0e10cSrcweir long SfxHelpWindow_Impl::PreNotify( NotifyEvent& rNEvt )
3263*cdf0e10cSrcweir {
3264*cdf0e10cSrcweir 	sal_Bool bHandled = sal_False;
3265*cdf0e10cSrcweir 	if ( rNEvt.GetType() == EVENT_KEYINPUT )
3266*cdf0e10cSrcweir 	{
3267*cdf0e10cSrcweir 		// Backward == <ALT><LEFT> or <BACKSPACE> Forward == <ALT><RIGHT>
3268*cdf0e10cSrcweir 	 	const KeyCode& rKeyCode = rNEvt.GetKeyEvent()->GetKeyCode();
3269*cdf0e10cSrcweir 		sal_uInt16 nKey = rKeyCode.GetCode();
3270*cdf0e10cSrcweir 		if ( ( rKeyCode.IsMod2() && ( KEY_LEFT == nKey || KEY_RIGHT == nKey ) ) ||
3271*cdf0e10cSrcweir 			 ( !rKeyCode.GetModifier() && KEY_BACKSPACE == nKey && !pIndexWin->HasFocusOnEdit() ) )
3272*cdf0e10cSrcweir 		{
3273*cdf0e10cSrcweir 			DoAction( rKeyCode.GetCode() == KEY_RIGHT ? TBI_FORWARD : TBI_BACKWARD );
3274*cdf0e10cSrcweir 			bHandled = sal_True;
3275*cdf0e10cSrcweir 		}
3276*cdf0e10cSrcweir 		else if ( rKeyCode.IsMod1() && ( KEY_F4 == nKey || KEY_W == nKey ) )
3277*cdf0e10cSrcweir 		{
3278*cdf0e10cSrcweir 			// <STRG><F4> or <STRG><W> -> close top frame
3279*cdf0e10cSrcweir 			CloseWindow();
3280*cdf0e10cSrcweir 			bHandled = sal_True;
3281*cdf0e10cSrcweir 		}
3282*cdf0e10cSrcweir 	}
3283*cdf0e10cSrcweir 	return bHandled ? 1 : Window::PreNotify( rNEvt );
3284*cdf0e10cSrcweir }
3285*cdf0e10cSrcweir 
3286*cdf0e10cSrcweir // -----------------------------------------------------------------------
3287*cdf0e10cSrcweir 
3288*cdf0e10cSrcweir void SfxHelpWindow_Impl::setContainerWindow( Reference < ::com::sun::star::awt::XWindow > xWin )
3289*cdf0e10cSrcweir {
3290*cdf0e10cSrcweir 	xWindow = xWin;
3291*cdf0e10cSrcweir 	MakeLayout();
3292*cdf0e10cSrcweir }
3293*cdf0e10cSrcweir 
3294*cdf0e10cSrcweir // -----------------------------------------------------------------------
3295*cdf0e10cSrcweir 
3296*cdf0e10cSrcweir void SfxHelpWindow_Impl::SetFactory( const String& rFactory )
3297*cdf0e10cSrcweir {
3298*cdf0e10cSrcweir 	pIndexWin->SetFactory( rFactory, sal_True );
3299*cdf0e10cSrcweir }
3300*cdf0e10cSrcweir 
3301*cdf0e10cSrcweir // -----------------------------------------------------------------------
3302*cdf0e10cSrcweir 
3303*cdf0e10cSrcweir void SfxHelpWindow_Impl::SetHelpURL( const String& rURL )
3304*cdf0e10cSrcweir {
3305*cdf0e10cSrcweir 	INetURLObject aObj( rURL );
3306*cdf0e10cSrcweir 	if ( aObj.GetProtocol() == INET_PROT_VND_SUN_STAR_HELP )
3307*cdf0e10cSrcweir 		SetFactory( aObj.GetHost() );
3308*cdf0e10cSrcweir }
3309*cdf0e10cSrcweir 
3310*cdf0e10cSrcweir // -----------------------------------------------------------------------
3311*cdf0e10cSrcweir 
3312*cdf0e10cSrcweir void SfxHelpWindow_Impl::DoAction( sal_uInt16 nActionId )
3313*cdf0e10cSrcweir {
3314*cdf0e10cSrcweir 	switch ( nActionId )
3315*cdf0e10cSrcweir 	{
3316*cdf0e10cSrcweir 		case TBI_INDEX :
3317*cdf0e10cSrcweir 		{
3318*cdf0e10cSrcweir 			bIndex = !bIndex;
3319*cdf0e10cSrcweir 			MakeLayout();
3320*cdf0e10cSrcweir 			pTextWin->ToggleIndex( bIndex );
3321*cdf0e10cSrcweir 			break;
3322*cdf0e10cSrcweir 		}
3323*cdf0e10cSrcweir 
3324*cdf0e10cSrcweir 		case TBI_START :
3325*cdf0e10cSrcweir 		{
3326*cdf0e10cSrcweir 			ShowStartPage();
3327*cdf0e10cSrcweir 			break;
3328*cdf0e10cSrcweir 		}
3329*cdf0e10cSrcweir 
3330*cdf0e10cSrcweir 		case TBI_BACKWARD :
3331*cdf0e10cSrcweir 		case TBI_FORWARD :
3332*cdf0e10cSrcweir 		{
3333*cdf0e10cSrcweir 			URL aURL;
3334*cdf0e10cSrcweir 	        aURL.Complete = DEFINE_CONST_UNICODE(".uno:Backward");
3335*cdf0e10cSrcweir 			if ( TBI_FORWARD == nActionId )
3336*cdf0e10cSrcweir 		        aURL.Complete = DEFINE_CONST_UNICODE(".uno:Forward");
3337*cdf0e10cSrcweir 			PARSE_URL( aURL );
3338*cdf0e10cSrcweir 			pHelpInterceptor->dispatch( aURL, Sequence < PropertyValue >() );
3339*cdf0e10cSrcweir 			break;
3340*cdf0e10cSrcweir 		}
3341*cdf0e10cSrcweir 
3342*cdf0e10cSrcweir 		case TBI_SEARCHDIALOG :
3343*cdf0e10cSrcweir 		{
3344*cdf0e10cSrcweir 			pTextWin->DoSearch();
3345*cdf0e10cSrcweir 			break;
3346*cdf0e10cSrcweir 		}
3347*cdf0e10cSrcweir 
3348*cdf0e10cSrcweir 		case TBI_PRINT :
3349*cdf0e10cSrcweir 		case TBI_SOURCEVIEW :
3350*cdf0e10cSrcweir 		case TBI_COPY :
3351*cdf0e10cSrcweir         case TBI_SELECTIONMODE:
3352*cdf0e10cSrcweir 		{
3353*cdf0e10cSrcweir 			Reference < XDispatchProvider > xProv( pTextWin->getFrame(), UNO_QUERY );
3354*cdf0e10cSrcweir 			if ( xProv.is() )
3355*cdf0e10cSrcweir 			{
3356*cdf0e10cSrcweir 				URL aURL;
3357*cdf0e10cSrcweir 				if ( TBI_PRINT == nActionId )
3358*cdf0e10cSrcweir 		        	aURL.Complete = DEFINE_CONST_UNICODE(".uno:Print");
3359*cdf0e10cSrcweir 				else if ( TBI_SOURCEVIEW == nActionId )
3360*cdf0e10cSrcweir 		        	aURL.Complete = DEFINE_CONST_UNICODE(".uno:SourceView");
3361*cdf0e10cSrcweir 				else if ( TBI_COPY == nActionId )
3362*cdf0e10cSrcweir 		        	aURL.Complete = DEFINE_CONST_UNICODE(".uno:Copy");
3363*cdf0e10cSrcweir                 else if ( TBI_SELECTIONMODE == nActionId )
3364*cdf0e10cSrcweir                     aURL.Complete = DEFINE_CONST_UNICODE(".uno:SelectTextMode");
3365*cdf0e10cSrcweir                 else
3366*cdf0e10cSrcweir 		        	aURL.Complete = DEFINE_CONST_UNICODE(".uno:SearchDialog");
3367*cdf0e10cSrcweir 				PARSE_URL( aURL );
3368*cdf0e10cSrcweir             	Reference < XDispatch > xDisp = xProv->queryDispatch( aURL, String(), 0 );
3369*cdf0e10cSrcweir             	if ( xDisp.is() )
3370*cdf0e10cSrcweir                 	xDisp->dispatch( aURL, Sequence < PropertyValue >() );
3371*cdf0e10cSrcweir 			}
3372*cdf0e10cSrcweir 			break;
3373*cdf0e10cSrcweir 		}
3374*cdf0e10cSrcweir 
3375*cdf0e10cSrcweir 		case TBI_BOOKMARKS :
3376*cdf0e10cSrcweir 		{
3377*cdf0e10cSrcweir 			String aURL = pHelpInterceptor->GetCurrentURL();
3378*cdf0e10cSrcweir 			if ( aURL.Len() > 0 )
3379*cdf0e10cSrcweir 			{
3380*cdf0e10cSrcweir 				try
3381*cdf0e10cSrcweir 				{
3382*cdf0e10cSrcweir 					Content aCnt( aURL, Reference< ::com::sun::star::ucb::XCommandEnvironment > () );
3383*cdf0e10cSrcweir 					::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > xInfo = aCnt.getProperties();
3384*cdf0e10cSrcweir 					if ( xInfo->hasPropertyByName( PROPERTY_TITLE ) )
3385*cdf0e10cSrcweir 					{
3386*cdf0e10cSrcweir 						::com::sun::star::uno::Any aAny = aCnt.getPropertyValue( PROPERTY_TITLE );
3387*cdf0e10cSrcweir 						rtl::OUString aValue;
3388*cdf0e10cSrcweir 						if ( aAny >>= aValue )
3389*cdf0e10cSrcweir 						{
3390*cdf0e10cSrcweir 							String aTitle( aValue );
3391*cdf0e10cSrcweir 							SfxAddHelpBookmarkDialog_Impl aDlg( this, sal_False );
3392*cdf0e10cSrcweir 							aDlg.SetTitle( aTitle );
3393*cdf0e10cSrcweir 							if ( aDlg.Execute() == RET_OK )
3394*cdf0e10cSrcweir 							{
3395*cdf0e10cSrcweir 								aTitle = aDlg.GetTitle();
3396*cdf0e10cSrcweir 								pIndexWin->AddBookmarks( aTitle, aURL );
3397*cdf0e10cSrcweir 							}
3398*cdf0e10cSrcweir 						}
3399*cdf0e10cSrcweir 					}
3400*cdf0e10cSrcweir 				}
3401*cdf0e10cSrcweir 				catch( Exception& )
3402*cdf0e10cSrcweir 				{
3403*cdf0e10cSrcweir 					DBG_ERROR( "SfxHelpWindow_Impl::DoAction(): unexpected exception" );
3404*cdf0e10cSrcweir 				}
3405*cdf0e10cSrcweir 			}
3406*cdf0e10cSrcweir 			break;
3407*cdf0e10cSrcweir 		}
3408*cdf0e10cSrcweir 	}
3409*cdf0e10cSrcweir }
3410*cdf0e10cSrcweir 
3411*cdf0e10cSrcweir // -----------------------------------------------------------------------
3412*cdf0e10cSrcweir 
3413*cdf0e10cSrcweir void SfxHelpWindow_Impl::CloseWindow()
3414*cdf0e10cSrcweir {
3415*cdf0e10cSrcweir 	try
3416*cdf0e10cSrcweir 	{
3417*cdf0e10cSrcweir 		// search for top frame
3418*cdf0e10cSrcweir 		Reference< XFramesSupplier > xCreator = getTextFrame()->getCreator();
3419*cdf0e10cSrcweir 		while ( xCreator.is() && !xCreator->isTop() )
3420*cdf0e10cSrcweir 		{
3421*cdf0e10cSrcweir 		    xCreator = xCreator->getCreator();
3422*cdf0e10cSrcweir 		}
3423*cdf0e10cSrcweir 
3424*cdf0e10cSrcweir 		// when found, close it
3425*cdf0e10cSrcweir 		if ( xCreator.is() && xCreator->isTop() )
3426*cdf0e10cSrcweir 		{
3427*cdf0e10cSrcweir 			Reference < XCloseable > xCloser( xCreator, UNO_QUERY );
3428*cdf0e10cSrcweir 			if ( xCloser.is() )
3429*cdf0e10cSrcweir 				xCloser->close( sal_False );
3430*cdf0e10cSrcweir 		}
3431*cdf0e10cSrcweir 	}
3432*cdf0e10cSrcweir 	catch( Exception& )
3433*cdf0e10cSrcweir 	{
3434*cdf0e10cSrcweir 		DBG_ERRORFILE( "SfxHelpWindow_Impl::CloseWindow(): caught an exception" );
3435*cdf0e10cSrcweir 	}
3436*cdf0e10cSrcweir }
3437*cdf0e10cSrcweir 
3438*cdf0e10cSrcweir // -----------------------------------------------------------------------
3439*cdf0e10cSrcweir 
3440*cdf0e10cSrcweir void SfxHelpWindow_Impl::UpdateToolbox()
3441*cdf0e10cSrcweir {
3442*cdf0e10cSrcweir 	pTextWin->GetToolBox().EnableItem( TBI_BACKWARD, pHelpInterceptor->HasHistoryPred() );
3443*cdf0e10cSrcweir 	pTextWin->GetToolBox().EnableItem( TBI_FORWARD, pHelpInterceptor->HasHistorySucc() );
3444*cdf0e10cSrcweir }
3445*cdf0e10cSrcweir 
3446*cdf0e10cSrcweir // -----------------------------------------------------------------------
3447*cdf0e10cSrcweir 
3448*cdf0e10cSrcweir sal_Bool SfxHelpWindow_Impl::HasHistoryPredecessor() const
3449*cdf0e10cSrcweir {
3450*cdf0e10cSrcweir 	return pHelpInterceptor->HasHistoryPred();
3451*cdf0e10cSrcweir }
3452*cdf0e10cSrcweir 
3453*cdf0e10cSrcweir // -----------------------------------------------------------------------
3454*cdf0e10cSrcweir 
3455*cdf0e10cSrcweir sal_Bool SfxHelpWindow_Impl::HasHistorySuccessor() const
3456*cdf0e10cSrcweir {
3457*cdf0e10cSrcweir 	return pHelpInterceptor->HasHistorySucc();
3458*cdf0e10cSrcweir }
3459*cdf0e10cSrcweir 
3460*cdf0e10cSrcweir // class SfxAddHelpBookmarkDialog_Impl -----------------------------------
3461*cdf0e10cSrcweir 
3462*cdf0e10cSrcweir SfxAddHelpBookmarkDialog_Impl::SfxAddHelpBookmarkDialog_Impl( Window* pParent, sal_Bool bRename ) :
3463*cdf0e10cSrcweir 
3464*cdf0e10cSrcweir 	ModalDialog( pParent, SfxResId( DLG_HELP_ADDBOOKMARK ) ),
3465*cdf0e10cSrcweir 
3466*cdf0e10cSrcweir 	aTitleFT	( this, SfxResId( FT_BOOKMARK_TITLE ) ),
3467*cdf0e10cSrcweir 	aTitleED	( this, SfxResId( ED_BOOKMARK_TITLE ) ),
3468*cdf0e10cSrcweir 	aOKBtn		( this, SfxResId( PB_BOOKMARK_OK ) ),
3469*cdf0e10cSrcweir 	aEscBtn		( this, SfxResId( PB_BOOKMARK_CANCEL ) ),
3470*cdf0e10cSrcweir 	aHelpBtn	( this, SfxResId( PB_BOOKMARK_HELP ) )
3471*cdf0e10cSrcweir 
3472*cdf0e10cSrcweir {
3473*cdf0e10cSrcweir 	if ( bRename )
3474*cdf0e10cSrcweir 		SetText( String( SfxResId( STR_BOOKMARK_RENAME ) ) );
3475*cdf0e10cSrcweir 
3476*cdf0e10cSrcweir 	FreeResource();
3477*cdf0e10cSrcweir }
3478*cdf0e10cSrcweir 
3479*cdf0e10cSrcweir // -----------------------------------------------------------------------
3480*cdf0e10cSrcweir 
3481*cdf0e10cSrcweir SfxAddHelpBookmarkDialog_Impl::~SfxAddHelpBookmarkDialog_Impl()
3482*cdf0e10cSrcweir {
3483*cdf0e10cSrcweir }
3484*cdf0e10cSrcweir 
3485*cdf0e10cSrcweir // -----------------------------------------------------------------------
3486*cdf0e10cSrcweir 
3487*cdf0e10cSrcweir void SfxAddHelpBookmarkDialog_Impl::SetTitle( const String& rTitle )
3488*cdf0e10cSrcweir {
3489*cdf0e10cSrcweir 	aTitleED.SetText( rTitle );
3490*cdf0e10cSrcweir 	aTitleED.SetSelection( Selection( 0, rTitle.Len() ) );
3491*cdf0e10cSrcweir }
3492*cdf0e10cSrcweir 
3493