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