xref: /aoo41x/main/sw/source/ui/index/cnttab.cxx (revision cdf0e10c)
1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 // MARKER(update_precomp.py): autogen include statement, do not remove
29 #include "precompiled_sw.hxx"
30 #ifdef SW_DLLIMPLEMENTATION
31 #undef SW_DLLIMPLEMENTATION
32 #endif
33 
34 
35 #include <rsc/rscsfx.hxx>
36 #include <vcl/msgbox.hxx>
37 #include <vcl/help.hxx>
38 #include <svl/stritem.hxx>
39 #include <svl/urihelper.hxx>
40 #include <unotools/pathoptions.hxx>
41 #include <sfx2/request.hxx>
42 #include <sfx2/viewfrm.hxx>
43 #include <sfx2/dispatch.hxx>
44 #include <sfx2/docfile.hxx>
45 #include <svx/dialogs.hrc>
46 #include <svx/svxdlg.hxx>
47 #include <svx/flagsdef.hxx>
48 #include <svx/simptabl.hxx>
49 #include <com/sun/star/ui/dialogs/TemplateDescription.hpp>
50 #include <com/sun/star/ui/dialogs/XFilePicker.hpp>
51 #include <com/sun/star/ui/dialogs/XFilterManager.hpp>
52 #include <svtools/indexentryres.hxx>
53 #include <editeng/unolingu.hxx>
54 #include <column.hxx>
55 #include <fmtfsize.hxx>
56 #include <shellio.hxx>
57 #include <authfld.hxx>
58 #include <swtypes.hxx>
59 #include <wrtsh.hxx>
60 #ifndef _VIEW_HXX
61 #include <view.hxx>
62 #endif
63 #ifndef _BASESH_HXX
64 #include <basesh.hxx>
65 #endif
66 #include <outline.hxx>
67 #include <cnttab.hxx>
68 #include <swuicnttab.hxx>
69 #include <formedt.hxx>
70 #include <poolfmt.hxx>
71 #ifndef _POOLFMT_HRC
72 #include <poolfmt.hrc>
73 #endif
74 #include <uitool.hxx>
75 #include <fmtcol.hxx>
76 #include <fldbas.hxx>
77 #include <expfld.hxx>
78 #include <unotools.hxx>
79 #include <unotxdoc.hxx>
80 #include <docsh.hxx>
81 #include <swmodule.hxx>
82 #include <modcfg.hxx>
83 
84 #ifndef _CMDID_H
85 #include <cmdid.h>
86 #endif
87 #ifndef _HELPID_H
88 #include <helpid.h>
89 #endif
90 #ifndef _UTLUI_HRC
91 #include <utlui.hrc>
92 #endif
93 #ifndef _INDEX_HRC
94 #include <index.hrc>
95 #endif
96 #ifndef _CNTTAB_HRC
97 #include <cnttab.hrc>
98 #endif
99 #ifndef _GLOBALS_HRC
100 #include <globals.hrc>
101 #endif
102 #include <SwStyleNameMapper.hxx>
103 #include <sfx2/filedlghelper.hxx>
104 #ifndef _TOXHLP_HXX
105 #include <toxwrap.hxx>
106 #endif
107 #include <chpfld.hxx>
108 
109 #ifndef _UTLUI_HRC
110 #include "utlui.hrc"
111 #endif
112 
113 #include <sfx2/app.hxx>
114 
115 #include <unomid.h>
116 using namespace ::com::sun::star;
117 using namespace ::com::sun::star::lang;
118 using namespace ::com::sun::star::uno;
119 using namespace com::sun::star::ui::dialogs;
120 using ::rtl::OUString;
121 using namespace ::sfx2;
122 #include <svtools/editbrowsebox.hxx>
123 
124 static const sal_Unicode aDeliStart = '['; //fuer die form
125 static const sal_Unicode aDeliEnd	 = ']'; //fuer die form
126 
127 #define POS_GRF		0
128 #define POS_OLE		1
129 #define POS_TABLE 	2
130 #define POS_FRAME 	3
131 
132 #define IDX_FILE_EXTENSION String::CreateFromAscii( \
133 							RTL_CONSTASCII_STRINGPARAM( "*.sdi" ))
134 
135 
136 /* -----------------14.06.99 13:10-------------------
137 
138  --------------------------------------------------*/
139 String lcl_CreateAutoMarkFileDlg( const String& rURL,
140 								const String& rFileString, sal_Bool bOpen )
141 {
142 	String sRet;
143 
144     FileDialogHelper aDlgHelper( bOpen ?
145                 TemplateDescription::FILEOPEN_SIMPLE : TemplateDescription::FILESAVE_AUTOEXTENSION, 0 );
146     uno::Reference < XFilePicker > xFP = aDlgHelper.GetFilePicker();
147 
148     uno::Reference<XFilterManager> xFltMgr(xFP, UNO_QUERY);
149     String sCurFltr( IDX_FILE_EXTENSION );
150     xFltMgr->appendFilter( rFileString, sCurFltr );
151     xFltMgr->setCurrentFilter( rFileString ) ;
152 
153 	String& rLastSaveDir = (String&)SFX_APP()->GetLastSaveDirectory();
154 	String sSaveDir = rLastSaveDir;
155 
156 	if( rURL.Len() )
157         xFP->setDisplayDirectory( rURL );
158 	else
159 	{
160 		SvtPathOptions aPathOpt;
161         xFP->setDisplayDirectory( aPathOpt.GetUserConfigPath() );
162 	}
163 
164     if( aDlgHelper.Execute() == ERRCODE_NONE )
165     {
166         sRet = xFP->getFiles().getConstArray()[0];
167     }
168 	rLastSaveDir = sSaveDir;
169 	return sRet;
170 }
171 /* -----------------------------19.01.00 11:09--------------------------------
172 
173  ---------------------------------------------------------------------------*/
174 struct AutoMarkEntry
175 {
176 	String sSearch;
177 	String sAlternative;
178 	String sPrimKey;
179 	String sSecKey;
180 	String sComment;
181 	sal_Bool 	bCase;
182 	sal_Bool 	bWord;
183 
184 	AutoMarkEntry() :
185 		bCase(sal_False),
186 		bWord(sal_False){}
187 };
188 typedef AutoMarkEntry* AutoMarkEntryPtr;
189 SV_DECL_PTRARR_DEL(AutoMarkEntryArr, AutoMarkEntryPtr, 0, 4)
190 SV_IMPL_PTRARR(AutoMarkEntryArr, AutoMarkEntryPtr);
191 
192 typedef ::svt::EditBrowseBox SwEntryBrowseBox_Base;
193 class SwEntryBrowseBox : public SwEntryBrowseBox_Base
194 {
195 	Edit 					aCellEdit;
196 	::svt::CheckBoxControl 	aCellCheckBox;
197 
198 	String 	sSearch;
199 	String 	sAlternative;
200 	String 	sPrimKey;
201 	String 	sSecKey;
202 	String 	sComment;
203 	String 	sCaseSensitive;
204 	String 	sWordOnly;
205 	String 	sYes;
206 	String 	sNo;
207 
208 	AutoMarkEntryArr	aEntryArr;
209 
210 	::svt::CellControllerRef	xController;
211 	::svt::CellControllerRef	xCheckController;
212 
213 	long 	nCurrentRow;
214 	sal_Bool	bModified;
215 
216 
217 	void						SetModified() {bModified = sal_True;}
218 
219 protected:
220 	virtual sal_Bool    			SeekRow( long nRow );
221 //	virtual void    			PaintField( OutputDevice& rDev, const awt::Rectangle& rRect,
222 //											sal_uInt16 nColumnId ) const;
223 	virtual void 					PaintCell(OutputDevice& rDev, const Rectangle& rRect, sal_uInt16 nColId) const;
224 	virtual void 					InitController(::svt::CellControllerRef& rController, long nRow, sal_uInt16 nCol);
225 	virtual ::svt::CellController* 	GetController(long nRow, sal_uInt16 nCol);
226 	virtual sal_Bool 				SaveModified();
227 
228 public:
229 					SwEntryBrowseBox(Window* pParent, const ResId& rId,
230 							   BrowserMode nMode = 0 );
231 	void	ReadEntries(SvStream& rInStr);
232 	void	WriteEntries(SvStream& rOutStr);
233 
234 	sal_Bool						IsModified()const;
235 
236     virtual String GetCellText( long nRow, sal_uInt16 nColumn ) const;
237 };
238 
239 class SwAutoMarkDlg_Impl : public ModalDialog
240 {
241 	OKButton 			aOKPB;
242 	CancelButton 		aCancelPB;
243 	HelpButton			aHelpPB;
244 
245 	SwEntryBrowseBox	aEntriesBB;
246     FixedLine           aEntriesFL;
247 
248 	String 				sAutoMarkURL;
249 	const String 		sAutoMarkType;
250 
251 	sal_Bool				bCreateMode;
252 
253 	DECL_LINK(OkHdl, OKButton*);
254 public:
255 	SwAutoMarkDlg_Impl(Window* pParent, const String& rAutoMarkURL,
256 						const String& rAutoMarkType, sal_Bool bCreate);
257 	~SwAutoMarkDlg_Impl();
258 
259 };
260 /* -----------------04.11.99 11:02-------------------
261 
262  --------------------------------------------------*/
263 sal_uInt16 CurTOXType::GetFlatIndex() const
264 {
265     sal_uInt16 nRet = static_cast< sal_uInt16 >(eType);
266 	if(eType == TOX_USER && nIndex)
267 	{
268         nRet = static_cast< sal_uInt16 >(TOX_AUTHORITIES + nIndex);
269 	}
270 	return nRet;
271 }
272 /*************************************************************************
273 
274 *************************************************************************/
275 #define EDIT_MINWIDTH 15
276 
277 /* -----------------14.06.99 12:12-------------------
278 
279  --------------------------------------------------*/
280 SwMultiTOXTabDialog::SwMultiTOXTabDialog(Window* pParent, const SfxItemSet& rSet,
281 					SwWrtShell &rShell,
282 					SwTOXBase* pCurTOX,
283 					sal_uInt16 nToxType, sal_Bool bGlobal) :
284 		SfxTabDialog(	pParent, SW_RES(DLG_MULTI_TOX), &rSet),
285 		aExampleContainerWIN(this, SW_RES(WIN_EXAMPLE)),
286         aExampleWIN( &aExampleContainerWIN, 0 ),
287         aShowExampleCB( this, SW_RES(CB_SHOWEXAMPLE)),
288         pMgr( new SwTOXMgr( &rShell ) ),
289         rSh(rShell),
290         pExampleFrame(0),
291         pParamTOXBase(pCurTOX),
292         sUserDefinedIndex(SW_RES(ST_USERDEFINEDINDEX)),
293 		nInitialTOXType(nToxType),
294 
295         bEditTOX(sal_False),
296 		bExampleCreated(sal_False),
297 		bGlobalFlag(bGlobal)
298 {
299 	FreeResource();
300 
301 	aExampleWIN.SetPosSizePixel(aExampleContainerWIN.GetPosPixel(),
302 								aExampleContainerWIN.GetSizePixel());
303 
304     eCurrentTOXType.eType = TOX_CONTENT;
305 	eCurrentTOXType.nIndex = 0;
306 
307 	sal_uInt16 nUserTypeCount = rSh.GetTOXTypeCount(TOX_USER);
308 	nTypeCount = nUserTypeCount + 6;
309 	pFormArr = new SwForm*[nTypeCount];
310 	pDescArr = new SwTOXDescription*[nTypeCount];
311 	pxIndexSectionsArr = new SwIndexSections_Impl*[nTypeCount];
312 	//the standard user index is on position TOX_USER
313 	//all user user indexes follow after position TOX_AUTHORITIES
314 	if(pCurTOX)
315 	{
316 		bEditTOX = sal_True;
317 	}
318 	for(int i = nTypeCount - 1; i > -1; i--)
319 	{
320 		pFormArr[i] = 0;
321 		pDescArr[i] = 0;
322 		pxIndexSectionsArr[i] = new SwIndexSections_Impl;
323 		if(pCurTOX)
324 		{
325 			eCurrentTOXType.eType = pCurTOX->GetType();
326             sal_uInt16 nArrayIndex = static_cast< sal_uInt16 >(eCurrentTOXType.eType);
327 			if(eCurrentTOXType.eType == TOX_USER)
328 			{
329 				//which user type is it?
330 				for(sal_uInt16 nUser = 0; nUser < nUserTypeCount; nUser++)
331 				{
332 					const SwTOXType* pTemp = rSh.GetTOXType(TOX_USER, nUser);
333 					if(pCurTOX->GetTOXType() == pTemp)
334 					{
335 						eCurrentTOXType.nIndex = nUser;
336                         nArrayIndex = static_cast< sal_uInt16 >(nUser > 0 ? TOX_AUTHORITIES + nUser : TOX_USER);
337 						break;
338 					}
339 				}
340 			}
341 			pFormArr[nArrayIndex] = new SwForm(pCurTOX->GetTOXForm());
342 			pDescArr[nArrayIndex] = CreateTOXDescFromTOXBase(pCurTOX);
343 			if(TOX_AUTHORITIES == eCurrentTOXType.eType)
344 			{
345 				const SwAuthorityFieldType* pFType = (const SwAuthorityFieldType*)
346 												rSh.GetFldType(RES_AUTHORITY, aEmptyStr);
347 				if(pFType)
348 				{
349 					String sBrackets;
350                     if(pFType->GetPrefix())
351 						sBrackets += pFType->GetPrefix();
352 					if(pFType->GetSuffix())
353 						sBrackets += pFType->GetSuffix();
354 					pDescArr[nArrayIndex]->SetAuthBrackets(sBrackets);
355 					pDescArr[nArrayIndex]->SetAuthSequence(pFType->IsSequence());
356 				}
357 				else
358 				{
359 					pDescArr[nArrayIndex]->SetAuthBrackets(C2S("[]"));
360 				}
361 			}
362 		}
363 	}
364     SfxAbstractDialogFactory* pFact = SfxAbstractDialogFactory::Create();
365     DBG_ASSERT(pFact, "Dialogdiet fail!");
366 	AddTabPage(TP_TOX_SELECT, SwTOXSelectTabPage::Create, 0);
367 	AddTabPage(TP_TOX_STYLES, SwTOXStylesTabPage::Create, 0);
368 	AddTabPage(TP_COLUMN,	SwColumnPage::Create,  	 0);
369     AddTabPage(TP_BACKGROUND, pFact->GetTabPageCreatorFunc( RID_SVXPAGE_BACKGROUND ),  0 );
370 	AddTabPage(TP_TOX_ENTRY, SwTOXEntryTabPage::Create, 	0);
371 	if(!pCurTOX)
372 		SetCurPageId(TP_TOX_SELECT);
373 
374 	aShowExampleCB.SetClickHdl(LINK(this, SwMultiTOXTabDialog, ShowPreviewHdl));
375 
376 	aShowExampleCB.Check( SW_MOD()->GetModuleConfig()->IsShowIndexPreview());
377 
378 	aExampleContainerWIN.SetAccessibleName(aShowExampleCB.GetText());
379     SetViewAlign( WINDOWALIGN_LEFT );
380 	// SetViewWindow does not work if the dialog is visible!
381 
382     if(!aShowExampleCB.IsChecked())
383         SetViewWindow( &aExampleContainerWIN );
384 
385     Point aOldPos = GetPosPixel();
386 	ShowPreviewHdl(0);
387  	Point aNewPos = GetPosPixel();
388 	//72040: initial position may be left of the view - that has to be corrected
389 	if(aNewPos.X() < 0)
390 		SetPosPixel(aOldPos);
391 }
392 /*-- 14.06.99 13:11:40---------------------------------------------------
393 
394   -----------------------------------------------------------------------*/
395 SwMultiTOXTabDialog::~SwMultiTOXTabDialog()
396 {
397 	SW_MOD()->GetModuleConfig()->SetShowIndexPreview(aShowExampleCB.IsChecked());
398 
399 	for(sal_uInt16 i = 0; i < nTypeCount; i++)
400 	{
401 		delete pFormArr[i];
402 		delete pDescArr[i];
403 		delete pxIndexSectionsArr[i];
404 	}
405     delete[] pxIndexSectionsArr;
406 
407     delete[] pFormArr;
408     delete[] pDescArr;
409 	delete pMgr;
410 	delete pExampleFrame;
411 }
412 /*-- 14.06.99 13:11:40---------------------------------------------------
413 
414   -----------------------------------------------------------------------*/
415 void	SwMultiTOXTabDialog::PageCreated( sal_uInt16 nId, SfxTabPage &rPage )
416 {
417 	if( TP_BACKGROUND == nId  )
418     {
419 		SfxAllItemSet aSet(*(GetInputSetImpl()->GetPool()));
420 		aSet.Put (SfxUInt32Item(SID_FLAG_TYPE, SVX_SHOW_SELECTOR));
421 		rPage.PageCreated(aSet);
422 	}
423 	else if(TP_COLUMN == nId )
424 	{
425 		const SwFmtFrmSize& rSize = (const SwFmtFrmSize&)GetInputSetImpl()->Get(RES_FRM_SIZE);
426 
427 		((SwColumnPage&)rPage).SetPageWidth(rSize.GetWidth());
428 	}
429 	else if(TP_TOX_ENTRY == nId)
430 		((SwTOXEntryTabPage&)rPage).SetWrtShell(rSh);
431 	if(TP_TOX_SELECT == nId)
432 	{
433 		((SwTOXSelectTabPage&)rPage).SetWrtShell(rSh);
434 		if(USHRT_MAX != nInitialTOXType)
435 			((SwTOXSelectTabPage&)rPage).SelectType((TOXTypes)nInitialTOXType);
436 	}
437 }
438 /*-- 14.06.99 13:11:40---------------------------------------------------
439 
440   -----------------------------------------------------------------------*/
441 short	SwMultiTOXTabDialog::Ok()
442 {
443 	short nRet = SfxTabDialog::Ok();
444 	SwTOXDescription& rDesc = GetTOXDescription(eCurrentTOXType);
445 	SwTOXBase aNewDef(*rSh.GetDefaultTOXBase( eCurrentTOXType.eType, sal_True ));
446 
447     sal_uInt16 nIndex = static_cast< sal_uInt16 >(eCurrentTOXType.eType);
448 	if(eCurrentTOXType.eType == TOX_USER && eCurrentTOXType.nIndex)
449 	{
450         nIndex =  static_cast< sal_uInt16 >(TOX_AUTHORITIES + eCurrentTOXType.nIndex);
451 	}
452 
453 	if(pFormArr[nIndex])
454 	{
455 		rDesc.SetForm(*pFormArr[nIndex]);
456 		aNewDef.SetTOXForm(*pFormArr[nIndex]);
457 	}
458 	rDesc.ApplyTo(aNewDef);
459 	if(!bGlobalFlag)
460 		pMgr->UpdateOrInsertTOX(
461 				rDesc, 0, GetOutputItemSet());
462 	else if(bEditTOX)
463 		pMgr->UpdateOrInsertTOX(
464 				rDesc, &pParamTOXBase, GetOutputItemSet());
465 
466 	if(!eCurrentTOXType.nIndex)
467 		rSh.SetDefaultTOXBase(aNewDef);
468 
469 	return nRet;
470 }
471 /* -----------------16.06.99 11:59-------------------
472 
473  --------------------------------------------------*/
474 SwForm* SwMultiTOXTabDialog::GetForm(CurTOXType eType)
475 {
476 	sal_uInt16 nIndex = eType.GetFlatIndex();
477 	if(!pFormArr[nIndex])
478 		pFormArr[nIndex] = new SwForm(eType.eType);
479 	return pFormArr[nIndex];
480 }
481 /* -----------------09.09.99 11:29-------------------
482 
483  --------------------------------------------------*/
484 SwTOXDescription&	SwMultiTOXTabDialog::GetTOXDescription(CurTOXType eType)
485 {
486 	sal_uInt16 nIndex = eType.GetFlatIndex();
487 	if(!pDescArr[nIndex])
488 	{
489 		const SwTOXBase* pDef = rSh.GetDefaultTOXBase( eType.eType );
490 		if(pDef)
491 			pDescArr[nIndex] = CreateTOXDescFromTOXBase(pDef);
492 		else
493 		{
494 			pDescArr[nIndex] = new SwTOXDescription(eType.eType);
495 			if(eType.eType == TOX_USER)
496 				pDescArr[nIndex]->SetTitle(sUserDefinedIndex);
497 			else
498 				pDescArr[nIndex]->SetTitle(
499 					rSh.GetTOXType(eType.eType, 0)->GetTypeName());
500 		}
501 		if(TOX_AUTHORITIES == eType.eType)
502 		{
503 			const SwAuthorityFieldType* pFType = (const SwAuthorityFieldType*)
504 											rSh.GetFldType(RES_AUTHORITY, aEmptyStr);
505 			if(pFType)
506 			{
507 				String sBrackets(pFType->GetPrefix());
508 				sBrackets += pFType->GetSuffix();
509 				pDescArr[nIndex]->SetAuthBrackets(sBrackets);
510 				pDescArr[nIndex]->SetAuthSequence(pFType->IsSequence());
511 			}
512 			else
513 			{
514 				pDescArr[nIndex]->SetAuthBrackets(C2S("[]"));
515 			}
516 		}
517         else if(TOX_INDEX == eType.eType)
518             pDescArr[nIndex]->SetMainEntryCharStyle(SW_RESSTR(STR_POOLCHR_IDX_MAIN_ENTRY));
519 
520 	}
521 	return *pDescArr[nIndex];
522 }
523 /* -----------------09.09.99 11:36-------------------
524 
525  --------------------------------------------------*/
526 SwTOXDescription* SwMultiTOXTabDialog::CreateTOXDescFromTOXBase(
527 			const SwTOXBase*pCurTOX)
528 {
529 	SwTOXDescription * pDesc = new SwTOXDescription(pCurTOX->GetType());
530 	for(sal_uInt16 i = 0; i < MAXLEVEL; i++)
531 		pDesc->SetStyleNames(pCurTOX->GetStyleNames(i), i);
532 	pDesc->SetAutoMarkURL(rSh.GetTOIAutoMarkURL());
533 	pDesc->SetTitle(pCurTOX->GetTitle());
534 
535 
536 	pDesc->SetContentOptions(pCurTOX->GetCreateType());
537 	if(pDesc->GetTOXType() == TOX_INDEX)
538 		pDesc->SetIndexOptions(pCurTOX->GetOptions());
539 	pDesc->SetMainEntryCharStyle(pCurTOX->GetMainEntryCharStyle());
540 	if(pDesc->GetTOXType() != TOX_INDEX)
541         pDesc->SetLevel((sal_uInt8)pCurTOX->GetLevel());
542 	pDesc->SetCreateFromObjectNames(pCurTOX->IsFromObjectNames());
543 	pDesc->SetSequenceName(pCurTOX->GetSequenceName());
544 	pDesc->SetCaptionDisplay(pCurTOX->GetCaptionDisplay());
545 	pDesc->SetFromChapter(pCurTOX->IsFromChapter());
546 	pDesc->SetReadonly(pCurTOX->IsProtected());
547 	pDesc->SetOLEOptions(pCurTOX->GetOLEOptions());
548 	pDesc->SetLevelFromChapter(pCurTOX->IsLevelFromChapter());
549     pDesc->SetLanguage(pCurTOX->GetLanguage());
550     pDesc->SetSortAlgorithm(pCurTOX->GetSortAlgorithm());
551 	return pDesc;
552 }
553 
554 /* -----------------------------29.12.99 09:53--------------------------------
555 
556  ---------------------------------------------------------------------------*/
557 
558 IMPL_LINK( SwMultiTOXTabDialog, ShowPreviewHdl, CheckBox *, pBox )
559 {
560 	if(aShowExampleCB.IsChecked())
561 	{
562 		if(!pExampleFrame && !bExampleCreated)
563 		{
564 			bExampleCreated = sal_True;
565 			String sTemplate( String::CreateFromAscii(
566 								RTL_CONSTASCII_STRINGPARAM("internal")) );
567 			sTemplate += INET_PATH_TOKEN;
568 			sTemplate.AppendAscii( RTL_CONSTASCII_STRINGPARAM("idxexample") );
569 			String sTemplateWithoutExt( sTemplate );
570 #ifndef MAC_WITHOUT_EXT
571             sTemplate.AppendAscii( RTL_CONSTASCII_STRINGPARAM(".odt") );
572 #endif
573 
574 			SvtPathOptions aOpt;
575 			// 6.0 (extension .sxw)
576 			sal_Bool bExist = aOpt.SearchFile( sTemplate, SvtPathOptions::PATH_TEMPLATE );
577 
578 #ifndef MAC_WITHOUT_EXT
579             if( !bExist )
580             {
581                 // 6.0 (extension .sxw)
582                 sTemplate = sTemplateWithoutExt;
583                 sTemplate.AppendAscii( RTL_CONSTASCII_STRINGPARAM(".sxw") );
584                 bExist = aOpt.SearchFile( sTemplate, SvtPathOptions::PATH_TEMPLATE );
585             }
586             if( !bExist )
587 			{
588 				// 5.0 (extension .vor)
589 				sTemplate = sTemplateWithoutExt;
590 				sTemplate.AppendAscii( RTL_CONSTASCII_STRINGPARAM(".sdw") );
591 				bExist = aOpt.SearchFile( sTemplate, SvtPathOptions::PATH_TEMPLATE );
592 			}
593 #endif
594 
595 			if(!bExist)
596 			{
597 				String sInfo(SW_RES(STR_FILE_NOT_FOUND));
598 				sInfo.SearchAndReplaceAscii( "%1", sTemplate );
599 				sInfo.SearchAndReplaceAscii( "%2", aOpt.GetTemplatePath() );
600 				InfoBox aInfo(GetParent(), sInfo);
601 				aInfo.Execute();
602 			}
603 			else
604 			{
605 				Link aLink(LINK(this, SwMultiTOXTabDialog, CreateExample_Hdl));
606 				pExampleFrame = new SwOneExampleFrame(
607 						aExampleWIN, EX_SHOW_ONLINE_LAYOUT, &aLink, &sTemplate);
608 
609 				if(!pExampleFrame->IsServiceAvailable())
610 				{
611 					pExampleFrame->CreateErrorMessage(0);
612 				}
613 			}
614 			aShowExampleCB.Show(pExampleFrame && pExampleFrame->IsServiceAvailable());
615 		}
616 	}
617 	sal_Bool bSetViewWindow = aShowExampleCB.IsChecked()
618         && pExampleFrame && pExampleFrame->IsServiceAvailable();
619 
620     aExampleContainerWIN.Show( bSetViewWindow );
621     SetViewWindow( bSetViewWindow ? &aExampleContainerWIN  : 0 );
622 
623 	Window *pTopmostParent = this;
624 	while(pTopmostParent->GetParent())
625 		pTopmostParent = pTopmostParent->GetParent();
626     ::Rectangle aRect(GetClientWindowExtentsRelative(pTopmostParent));
627     ::Point aPos = aRect.TopLeft();
628     Size aSize = GetSizePixel();
629 	if(pBox)
630 		AdjustLayout();
631 	long nDiffWidth = GetSizePixel().Width() - aSize.Width();
632 	aPos.X() -= nDiffWidth;
633 	SetPosPixel(aPos);
634 
635 	return 0;
636 }
637 
638 
639 /* -----------------05.07.99 09:49-------------------
640 
641  --------------------------------------------------*/
642 sal_Bool SwMultiTOXTabDialog::IsNoNum(SwWrtShell& rSh, const String& rName)
643 {
644 	SwTxtFmtColl* pColl = rSh.GetParaStyle(rName);
645 	//if(pColl && pColl->GetOutlineLevel() == NO_NUMBERING)		//#outline level,zhaojianwei
646 	if(pColl && ! pColl->IsAssignedToListLevelOfOutlineStyle())	//<-end,zhaojianwei
647 		return sal_True;
648 
649 	sal_uInt16 nId = SwStyleNameMapper::GetPoolIdFromUIName(rName, nsSwGetPoolIdFromName::GET_POOLID_TXTCOLL);
650 	if(nId != USHRT_MAX &&
651 		//rSh.GetTxtCollFromPool(nId)->GetOutlineLevel() == NO_NUMBERING)		//#outline level,zhaojianwei
652 		! rSh.GetTxtCollFromPool(nId)->IsAssignedToListLevelOfOutlineStyle())	//<-end,zhaojianwei
653 		return sal_True;
654 
655 	return sal_False;
656 }
657 /* -----------------14.07.99 16:01-------------------
658 
659  --------------------------------------------------*/
660 class SwIndexTreeLB : public SvTreeListBox
661 {
662 	const HeaderBar* pHeaderBar;
663 public:
664 	SwIndexTreeLB(Window* pWin, const ResId& rResId) :
665 		SvTreeListBox(pWin, rResId), pHeaderBar(0){}
666 
667 	virtual void	KeyInput( const KeyEvent& rKEvt );
668 	virtual long    GetTabPos( SvLBoxEntry*, SvLBoxTab* );
669 	void			SetHeaderBar(const HeaderBar* pHB) {pHeaderBar = pHB;}
670 };
671 /* -----------------14.07.99 16:03-------------------
672 
673  --------------------------------------------------*/
674 long  SwIndexTreeLB::GetTabPos( SvLBoxEntry* pEntry, SvLBoxTab* pTab)
675 {
676 	long nData = (long)pEntry->GetUserData();
677 	if(nData != USHRT_MAX)
678 	{
679         long  nPos = pHeaderBar->GetItemRect( static_cast< sal_uInt16 >(101 + nData) ).TopLeft().X();
680 		nData = nPos;
681 	}
682 	else
683 		nData = 0;
684 	nData += pTab->GetPos();
685 	return nData;
686 }
687 /* -----------------25.08.99 11:14-------------------
688 
689  --------------------------------------------------*/
690 void	SwIndexTreeLB::KeyInput( const KeyEvent& rKEvt )
691 {
692 	SvLBoxEntry* pEntry = FirstSelected();
693 	KeyCode aCode = rKEvt.GetKeyCode();
694 	sal_Bool bChanged = sal_False;
695 	if(pEntry)
696     {
697 		long nLevel = (long)pEntry->GetUserData();
698 		if(aCode.GetCode() == KEY_ADD )
699 		{
700 			if(nLevel < MAXLEVEL - 1)
701 				nLevel++;
702 			else if(nLevel == USHRT_MAX)
703 				nLevel = 0;
704 			bChanged = sal_True;
705 		}
706 		else if(aCode.GetCode() == KEY_SUBTRACT)
707 		{
708 			if(!nLevel)
709 				nLevel = USHRT_MAX;
710 			else if(nLevel != USHRT_MAX)
711 				nLevel--;
712 			bChanged = sal_True;
713 		}
714 		if(bChanged)
715 		{
716 			pEntry->SetUserData((void*)nLevel);
717 			Invalidate();
718 		}
719 	}
720 	if(!bChanged)
721 		SvTreeListBox::KeyInput(rKEvt);
722 }
723 
724 /* -----------------16.07.99 10:01-------------------
725 
726  --------------------------------------------------*/
727 class SwHeaderTree : public Control
728 {
729 	HeaderBar		aStylesHB;
730 	SwIndexTreeLB 	aStylesTLB;
731 
732 public:
733 	SwHeaderTree(Window* pParent, const ResId rResId);
734 
735 	HeaderBar&		GetHeaderBar() {return aStylesHB;}
736 	SwIndexTreeLB& 	GetTreeListBox() { return aStylesTLB;}
737 
738 	virtual void	GetFocus();
739 };
740 /* -----------------16.07.99 10:11-------------------
741 
742  --------------------------------------------------*/
743 SwHeaderTree::SwHeaderTree(Window* pParent, const ResId rResId) :
744 		Control(pParent, rResId),
745         aStylesHB(  this, ResId(HB_STYLES, *rResId.GetResMgr())),
746         aStylesTLB( this, ResId(TLB_STYLES, *rResId.GetResMgr()))
747 {
748 	FreeResource();
749 	aStylesHB.SetStyle(aStylesHB.GetStyle()|WB_BUTTONSTYLE|WB_TABSTOP|WB_BORDER);
750  	Size aHBSize(aStylesHB.GetSizePixel());
751 	aHBSize.Height() = aStylesHB.CalcWindowSizePixel().Height();
752 	aStylesHB.SetSizePixel(aHBSize);
753 	aStylesTLB.SetPosPixel(Point(0, aHBSize.Height()));
754  	Size aTLBSize(aStylesHB.GetSizePixel());
755 	aTLBSize.Height() = GetOutputSizePixel().Height() - aHBSize.Height();
756 	aStylesTLB.SetSizePixel(aTLBSize);
757 	aStylesTLB.SetHeaderBar(&aStylesHB);
758 }
759 /* -----------------25.08.99 10:38-------------------
760 
761  --------------------------------------------------*/
762 void	SwHeaderTree::GetFocus()
763 {
764 	Control::GetFocus();
765 	aStylesTLB.GrabFocus();
766 }
767 /* -----------------13.07.99 15:29-------------------
768 
769  --------------------------------------------------*/
770 class SwAddStylesDlg_Impl : public SfxModalDialog
771 {
772 	OKButton		aOk;
773 	CancelButton	aCancel;
774 	HelpButton 		aHelp;
775 
776     FixedLine       aStylesFL;
777 	SwHeaderTree	aHeaderTree;
778     ImageButton     aLeftPB;
779     ImageButton      aRightPB;
780 
781 	String 			sHBFirst;
782 	String*			pStyleArr;
783 
784 	DECL_LINK(OkHdl, OKButton*);
785 	DECL_LINK(LeftRightHdl, PushButton*);
786 	DECL_LINK(HeaderDragHdl, HeaderBar*);
787 
788 public:
789 	SwAddStylesDlg_Impl(Window* pParent, SwWrtShell& rWrtSh, String rStringArr[]);
790 	~SwAddStylesDlg_Impl();
791 };
792 /* -----------------13.07.99 15:39-------------------
793 
794  --------------------------------------------------*/
795 SwAddStylesDlg_Impl::SwAddStylesDlg_Impl(Window* pParent,
796 			SwWrtShell& rWrtSh, String rStringArr[]) :
797 	SfxModalDialog(pParent, SW_RES(DLG_ADD_IDX_STYLES)),
798     aOk(        this, SW_RES(PB_OK      )),
799     aCancel(    this, SW_RES(PB_CANCEL  )),
800     aHelp(      this, SW_RES(PB_HELP        )),
801 
802     aStylesFL(  this, SW_RES(FL_STYLES   )),
803     aHeaderTree(this, SW_RES(TR_HEADER   )),
804     aLeftPB(    this, SW_RES(PB_LEFT     )),
805     aRightPB(   this, SW_RES(PB_RIGHT    )),
806 
807     sHBFirst(   SW_RES(ST_HB_FIRST)),
808     pStyleArr(rStringArr)
809 {
810 	FreeResource();
811 
812 	aHeaderTree.SetAccessibleRelationMemberOf(&aStylesFL);
813 	aLeftPB.SetAccessibleRelationMemberOf(&aStylesFL);
814 	aRightPB.SetAccessibleRelationMemberOf(&aStylesFL);
815 
816 	aLeftPB.SetModeImage( Image( SW_RES( IMG_ALL_LEFT_HC ) ), BMP_COLOR_HIGHCONTRAST );
817 	aRightPB.SetModeImage( Image( SW_RES( IMG_ALL_RIGHT_HC ) ), BMP_COLOR_HIGHCONTRAST );
818 
819 	aOk.SetClickHdl(LINK(this, SwAddStylesDlg_Impl, OkHdl));
820 	aLeftPB.SetClickHdl(LINK(this, SwAddStylesDlg_Impl, LeftRightHdl));
821 	aRightPB.SetClickHdl(LINK(this, SwAddStylesDlg_Impl, LeftRightHdl));
822 
823 	HeaderBar& rHB = aHeaderTree.GetHeaderBar();
824 	rHB.SetEndDragHdl(LINK(this, SwAddStylesDlg_Impl, HeaderDragHdl));
825 
826 	long nWidth = rHB.GetSizePixel().Width();
827 	sal_uInt16 i;
828 
829 	nWidth /= 14;
830 	nWidth--;
831 	rHB.InsertItem( 100, sHBFirst,	4 * nWidth );
832 	for( i = 1; i <= MAXLEVEL; i++)
833 		rHB.InsertItem( 100 + i, String::CreateFromInt32(i), nWidth );
834 	rHB.Show();
835 
836 	SwIndexTreeLB& rTLB = aHeaderTree.GetTreeListBox();
837 	rTLB.SetStyle(rTLB.GetStyle()|WB_CLIPCHILDREN|WB_SORT);
838 	//aStylesTLB.SetSelectHdl(LINK(this, SwAddStylesDlg_Impl, SelectHdl));
839 	rTLB.GetModel()->SetSortMode(SortAscending);
840 	for(i = 0; i < MAXLEVEL; ++i)
841 	{
842 		String sStyles(rStringArr[i]);
843 		for(sal_uInt16 nToken = 0; nToken < sStyles.GetTokenCount(TOX_STYLE_DELIMITER); nToken++)
844 		{
845 			String sTmp(sStyles.GetToken(nToken, TOX_STYLE_DELIMITER));
846 			SvLBoxEntry* pEntry = rTLB.InsertEntry(sTmp);
847             pEntry->SetUserData(reinterpret_cast<void*>(i));
848 		}
849 	}
850 	// now the other styles
851 	//
852 	const SwTxtFmtColl *pColl 	= 0;
853 	const sal_uInt16 nSz = rWrtSh.GetTxtFmtCollCount();
854 
855 	for ( sal_uInt16 j = 0;j < nSz; ++j )
856 	{
857 		pColl = &rWrtSh.GetTxtFmtColl(j);
858 		if(pColl->IsDefault())
859 			continue;
860 
861 		const String& rName = pColl->GetName();
862 
863 		if(rName.Len() > 0)
864 		{
865 			SvLBoxEntry* pEntry = rTLB.First();
866 			sal_Bool bFound = sal_False;
867 			while(pEntry && !bFound)
868 			{
869 				if(rTLB.GetEntryText(pEntry) == rName)
870 					bFound = sal_True;
871 				pEntry = rTLB.Next(pEntry);
872 			}
873 			if(!bFound)
874 			{
875 				rTLB.InsertEntry(rName)->SetUserData((void*)USHRT_MAX);
876 			}
877 		}
878 	}
879 	rTLB.GetModel()->Resort();
880 }
881 
882 /* -----------------13.07.99 15:39-------------------
883 
884  --------------------------------------------------*/
885 SwAddStylesDlg_Impl::~SwAddStylesDlg_Impl()
886 {
887 }
888 /* -----------------13.07.99 15:39-------------------
889 
890  --------------------------------------------------*/
891 IMPL_LINK(SwAddStylesDlg_Impl, OkHdl, OKButton*, EMPTYARG)
892 {
893 	for(sal_uInt16 i = 0; i < MAXLEVEL; i++)
894 		pStyleArr[i].Erase();
895 
896 	SwIndexTreeLB& rTLB = aHeaderTree.GetTreeListBox();
897 	SvLBoxEntry* pEntry = rTLB.First();
898 	while(pEntry)
899 	{
900 		long nLevel = (long)pEntry->GetUserData();
901 		if(nLevel != USHRT_MAX)
902 		{
903 			String sName(rTLB.GetEntryText(pEntry));
904 			if(pStyleArr[nLevel].Len())
905 				pStyleArr[nLevel] += TOX_STYLE_DELIMITER;
906 			pStyleArr[nLevel] += sName;
907 		}
908 		pEntry = rTLB.Next(pEntry);
909 	}
910 
911 	//TODO write back style names
912 	EndDialog(RET_OK);
913 	return 0;
914 }
915 /* -----------------16.07.99 09:27-------------------
916 
917  --------------------------------------------------*/
918 IMPL_LINK(SwAddStylesDlg_Impl, HeaderDragHdl, HeaderBar*, EMPTYARG)
919 {
920 	aHeaderTree.GetTreeListBox().Invalidate();
921 	return 0;
922 }
923 /* -----------------13.07.99 15:39-------------------
924 
925  --------------------------------------------------*/
926 IMPL_LINK(SwAddStylesDlg_Impl, LeftRightHdl, PushButton*, pBtn)
927 {
928 	sal_Bool bLeft = pBtn == &aLeftPB;
929 	SvLBoxEntry* pEntry = aHeaderTree.GetTreeListBox().FirstSelected();
930 	if(pEntry)
931 	{
932 		long nLevel = (long)pEntry->GetUserData();
933 		if(bLeft)
934 		{
935 			if(!nLevel)
936 				nLevel = USHRT_MAX;
937 			else if(nLevel != USHRT_MAX)
938 				nLevel--;
939 		}
940 		else
941 		{
942 			if(nLevel < MAXLEVEL - 1)
943 				nLevel++;
944 			else if(nLevel == USHRT_MAX)
945 				nLevel = 0;
946 		}
947 		pEntry->SetUserData((void*)nLevel);
948 		aHeaderTree.GetTreeListBox().Invalidate();
949 	}
950 	return 0;
951 }
952 
953 /*-- 14.06.99 13:11:40---------------------------------------------------
954 
955   -----------------------------------------------------------------------*/
956 SwTOXSelectTabPage::SwTOXSelectTabPage(Window* pParent, const SfxItemSet& rAttrSet) :
957 	SfxTabPage(pParent, SW_RES(TP_TOX_SELECT), rAttrSet),
958 
959     aTypeTitleFL(       this, SW_RES(FL_TYPETITLE        )),
960     aTitleFT(           this, SW_RES(FT_TITLE            )),
961     aTitleED(           this, SW_RES(ED_TITLE           )),
962     aTypeFT(            this, SW_RES(FT_TYPE                )),
963     aTypeLB(            this, SW_RES(LB_TYPE                )),
964     aReadOnlyCB(        this, SW_RES(CB_READONLY            )),
965 
966     aAreaFL(            this, SW_RES(FL_AREA             )),
967     aAreaFT(            this, SW_RES(FT_AREA             )),
968     aAreaLB(            this, SW_RES(LB_AREA                )),
969     aLevelFT(           this, SW_RES(FT_LEVEL           )),
970     aLevelNF(           this, SW_RES(NF_LEVEL           )),
971 
972     aCreateFromFL(      this, SW_RES(FL_CREATEFROM       )),
973     aFromHeadingsCB(    this, SW_RES(CB_FROMHEADINGS     )),
974 //   aChapterDlgPB(      this, SW_RES(PB_CHAPTERDLG      )),//#outline level,removed by zhaojianwei
975     aAddStylesCB(       this, SW_RES(CB_ADDSTYLES       )),
976     aAddStylesPB(       this, SW_RES(PB_ADDSTYLES       )),
977 
978     aFromTablesCB(      this, SW_RES(CB_FROMTABLES       )),
979     aFromFramesCB(      this, SW_RES(CB_FROMFRAMES      )),
980     aFromGraphicsCB(    this, SW_RES(CB_FROMGRAPHICS        )),
981     aFromOLECB(         this, SW_RES(CB_FROMOLE         )),
982     aLevelFromChapterCB(this, SW_RES(CB_LEVELFROMCHAPTER    )),
983 
984     aFromCaptionsRB(    this, SW_RES(RB_FROMCAPTIONS     )),
985     aFromObjectNamesRB( this, SW_RES(RB_FROMOBJECTNAMES )),
986 
987     aCaptionSequenceFT( this, SW_RES(FT_CAPTIONSEQUENCE  )),
988     aCaptionSequenceLB( this, SW_RES(LB_CAPTIONSEQUENCE  )),
989     aDisplayTypeFT(     this, SW_RES(FT_DISPLAYTYPE     )),
990     aDisplayTypeLB(     this, SW_RES(LB_DISPLAYTYPE     )),
991 
992     aTOXMarksCB(        this, SW_RES(CB_TOXMARKS         )),
993 
994     aIdxOptionsFL(      this, SW_RES(FL_IDXOPTIONS       )),
995     aCollectSameCB(     this, SW_RES(CB_COLLECTSAME      )),
996     aUseFFCB(           this, SW_RES(CB_USEFF           )),
997     aUseDashCB(         this, SW_RES(CB_USE_DASH            )),
998     aCaseSensitiveCB(   this, SW_RES(CB_CASESENSITIVE   )),
999     aInitialCapsCB(     this, SW_RES(CB_INITIALCAPS     )),
1000     aKeyAsEntryCB(      this, SW_RES(CB_KEYASENTRY      )),
1001     aFromFileCB(        this, SW_RES(CB_FROMFILE            )),
1002     aAutoMarkPB(        this, SW_RES(MB_AUTOMARK            )),
1003 
1004     aFromNames(         SW_RES(RES_SRCTYPES              )),
1005     aFromObjCLB(        this, SW_RES(CLB_FROMOBJ            )),
1006     aFromObjFL(         this, SW_RES(FL_FROMOBJ          )),
1007 
1008     aSequenceCB(        this, SW_RES(CB_SEQUENCE         )),
1009     aBracketFT(         this, SW_RES(FT_BRACKET         )),
1010     aBracketLB(         this, SW_RES(LB_BRACKET         )),
1011     aAuthorityFormatFL( this, SW_RES(FL_AUTHORITY        )),
1012 
1013     aSortOptionsFL(     this, SW_RES(FL_SORTOPTIONS      )),
1014     aLanguageFT(        this, SW_RES(FT_LANGUAGE         )),
1015     aLanguageLB(        this, SW_RES(LB_LANGUAGE         )),
1016     aSortAlgorithmFT(   this, SW_RES(FT_SORTALG          )),
1017     aSortAlgorithmLB(   this, SW_RES(LB_SORTALG          )),
1018 
1019     pIndexRes(0),
1020 
1021     sAutoMarkType(SW_RES(ST_AUTOMARK_TYPE)),
1022     sAddStyleUser(SW_RES(ST_USER_ADDSTYLE)),
1023     bFirstCall(sal_True)
1024 {
1025     aBracketLB.InsertEntry(String(SW_RES(ST_NO_BRACKET)), 0);
1026 
1027 	aAddStylesPB.SetAccessibleRelationMemberOf(&aCreateFromFL);
1028 	aAddStylesPB.SetAccessibleRelationLabeledBy(&aAddStylesCB);
1029 	aAddStylesPB.SetAccessibleName(aAddStylesCB.GetText());
1030 
1031     FreeResource();
1032 
1033     pIndexEntryWrapper = new IndexEntrySupplierWrapper();
1034 
1035     aLanguageLB.SetLanguageList( LANG_LIST_ALL | LANG_LIST_ONLY_KNOWN,
1036                                  sal_False, sal_False, sal_False );
1037 
1038 	sAddStyleContent = aAddStylesCB.GetText();
1039 
1040 	aCBLeftPos1 = aFromHeadingsCB.GetPosPixel();
1041 	aCBLeftPos2 = aAddStylesCB.GetPosPixel();
1042 	aCBLeftPos3 = aTOXMarksCB.GetPosPixel();
1043 
1044 	ResStringArray& rNames = aFromNames.GetNames();
1045 	for(sal_uInt16 i = 0; i < rNames.Count(); i++)
1046 	{
1047 		aFromObjCLB.InsertEntry(rNames.GetString(i));
1048 		aFromObjCLB.SetEntryData( i, (void*)rNames.GetValue(i) );
1049 	}
1050 	aFromObjCLB.SetHelpId(HID_OLE_CHECKLB);
1051 
1052 	SetExchangeSupport();
1053 	aTypeLB.SetSelectHdl(LINK(this, SwTOXSelectTabPage, TOXTypeHdl));
1054 
1055 	aAddStylesPB.SetClickHdl(LINK(this, SwTOXSelectTabPage, AddStylesHdl));
1056 	//aChapterDlgPB.SetClickHdl(LINK(this, SwTOXSelectTabPage, ChapterHdl));//#outline level,removed by zhaojianwei
1057 
1058 	PopupMenu*	pMenu = aAutoMarkPB.GetPopupMenu();
1059 	pMenu->SetActivateHdl(LINK(this, SwTOXSelectTabPage, MenuEnableHdl));
1060 	pMenu->SetSelectHdl(LINK(this, SwTOXSelectTabPage, MenuExecuteHdl));
1061 
1062 	Link aLk =  LINK(this, SwTOXSelectTabPage, CheckBoxHdl);
1063 	aAddStylesCB	.SetClickHdl(aLk);
1064 	aFromHeadingsCB .SetClickHdl(aLk);
1065 	aTOXMarksCB     .SetClickHdl(aLk);
1066 	aFromFileCB     .SetClickHdl(aLk);
1067 	aCollectSameCB	.SetClickHdl(aLk);
1068 	aUseFFCB		.SetClickHdl(aLk);
1069 	aUseDashCB		.SetClickHdl(aLk);
1070 	aInitialCapsCB	.SetClickHdl(aLk);
1071 	aKeyAsEntryCB	.SetClickHdl(aLk);
1072 
1073 	Link aModifyLk = LINK(this, SwTOXSelectTabPage, ModifyHdl);
1074 	aTitleED.SetModifyHdl(aModifyLk);
1075 	aLevelNF.SetModifyHdl(aModifyLk);
1076     aSortAlgorithmLB.SetSelectHdl(aModifyLk);
1077 
1078 	aLk =  LINK(this, SwTOXSelectTabPage, RadioButtonHdl);
1079 	aFromCaptionsRB.SetClickHdl(aLk);
1080 	aFromObjectNamesRB.SetClickHdl(aLk);
1081 	RadioButtonHdl(&aFromCaptionsRB);
1082 
1083     aLanguageLB.SetSelectHdl(LINK(this, SwTOXSelectTabPage, LanguageHdl));
1084 	aTypeLB.SelectEntryPos(0);
1085 	aTitleED.SaveValue();
1086 }
1087 /*-- 14.06.99 13:11:41---------------------------------------------------
1088 
1089   -----------------------------------------------------------------------*/
1090 SwTOXSelectTabPage::~SwTOXSelectTabPage()
1091 {
1092     delete pIndexRes;
1093     delete pIndexEntryWrapper;
1094 }
1095 /* -----------------21.10.99 17:03-------------------
1096 
1097  --------------------------------------------------*/
1098 void SwTOXSelectTabPage::SetWrtShell(SwWrtShell& rSh)
1099 {
1100 	sal_uInt16 nUserTypeCount = rSh.GetTOXTypeCount(TOX_USER);
1101 	if(nUserTypeCount > 1)
1102 	{
1103 		//insert all new user indexes names after the standard user index
1104 		sal_uInt16 nPos = aTypeLB.GetEntryPos((void*)(sal_uInt32)TO_USER);
1105 		nPos++;
1106 		for(sal_uInt16 nUser = 1; nUser < nUserTypeCount; nUser++)
1107 		{
1108 			nPos = aTypeLB.InsertEntry(rSh.GetTOXType(TOX_USER, nUser)->GetTypeName(), nPos);
1109 			sal_uInt32 nEntryData = nUser << 8;
1110 			nEntryData |= TO_USER;
1111 			aTypeLB.SetEntryData(nPos, (void*)nEntryData);
1112 		}
1113 	}
1114 }
1115 /* -----------------14.06.99 13:10-------------------
1116 
1117  --------------------------------------------------*/
1118 sal_Bool SwTOXSelectTabPage::FillItemSet( SfxItemSet& )
1119 {
1120 	return sal_True;
1121 }
1122 /* -----------------25.08.99 14:31-------------------
1123 
1124  --------------------------------------------------*/
1125 long lcl_TOXTypesToUserData(CurTOXType eType)
1126 {
1127     sal_uInt16 nRet = TOX_INDEX;
1128 	switch(eType.eType)
1129 	{
1130 		case TOX_INDEX       : nRet = TO_INDEX; 	break;
1131 		case TOX_USER        :
1132 		{
1133 			nRet = eType.nIndex << 8;
1134 			nRet |= TO_USER;
1135 		}
1136 		break;
1137 		case TOX_CONTENT     : nRet = TO_CONTENT; 	break;
1138 		case TOX_ILLUSTRATIONS:nRet = TO_ILLUSTRATION; break;
1139 		case TOX_OBJECTS     : nRet = TO_OBJECT; 	break;
1140 		case TOX_TABLES      : nRet = TO_TABLE; 	break;
1141 		case TOX_AUTHORITIES : nRet = TO_AUTHORITIES; break;
1142 	}
1143 	return nRet;
1144 }
1145 //-----------------------------------------------------------------
1146 void SwTOXSelectTabPage::SelectType(TOXTypes eSet)
1147 {
1148 	CurTOXType eCurType (eSet, 0);
1149 
1150 	long nData = lcl_TOXTypesToUserData(eCurType);
1151 	aTypeLB.SelectEntryPos(aTypeLB.GetEntryPos((void*)nData));
1152 	aTypeFT.Enable(sal_False);
1153 	aTypeLB.Enable(sal_False);
1154 	TOXTypeHdl(&aTypeLB);
1155 }
1156 
1157 /*-- 14.06.99 13:10:45---------------------------------------------------
1158 
1159   -----------------------------------------------------------------------*/
1160 //-----------------------------------------------------------------
1161 CurTOXType lcl_UserData2TOXTypes(sal_uInt16 nData)
1162 {
1163 	CurTOXType eRet;
1164 
1165 	switch(nData&0xff)
1166 	{
1167 		case TO_INDEX 	   	: eRet.eType = TOX_INDEX;       break;
1168 		case TO_USER 		:
1169 		{
1170 			eRet.eType = TOX_USER;
1171 			eRet.nIndex  = (nData&0xff00) >> 8;
1172 		}
1173 		break;
1174 		case TO_CONTENT 	: eRet.eType = TOX_CONTENT;     break;
1175 		case TO_ILLUSTRATION: eRet.eType = TOX_ILLUSTRATIONS; break;
1176 		case TO_OBJECT 	  	: eRet.eType = TOX_OBJECTS;     break;
1177 		case TO_TABLE 	   	: eRet.eType = TOX_TABLES;      break;
1178 		case TO_AUTHORITIES	: eRet.eType = TOX_AUTHORITIES; break;
1179 		default: DBG_ERROR("what a type?");
1180 	}
1181 	return eRet;
1182 }
1183 /* -----------------02.09.99 08:16-------------------
1184 
1185  --------------------------------------------------*/
1186 void	SwTOXSelectTabPage::ApplyTOXDescription()
1187 {
1188 	SwMultiTOXTabDialog* pTOXDlg = (SwMultiTOXTabDialog*)GetTabDialog();
1189 	const CurTOXType aCurType = pTOXDlg->GetCurrentTOXType();
1190 	SwTOXDescription& rDesc = pTOXDlg->GetTOXDescription(aCurType);
1191 	aReadOnlyCB.Check(rDesc.IsReadonly());
1192 	if(aTitleED.GetText() == aTitleED.GetSavedValue())
1193 	{
1194 		if(rDesc.GetTitle())
1195 			aTitleED.SetText(*rDesc.GetTitle());
1196 		else
1197 			aTitleED.SetText(aEmptyStr);
1198 		aTitleED.SaveValue();
1199 	}
1200 
1201 	aAreaLB.SelectEntryPos(rDesc.IsFromChapter() ? 1 : 0);
1202 
1203 	if(aCurType.eType != TOX_INDEX)
1204 		aLevelNF.SetValue(rDesc.GetLevel());   //content, user
1205 
1206 	sal_uInt16 nCreateType = rDesc.GetContentOptions();
1207 
1208 	//user + content
1209 	sal_Bool bHasStyleNames = sal_False;
1210 	sal_uInt16 i;
1211 
1212 	for( i = 0; i < MAXLEVEL; i++)
1213 		if(rDesc.GetStyleNames(i).Len())
1214 		{
1215 			bHasStyleNames = sal_True;
1216 			break;
1217 		}
1218     aAddStylesCB.Check(bHasStyleNames && (nCreateType & nsSwTOXElement::TOX_TEMPLATE));
1219 
1220     aFromOLECB.     Check( 0 != (nCreateType & nsSwTOXElement::TOX_OLE) );
1221     aFromTablesCB.  Check( 0 != (nCreateType & nsSwTOXElement::TOX_TABLE) );
1222     aFromGraphicsCB.Check( 0 != (nCreateType & nsSwTOXElement::TOX_GRAPHIC) );
1223     aFromFramesCB.  Check( 0 != (nCreateType & nsSwTOXElement::TOX_FRAME) );
1224 
1225 	aLevelFromChapterCB.Check(rDesc.IsLevelFromChapter());
1226 
1227 	//all but illustration and table
1228     aTOXMarksCB.Check( 0 != (nCreateType & nsSwTOXElement::TOX_MARK) );
1229 
1230 	//content
1231 	if(TOX_CONTENT == aCurType.eType)
1232 	{
1233         aFromHeadingsCB.Check( 0 != (nCreateType & nsSwTOXElement::TOX_OUTLINELEVEL) );
1234 		//aChapterDlgPB.Enable(aFromHeadingsCB.IsChecked());//#outline level,removed by zhaojianwei
1235 		aAddStylesCB.SetText(sAddStyleContent);
1236 		aAddStylesPB.Enable(aAddStylesCB.IsChecked());
1237 	}
1238 	//index only
1239 	else if(TOX_INDEX == aCurType.eType)
1240 	{
1241 		sal_uInt16 nIndexOptions = rDesc.GetIndexOptions();
1242         aCollectSameCB.     Check( 0 != (nIndexOptions & nsSwTOIOptions::TOI_SAME_ENTRY) );
1243         aUseFFCB.           Check( 0 != (nIndexOptions & nsSwTOIOptions::TOI_FF) );
1244         aUseDashCB.         Check( 0 != (nIndexOptions & nsSwTOIOptions::TOI_DASH) );
1245 		if(aUseFFCB.IsChecked())
1246 			aUseDashCB.Enable(sal_False);
1247 		else if(aUseDashCB.IsChecked())
1248 			aUseFFCB.Enable(sal_False);
1249 
1250         aCaseSensitiveCB.   Check( 0 != (nIndexOptions & nsSwTOIOptions::TOI_CASE_SENSITIVE) );
1251         aInitialCapsCB.     Check( 0 != (nIndexOptions & nsSwTOIOptions::TOI_INITIAL_CAPS) );
1252         aKeyAsEntryCB.      Check( 0 != (nIndexOptions & nsSwTOIOptions::TOI_KEY_AS_ENTRY) );
1253 	}
1254 	else if(TOX_ILLUSTRATIONS == aCurType.eType ||
1255 		TOX_TABLES == aCurType.eType)
1256 	{
1257 		aFromObjectNamesRB.Check(rDesc.IsCreateFromObjectNames());
1258 		aFromCaptionsRB.Check(!rDesc.IsCreateFromObjectNames());
1259 		aCaptionSequenceLB.SelectEntry(rDesc.GetSequenceName());
1260         aDisplayTypeLB.SelectEntryPos( static_cast< sal_uInt16 >(rDesc.GetCaptionDisplay()) );
1261 		RadioButtonHdl(&aFromCaptionsRB);
1262 
1263 	}
1264 	else if(TOX_OBJECTS == aCurType.eType)
1265 	{
1266 		long nOLEData = rDesc.GetOLEOptions();
1267         for(sal_uInt16 nFromObj = 0; nFromObj < aFromObjCLB.GetEntryCount(); nFromObj++)
1268 		{
1269             long nData = (long)aFromObjCLB.GetEntryData(nFromObj);
1270             aFromObjCLB.CheckEntryPos(nFromObj, 0 != (nData & nOLEData));
1271 		}
1272 	}
1273 	else if(TOX_AUTHORITIES == aCurType.eType)
1274 	{
1275         String sBrackets(rDesc.GetAuthBrackets());
1276         if(!sBrackets.Len() || sBrackets.EqualsAscii("  "))
1277             aBracketLB.SelectEntryPos(0);
1278         else
1279             aBracketLB.SelectEntry(sBrackets);
1280 		aSequenceCB.Check(rDesc.IsAuthSequence());
1281 	}
1282 	aAutoMarkPB.Enable(aFromFileCB.IsChecked());
1283 
1284 	for(i = 0; i < MAXLEVEL; i++)
1285 		aStyleArr[i] = rDesc.GetStyleNames(i);
1286 
1287     aLanguageLB.SelectLanguage(rDesc.GetLanguage());
1288     LanguageHdl(0);
1289     for( long nCnt = 0; nCnt < aSortAlgorithmLB.GetEntryCount(); ++nCnt )
1290 	{
1291         const String* pEntryData = (const String*)aSortAlgorithmLB.GetEntryData( (sal_uInt16)nCnt );
1292         DBG_ASSERT(pEntryData, "no entry data available");
1293         if( pEntryData && *pEntryData == rDesc.GetSortAlgorithm())
1294         {
1295             aSortAlgorithmLB.SelectEntryPos( (sal_uInt16)nCnt );
1296             break;
1297         }
1298 	}
1299 }
1300 /* -----------------09.09.99 11:57-------------------
1301 
1302  --------------------------------------------------*/
1303 void SwTOXSelectTabPage::FillTOXDescription()
1304 {
1305 	SwMultiTOXTabDialog* pTOXDlg = (SwMultiTOXTabDialog*)GetTabDialog();
1306 	CurTOXType aCurType = pTOXDlg->GetCurrentTOXType();
1307 	SwTOXDescription& rDesc = pTOXDlg->GetTOXDescription(aCurType);
1308 	rDesc.SetTitle(aTitleED.GetText());
1309 	rDesc.SetFromChapter(1 == aAreaLB.GetSelectEntryPos());
1310 	sal_uInt16 nContentOptions = 0;
1311 	if(aTOXMarksCB.IsVisible() && aTOXMarksCB.IsChecked())
1312         nContentOptions |= nsSwTOXElement::TOX_MARK;
1313 
1314     sal_uInt16 nIndexOptions = rDesc.GetIndexOptions()&nsSwTOIOptions::TOI_ALPHA_DELIMITTER;
1315 	switch(rDesc.GetTOXType())
1316 	{
1317 		case TOX_CONTENT:
1318 			if(aFromHeadingsCB.IsChecked())
1319                 nContentOptions |= nsSwTOXElement::TOX_OUTLINELEVEL;
1320 		break;
1321 		case TOX_USER:
1322 		{
1323 			rDesc.SetTOUName(aTypeLB.GetSelectEntry());
1324 
1325 			if(aFromOLECB.IsChecked())
1326                 nContentOptions |= nsSwTOXElement::TOX_OLE;
1327 			if(aFromTablesCB.IsChecked())
1328                 nContentOptions |= nsSwTOXElement::TOX_TABLE;
1329 			if(aFromFramesCB.IsChecked())
1330                 nContentOptions |= nsSwTOXElement::TOX_FRAME;
1331 			if(aFromGraphicsCB.IsChecked())
1332                 nContentOptions |= nsSwTOXElement::TOX_GRAPHIC;
1333 		}
1334 		break;
1335 		case  TOX_INDEX:
1336 		{
1337             nContentOptions = nsSwTOXElement::TOX_MARK;
1338 
1339 			if(aCollectSameCB.IsChecked())
1340                 nIndexOptions |= nsSwTOIOptions::TOI_SAME_ENTRY;
1341 			if(aUseFFCB.IsChecked())
1342                 nIndexOptions |= nsSwTOIOptions::TOI_FF;
1343 			if(aUseDashCB.IsChecked())
1344                 nIndexOptions |= nsSwTOIOptions::TOI_DASH;
1345 			if(aCaseSensitiveCB.IsChecked())
1346                 nIndexOptions |= nsSwTOIOptions::TOI_CASE_SENSITIVE;
1347 			if(aInitialCapsCB.IsChecked())
1348                 nIndexOptions |= nsSwTOIOptions::TOI_INITIAL_CAPS;
1349 			if(aKeyAsEntryCB.IsChecked())
1350                 nIndexOptions |= nsSwTOIOptions::TOI_KEY_AS_ENTRY;
1351 			if(aFromFileCB.IsChecked())
1352 				rDesc.SetAutoMarkURL(sAutoMarkURL);
1353 			else
1354 				rDesc.SetAutoMarkURL(aEmptyStr);
1355 		}
1356 		break;
1357 		case TOX_ILLUSTRATIONS:
1358 		case TOX_TABLES :
1359 			rDesc.SetCreateFromObjectNames(aFromObjectNamesRB.IsChecked());
1360 			rDesc.SetSequenceName(aCaptionSequenceLB.GetSelectEntry());
1361 			rDesc.SetCaptionDisplay((SwCaptionDisplay)aDisplayTypeLB.GetSelectEntryPos());
1362 		break;
1363 		case TOX_OBJECTS:
1364 		{
1365 			long nOLEData = 0;
1366 			for(sal_uInt16 i = 0; i < aFromObjCLB.GetEntryCount(); i++)
1367 			{
1368 				if(aFromObjCLB.IsChecked(i))
1369 				{
1370 					long nData = (long)aFromObjCLB.GetEntryData(i);
1371 					nOLEData |= nData;
1372 				}
1373 			}
1374             rDesc.SetOLEOptions((sal_uInt16)nOLEData);
1375 		}
1376 		break;
1377 		case TOX_AUTHORITIES:
1378 		{
1379             if(aBracketLB.GetSelectEntryPos())
1380                 rDesc.SetAuthBrackets(aBracketLB.GetSelectEntry());
1381             else
1382                 rDesc.SetAuthBrackets(aEmptyStr);
1383 			rDesc.SetAuthSequence(aSequenceCB.IsChecked());
1384 		}
1385 		break;
1386 	}
1387 
1388 	rDesc.SetLevelFromChapter(	aLevelFromChapterCB.IsVisible() &&
1389 								aLevelFromChapterCB.IsChecked());
1390 	if(aTOXMarksCB.IsChecked() && aTOXMarksCB.IsVisible())
1391         nContentOptions |= nsSwTOXElement::TOX_MARK;
1392 	if(aFromHeadingsCB.IsChecked() && aFromHeadingsCB.IsVisible())
1393         nContentOptions |= nsSwTOXElement::TOX_OUTLINELEVEL;
1394 	if(aAddStylesCB.IsChecked() && aAddStylesCB.IsVisible())
1395         nContentOptions |= nsSwTOXElement::TOX_TEMPLATE;
1396 
1397 	rDesc.SetContentOptions(nContentOptions);
1398 	rDesc.SetIndexOptions(nIndexOptions);
1399     rDesc.SetLevel( static_cast< sal_uInt8 >(aLevelNF.GetValue()) );
1400 
1401 	rDesc.SetReadonly(aReadOnlyCB.IsChecked());
1402 
1403 	for(sal_uInt16 i = 0; i < MAXLEVEL; i++)
1404 		rDesc.SetStyleNames(aStyleArr[i], i);
1405 
1406     rDesc.SetLanguage(aLanguageLB.GetSelectLanguage());
1407     const String* pEntryData = (const String*)aSortAlgorithmLB.GetEntryData(
1408                                             aSortAlgorithmLB.GetSelectEntryPos() );
1409     DBG_ASSERT(pEntryData, "no entry data available");
1410     if(pEntryData)
1411         rDesc.SetSortAlgorithm(*pEntryData);
1412 }
1413 /* -----------------05.07.99 15:09-------------------
1414 
1415  --------------------------------------------------*/
1416 void SwTOXSelectTabPage::Reset( const SfxItemSet& )
1417 {
1418 	SwMultiTOXTabDialog* pTOXDlg = (SwMultiTOXTabDialog*)GetTabDialog();
1419 	SwWrtShell& rSh = pTOXDlg->GetWrtShell();
1420 	const CurTOXType aCurType = pTOXDlg->GetCurrentTOXType();
1421 	long nData = lcl_TOXTypesToUserData(aCurType);
1422 	aTypeLB.SelectEntryPos(aTypeLB.GetEntryPos((void*)nData));
1423 
1424 	sAutoMarkURL = INetURLObject::decode( rSh.GetTOIAutoMarkURL(),
1425 										INET_HEX_ESCAPE,
1426 						   				INetURLObject::DECODE_UNAMBIGUOUS,
1427 										RTL_TEXTENCODING_UTF8 );
1428     aFromFileCB.Check( 0 != sAutoMarkURL.Len() );
1429 
1430 	aCaptionSequenceLB.Clear();
1431 	sal_uInt16 i, nCount = rSh.GetFldTypeCount(RES_SETEXPFLD);
1432 	for (i = 0; i < nCount; i++)
1433 	{
1434 		SwFieldType *pType = rSh.GetFldType( i, RES_SETEXPFLD );
1435 		if( pType->Which() == RES_SETEXPFLD &&
1436 			((SwSetExpFieldType *) pType)->GetType() & nsSwGetSetExpType::GSE_SEQ )
1437 			aCaptionSequenceLB.InsertEntry(pType->GetName());
1438 	}
1439 
1440 	if(pTOXDlg->IsTOXEditMode())
1441 	{
1442 		aTypeFT.Enable(sal_False);
1443 		aTypeLB.Enable(sal_False);
1444 	}
1445 	TOXTypeHdl(&aTypeLB);
1446 	CheckBoxHdl(&aAddStylesCB);
1447 }
1448 /*-- 14.06.99 13:10:52---------------------------------------------------
1449 
1450   -----------------------------------------------------------------------*/
1451 void SwTOXSelectTabPage::ActivatePage( const SfxItemSet& )
1452 {
1453 	//nothing to do
1454 }
1455 /*-- 14.06.99 13:11:00---------------------------------------------------
1456 
1457   -----------------------------------------------------------------------*/
1458 int SwTOXSelectTabPage::DeactivatePage( SfxItemSet* _pSet )
1459 {
1460     if(_pSet)
1461         _pSet->Put(SfxUInt16Item(FN_PARAM_TOX_TYPE,
1462 			(sal_uInt16)(long)aTypeLB.GetEntryData( aTypeLB.GetSelectEntryPos() )));
1463 	FillTOXDescription();
1464 	return LEAVE_PAGE;
1465 }
1466 /* -----------------14.06.99 13:10-------------------
1467 
1468  --------------------------------------------------*/
1469 SfxTabPage*	SwTOXSelectTabPage::Create( Window* pParent, const SfxItemSet& rAttrSet)
1470 {
1471 	return new SwTOXSelectTabPage(pParent, rAttrSet);
1472 }
1473 /* -----------------14.06.99 13:10-------------------
1474 
1475  --------------------------------------------------*/
1476 IMPL_LINK(SwTOXSelectTabPage, TOXTypeHdl, 	ListBox*, pBox)
1477 {
1478 	SwMultiTOXTabDialog* pTOXDlg = (SwMultiTOXTabDialog*)GetTabDialog();
1479 	if(!bFirstCall)
1480 	{
1481 		// save current values into the proper TOXDescription
1482 		FillTOXDescription();
1483 	}
1484 	bFirstCall = sal_False;
1485     const sal_uInt16 nType =  sal::static_int_cast< sal_uInt16 >(reinterpret_cast< sal_uIntPtr >(
1486                                 pBox->GetEntryData( pBox->GetSelectEntryPos() )));
1487 	CurTOXType eCurType = lcl_UserData2TOXTypes(nType);
1488 	pTOXDlg->SetCurrentTOXType(eCurType);
1489 
1490     aAreaLB.Show( 0 != (nType & (TO_CONTENT|TO_ILLUSTRATION|TO_USER|TO_INDEX|TO_TABLE|TO_OBJECT)) );
1491     aLevelFT.Show( 0 != (nType & (TO_CONTENT)) );
1492     aLevelNF.Show( 0 != (nType & (TO_CONTENT)) );
1493     aLevelFromChapterCB.Show( 0 != (nType & (TO_USER)) );
1494     aAreaFT.Show( 0 != (nType & (TO_CONTENT|TO_ILLUSTRATION|TO_USER|TO_INDEX|TO_TABLE|TO_OBJECT)) );
1495     aAreaFL.Show( 0 != (nType & (TO_CONTENT|TO_ILLUSTRATION|TO_USER|TO_INDEX|TO_TABLE|TO_OBJECT)) );
1496 
1497     aFromHeadingsCB.Show( 0 != (nType & (TO_CONTENT)) );
1498    // aChapterDlgPB.Show( 0 != (nType & (TO_CONTENT)) );//#outline level,removed by zhaojianwei
1499     aAddStylesCB.Show( 0 != (nType & (TO_CONTENT|TO_USER)) );
1500     aAddStylesPB.Show( 0 != (nType & (TO_CONTENT|TO_USER)) );
1501 
1502     aFromTablesCB.Show( 0 != (nType & (TO_USER)) );
1503     aFromFramesCB.Show( 0 != (nType & (TO_USER)) );
1504     aFromGraphicsCB.Show( 0 != (nType & (TO_USER)) );
1505     aFromOLECB.Show( 0 != (nType & (TO_USER)) );
1506 
1507     aFromCaptionsRB.Show( 0 != (nType & (TO_ILLUSTRATION|TO_TABLE)) );
1508     aFromObjectNamesRB.Show( 0 != (nType & (TO_ILLUSTRATION|TO_TABLE)) );
1509 
1510     aTOXMarksCB.Show( 0 != (nType & (TO_CONTENT|TO_USER)) );
1511 
1512     aCreateFromFL.Show( 0 != (nType & (TO_CONTENT|TO_ILLUSTRATION|TO_USER|TO_TABLE)) );
1513     aCaptionSequenceFT.Show( 0 != (nType & (TO_ILLUSTRATION|TO_TABLE)) );
1514     aCaptionSequenceLB.Show( 0 != (nType & (TO_ILLUSTRATION|TO_TABLE)) );
1515     aDisplayTypeFT.Show( 0 != (nType & (TO_ILLUSTRATION|TO_TABLE)) );
1516     aDisplayTypeLB.Show( 0 != (nType & (TO_ILLUSTRATION|TO_TABLE)) );
1517 
1518     aSequenceCB.Show( 0 != (nType & TO_AUTHORITIES) );
1519     aBracketFT.Show( 0 != (nType & TO_AUTHORITIES) );
1520     aBracketLB.Show( 0 != (nType & TO_AUTHORITIES) );
1521     aAuthorityFormatFL.Show( 0 != (nType & TO_AUTHORITIES) );
1522 
1523     sal_Bool bEnableSortLanguage = 0 != (nType & (TO_INDEX|TO_AUTHORITIES));
1524     aSortOptionsFL.Show(bEnableSortLanguage);
1525     aLanguageFT.Show(bEnableSortLanguage);
1526     aLanguageLB.Show(bEnableSortLanguage);
1527     aSortAlgorithmFT.Show(bEnableSortLanguage);
1528     aSortAlgorithmLB.Show(bEnableSortLanguage);
1529 
1530 	//if(nType & TO_CONTENT)			//#outline level,removed by zhaojianwei
1531 	//{
1532 	 	//Point aPos(aAddStylesPB.GetPosPixel());
1533 		//aPos.X() = aChapterDlgPB.GetPosPixel().X();
1534 		//aAddStylesPB.SetPosPixel(aPos);
1535 	//}
1536 	//else if( nType & TO_ILLUSTRATION )//<-removed end.
1537         // initialize button positions
1538 
1539     //#i111993# add styles button has two different positions
1540     if( !aAddStylesPosDef.X() )
1541     {
1542         aAddStylesPosDef = ( aAddStylesPB.GetPosPixel() );
1543         // move left!
1544         Point aPos(aAddStylesPosDef);
1545         aPos.X() -= 2 * aAddStylesPB.GetSizePixel().Width();
1546         aAddStylesPosUser = aPos;
1547     }
1548 
1549     if( nType & TO_ILLUSTRATION )       //add by zhaojianwei
1550 		aCaptionSequenceLB.SelectEntry( SwStyleNameMapper::GetUIName(
1551 									RES_POOLCOLL_LABEL_ABB, aEmptyStr ));
1552 	else if( nType & TO_TABLE )
1553 		aCaptionSequenceLB.SelectEntry( SwStyleNameMapper::GetUIName(
1554 									RES_POOLCOLL_LABEL_TABLE, aEmptyStr ));
1555 	else if( nType & TO_USER )
1556 	{
1557         aAddStylesCB.SetText(sAddStyleUser);
1558         aAddStylesPB.SetPosPixel(aAddStylesPosUser);
1559 	}
1560     else if( nType & TO_CONTENT )
1561     {
1562         aAddStylesPB.SetPosPixel(aAddStylesPosDef);
1563     }
1564 
1565     aCollectSameCB.Show( 0 != (nType & TO_INDEX) );
1566     aUseFFCB.Show( 0 != (nType & TO_INDEX) );
1567     aUseDashCB.Show( 0 != (nType & TO_INDEX) );
1568     aCaseSensitiveCB.Show( 0 != (nType & TO_INDEX) );
1569     aInitialCapsCB.Show( 0 != (nType & TO_INDEX) );
1570     aKeyAsEntryCB.Show( 0 != (nType & TO_INDEX) );
1571     aFromFileCB.Show( 0 != (nType & TO_INDEX) );
1572     aAutoMarkPB.Show( 0 != (nType & TO_INDEX) );
1573 //	aCreateAutoMarkPB.Show(nType &TO_INDEX);
1574 //	aEditAutoMarkPB.Show(nType & TO_INDEX);
1575 
1576     aIdxOptionsFL.Show( 0 != (nType & TO_INDEX) );
1577 
1578 	//object index
1579     aFromObjCLB.Show( 0 != (nType & TO_OBJECT) );
1580     aFromObjFL.Show( 0 != (nType & TO_OBJECT) );
1581 
1582 	//move controls
1583 	aAddStylesCB.SetPosPixel(nType & TO_USER ? aCBLeftPos1 : aCBLeftPos2);
1584  Point aPBPos(aAddStylesPB.GetPosPixel());
1585 	aPBPos.Y() = nType & TO_USER ? aCBLeftPos1.Y() : aCBLeftPos2.Y();
1586 	aAddStylesPB.SetPosPixel(aPBPos);
1587 	aTOXMarksCB.SetPosPixel(nType & TO_USER ? aCBLeftPos2 : aCBLeftPos3);
1588 	//set control values from the proper TOXDescription
1589 	{
1590 		ApplyTOXDescription();
1591 	}
1592 	ModifyHdl(0);
1593 	return 0;
1594 }
1595 /* -----------------30.11.99 12:48-------------------
1596 
1597  --------------------------------------------------*/
1598 IMPL_LINK(SwTOXSelectTabPage, ModifyHdl, void*, EMPTYARG)
1599 {
1600 	SwMultiTOXTabDialog* pTOXDlg = (SwMultiTOXTabDialog*)GetTabDialog();
1601 	if(pTOXDlg)
1602 	{
1603 		FillTOXDescription();
1604 		pTOXDlg->CreateOrUpdateExample(pTOXDlg->GetCurrentTOXType().eType, TOX_PAGE_SELECT);
1605 	}
1606 	return 0;
1607 }
1608 /* -----------------05.07.99 10:13-------------------
1609 
1610  --------------------------------------------------*/
1611 IMPL_LINK(SwTOXSelectTabPage, CheckBoxHdl, 	CheckBox*, pBox	)
1612 {
1613 	SwMultiTOXTabDialog* pTOXDlg = (SwMultiTOXTabDialog*)GetTabDialog();
1614 	const CurTOXType aCurType = pTOXDlg->GetCurrentTOXType();
1615 	if(TOX_CONTENT == aCurType.eType)
1616 	{
1617 		//at least one of the three CheckBoxes must be checked
1618 		if(!aAddStylesCB.IsChecked() && !aFromHeadingsCB.IsChecked() && !aTOXMarksCB.IsChecked())
1619 		{
1620 			//TODO: InfoBox?
1621 			pBox->Check(sal_True);
1622 		}
1623 		aAddStylesPB.Enable(aAddStylesCB.IsChecked());
1624 		//aChapterDlgPB.Enable(aFromHeadingsCB.IsChecked());//#outline level,removed by zhaojianwei
1625 	}
1626 	if(TOX_USER == aCurType.eType)
1627 	{
1628 		aAddStylesPB.Enable(aAddStylesCB.IsChecked());
1629 	}
1630 	else if(TOX_INDEX == aCurType.eType)
1631 	{
1632 		aAutoMarkPB.Enable(aFromFileCB.IsChecked());
1633 		aUseFFCB.Enable(aCollectSameCB.IsChecked() && !aUseDashCB.IsChecked());
1634 		aUseDashCB.Enable(aCollectSameCB.IsChecked() && !aUseFFCB.IsChecked());
1635 		aCaseSensitiveCB.Enable(aCollectSameCB.IsChecked());
1636 	}
1637 	ModifyHdl(0);
1638 	return 0;
1639 };
1640 /* -----------------14.07.99 14:21-------------------
1641 
1642  --------------------------------------------------*/
1643 IMPL_LINK(SwTOXSelectTabPage, RadioButtonHdl, RadioButton*, EMPTYARG )
1644 {
1645 	sal_Bool bEnable = aFromCaptionsRB.IsChecked();
1646 	aCaptionSequenceFT.Enable(bEnable);
1647 	aCaptionSequenceLB.Enable(bEnable);
1648 	aDisplayTypeFT.Enable(bEnable);
1649 	aDisplayTypeLB.Enable(bEnable);
1650 	ModifyHdl(0);
1651 	return 0;
1652 }
1653 /* -----------------------------06.06.01 09:33--------------------------------
1654 
1655  ---------------------------------------------------------------------------*/
1656 IMPL_LINK(SwTOXSelectTabPage, LanguageHdl, ListBox*, pBox)
1657 {
1658     Locale aLcl( SvxCreateLocale( aLanguageLB.GetSelectLanguage() ) );
1659     Sequence< OUString > aSeq = pIndexEntryWrapper->GetAlgorithmList( aLcl );
1660 
1661     if( !pIndexRes )
1662         pIndexRes = new IndexEntryRessource();
1663 
1664     String sOldString;
1665     void* pUserData;
1666     if( 0 != (pUserData = aSortAlgorithmLB.GetEntryData( aSortAlgorithmLB.GetSelectEntryPos())) )
1667         sOldString = *(String*)pUserData;
1668     void* pDel;
1669     sal_uInt16 nEnd = aSortAlgorithmLB.GetEntryCount();
1670     for( sal_uInt16 n = 0; n < nEnd; ++n )
1671         if( 0 != ( pDel = aSortAlgorithmLB.GetEntryData( n )) )
1672 			delete (String*)pDel;
1673     aSortAlgorithmLB.Clear();
1674 
1675 	sal_uInt16 nInsPos;
1676 	String sAlg, sUINm;
1677     nEnd = static_cast< sal_uInt16 >(aSeq.getLength());
1678     for( sal_uInt16 nCnt = 0; nCnt < nEnd; ++nCnt )
1679 	{
1680         sUINm = pIndexRes->GetTranslation( sAlg = aSeq[ nCnt ] );
1681         nInsPos = aSortAlgorithmLB.InsertEntry( sUINm );
1682         aSortAlgorithmLB.SetEntryData( nInsPos, new String( sAlg ));
1683         if( sAlg == sOldString )
1684             aSortAlgorithmLB.SelectEntryPos( nInsPos );
1685 	}
1686 
1687     if( LISTBOX_ENTRY_NOTFOUND == aSortAlgorithmLB.GetSelectEntryPos() )
1688         aSortAlgorithmLB.SelectEntryPos( 0 );
1689 
1690     if(pBox)
1691         ModifyHdl(0);
1692     return 0;
1693 };
1694 /* -----------------14.06.99 13:10-------------------
1695 
1696  --------------------------------------------------*/
1697 IMPL_LINK(SwTOXSelectTabPage, TOXAreaHdl, 	ListBox*, pBox)
1698 {
1699 	DBG_WARNING("not implemented");
1700 	switch((long)pBox->GetEntryData( pBox->GetSelectEntryPos() ))
1701 	{
1702 		case AREA_DOCUMENT  : break;
1703 		case AREA_CHAPTER	: break;
1704 	}
1705 	return 0;
1706 }
1707 
1708 //#outline level, removed by zhaojianwei
1709 //It is no longer used!
1710 ///* -----------------14.06.99 13:10-------------------
1711 //
1712 // --------------------------------------------------*/
1713 //IMPL_LINK(SwTOXSelectTabPage, ChapterHdl, 	PushButton*, pButton)
1714 //{
1715 //	SwMultiTOXTabDialog* pTOXDlg = (SwMultiTOXTabDialog*)GetTabDialog();
1716 //	SwWrtShell& rSh = pTOXDlg->GetWrtShell();
1717 //
1718 //	SfxItemSet aTmp(rSh.GetView().GetPool(), FN_PARAM_1, FN_PARAM_1);
1719 //	SwOutlineTabDialog* pDlg = new SwOutlineTabDialog(pButton, &aTmp, rSh);
1720 //
1721 //	if(RET_OK == pDlg->Execute())
1722 //	{
1723 //		CurTOXType aCurType = pTOXDlg->GetCurrentTOXType();
1724 //		SwForm* pForm = ((SwMultiTOXTabDialog*)GetTabDialog())->GetForm(aCurType);
1725 //		// jetzt muss ueberprueft werden, ob dem sdbcx::Index Ueberschriftenvorlagen
1726 //		// zugewiesen wurden
1727 //		String sStr;
1728 //		for(sal_uInt16 i = 0; i < MAXLEVEL; i++)
1729 //		{
1730 //			sal_Bool bNum = !SwMultiTOXTabDialog::IsNoNum(rSh, pForm->GetTemplate( i + 1 ));
1731 //			if(bNum)
1732 //			{
1733 //				//es gibt getrennte Resourcebereiche fuer die Inhaltsverzeichnisse
1734 //				if(i < 5)
1735 //                    SwStyleNameMapper::FillUIName( static_cast< sal_uInt16 >(RES_POOLCOLL_TOX_CNTNT1 + i), sStr );
1736 //				else
1737 //                    SwStyleNameMapper::FillUIName( static_cast< sal_uInt16 >(RES_POOLCOLL_TOX_CNTNT6 + i - 5), sStr );
1738 //				pForm->SetTemplate( i + 1, sStr );
1739 //			}
1740 //		}
1741 //
1742 //	}
1743 //	delete pDlg;
1744 //	return 0;
1745 //}
1746 /* -----------------14.06.99 13:10-------------------
1747 
1748  --------------------------------------------------*/
1749 IMPL_LINK(SwTOXSelectTabPage, AddStylesHdl, PushButton*, pButton)
1750 {
1751 	SwAddStylesDlg_Impl* pDlg = new SwAddStylesDlg_Impl(pButton,
1752 		((SwMultiTOXTabDialog*)GetTabDialog())->GetWrtShell(),
1753 		aStyleArr);
1754 	pDlg->Execute();
1755 	delete pDlg;
1756 	ModifyHdl(0);
1757 	return 0;
1758 }
1759 /* -----------------------------19.01.00 10:59--------------------------------
1760 
1761  ---------------------------------------------------------------------------*/
1762 
1763 IMPL_LINK(SwTOXSelectTabPage, MenuEnableHdl, Menu*, pMenu)
1764 {
1765     pMenu->EnableItem(MN_AUTOMARK_EDIT, sAutoMarkURL.Len() > 0);
1766 	return 0;
1767 }
1768 
1769 IMPL_LINK(SwTOXSelectTabPage, MenuExecuteHdl, Menu*, pMenu)
1770 {
1771 	const String sSaveAutoMarkURL = sAutoMarkURL;
1772 	switch(pMenu->GetCurItemId())
1773 	{
1774 		case  MN_AUTOMARK_OPEN:
1775             sAutoMarkURL = lcl_CreateAutoMarkFileDlg(
1776 									sAutoMarkURL, sAutoMarkType, sal_True);
1777 		break;
1778 		case  MN_AUTOMARK_NEW :
1779             sAutoMarkURL = lcl_CreateAutoMarkFileDlg(
1780 									sAutoMarkURL, sAutoMarkType, sal_False);
1781 			if( !sAutoMarkURL.Len() )
1782 				break;
1783 		//no break
1784 		case  MN_AUTOMARK_EDIT:
1785 		{
1786 			sal_Bool bNew = pMenu->GetCurItemId()== MN_AUTOMARK_NEW;
1787 			SwAutoMarkDlg_Impl* pAutoMarkDlg = new SwAutoMarkDlg_Impl(
1788 					&aAutoMarkPB, sAutoMarkURL, sAutoMarkType, bNew );
1789 
1790 			if( RET_OK != pAutoMarkDlg->Execute() && bNew )
1791 				sAutoMarkURL = sSaveAutoMarkURL;
1792 			delete pAutoMarkDlg;
1793 
1794 		}
1795 		break;
1796 	}
1797 	return 0;
1798 }
1799 
1800 /* -----------------16.06.99 10:46-------------------
1801 
1802  --------------------------------------------------*/
1803 class SwTOXEdit : public Edit
1804 {
1805 	SwFormToken	aFormToken;
1806 	Link		aPrevNextControlLink;
1807    	sal_Bool		bNextControl;
1808 	SwTokenWindow* m_pParent;
1809 public:
1810 	SwTOXEdit( Window* pParent, SwTokenWindow* pTokenWin,
1811 				const SwFormToken& aToken)
1812 		: Edit( pParent, WB_BORDER|WB_TABSTOP|WB_CENTER),
1813         aFormToken(aToken),
1814 		bNextControl(sal_False),
1815 		m_pParent( pTokenWin )
1816 	{
1817 		SetHelpId( HID_TOX_ENTRY_EDIT );
1818 	}
1819 
1820 	virtual void	KeyInput( const KeyEvent& rKEvt );
1821 	virtual void	RequestHelp( const HelpEvent& rHEvt );
1822 
1823 	sal_Bool	IsNextControl() const {return bNextControl;}
1824 	void SetPrevNextLink( const Link& rLink )	{aPrevNextControlLink = rLink;}
1825 
1826 	const SwFormToken&	GetFormToken()
1827 		{
1828 			aFormToken.sText = GetText();
1829 			return aFormToken;
1830 		}
1831 
1832 	void	SetCharStyleName(const String& rSet, sal_uInt16 nPoolId)
1833 		{
1834 			aFormToken.sCharStyleName = rSet;
1835 			aFormToken.nPoolId = nPoolId;
1836 		}
1837 
1838 	void 	AdjustSize();
1839 };
1840 
1841 //---------------------------------------------------
1842 void	SwTOXEdit::RequestHelp( const HelpEvent& rHEvt )
1843 {
1844 	if(!m_pParent->CreateQuickHelp(this, aFormToken, rHEvt))
1845 		Edit::RequestHelp(rHEvt);
1846 }
1847 //---------------------------------------------------
1848 void	SwTOXEdit::KeyInput( const KeyEvent& rKEvt )
1849 {
1850 	const Selection& rSel = GetSelection();
1851 	sal_uInt16 nTextLen = GetText().Len();
1852 	if( (rSel.A() == rSel.B() &&
1853 		 !rSel.A() ) || rSel.A() == nTextLen )
1854 	{
1855 		sal_Bool bCall = sal_False;
1856 		KeyCode aCode = rKEvt.GetKeyCode();
1857 		if(aCode.GetCode() == KEY_RIGHT && rSel.A() == nTextLen)
1858 		{
1859 			bNextControl = sal_True;
1860 			bCall = sal_True;
1861 		}
1862 		else if(aCode.GetCode() == KEY_LEFT && !rSel.A() )
1863 		{
1864 			bNextControl = sal_False;
1865 			bCall = sal_True;
1866 		}
1867 
1868 		if(bCall && aPrevNextControlLink.IsSet())
1869 			aPrevNextControlLink.Call(this);
1870 
1871 	}
1872 	Edit::KeyInput(rKEvt);
1873 }
1874 /* -----------------16.07.99 12:41-------------------
1875 
1876  --------------------------------------------------*/
1877 void SwTOXEdit::AdjustSize()
1878 {
1879  	Size aSize(GetSizePixel());
1880  	Size aTextSize(GetTextWidth(GetText()), GetTextHeight());
1881 	aTextSize = LogicToPixel(aTextSize);
1882 	aSize.Width() = aTextSize.Width() + EDIT_MINWIDTH;
1883 	SetSizePixel(aSize);
1884 }
1885 
1886 //---------------------------------------------------
1887 //---------------------------------------------------
1888 class SwTOXButton : public PushButton
1889 {
1890 	SwFormToken	aFormToken;
1891 	Link		aPrevNextControlLink;
1892 	sal_Bool		bNextControl;
1893 	SwTokenWindow* m_pParent;
1894 public:
1895 	SwTOXButton( Window* pParent, SwTokenWindow* pTokenWin,
1896 				const SwFormToken& rToken)
1897 		: PushButton(pParent, WB_BORDER|WB_TABSTOP),
1898         aFormToken(rToken),
1899 		bNextControl(sal_False),
1900 		m_pParent(pTokenWin)
1901 	{
1902 		SetHelpId(HID_TOX_ENTRY_BUTTON);
1903 	}
1904 
1905 	virtual void	KeyInput( const KeyEvent& rKEvt );
1906 	virtual void	RequestHelp( const HelpEvent& rHEvt );
1907 
1908 	sal_Bool IsNextControl() const 			{return bNextControl;}
1909 	void SetPrevNextLink(const Link& rLink) {aPrevNextControlLink = rLink;}
1910 	const SwFormToken& GetFormToken() const	{return aFormToken;}
1911 
1912 	void SetCharStyleName(const String& rSet, sal_uInt16 nPoolId)
1913 		{
1914 			aFormToken.sCharStyleName = rSet;
1915 			aFormToken.nPoolId = nPoolId;
1916 		}
1917 
1918 	void SetTabPosition(SwTwips nSet)
1919 		{ aFormToken.nTabStopPosition = nSet; }
1920 
1921 	void SetFillChar( sal_Unicode cSet )
1922 		{ aFormToken.cTabFillChar = cSet; }
1923 
1924 	void SetTabAlign(SvxTabAdjust eAlign)
1925 		 {	aFormToken.eTabAlign = eAlign;}
1926 
1927 //---> i89791
1928     //used for entry number format, in TOC only
1929     //needed for different UI dialog position
1930     void SetEntryNumberFormat(sal_uInt16 nSet) {
1931         switch(nSet)
1932         {
1933         default:
1934         case 0:
1935             aFormToken.nChapterFormat = CF_NUMBER;
1936             break;
1937         case 1:
1938             aFormToken.nChapterFormat = CF_NUM_NOPREPST_TITLE;
1939             break;
1940         }
1941     }
1942 
1943     void SetChapterInfo(sal_uInt16 nSet) {
1944         switch(nSet)
1945         {
1946         default:
1947         case 0:
1948             aFormToken.nChapterFormat = CF_NUM_NOPREPST_TITLE;
1949             break;
1950         case 1:
1951             aFormToken.nChapterFormat = CF_TITLE;
1952             break;
1953         case 2:
1954             aFormToken.nChapterFormat = CF_NUMBER_NOPREPST;
1955             break;
1956         }
1957     }
1958 //<---
1959 	sal_uInt16 GetChapterInfo() const{ return aFormToken.nChapterFormat;}
1960 
1961     void SetOutlineLevel( sal_uInt16 nSet ) { aFormToken.nOutlineLevel = nSet;}//i53420
1962     sal_uInt16 GetOutlineLevel() const{ return aFormToken.nOutlineLevel;}
1963 
1964 	void SetLinkEnd()
1965 		{
1966 			DBG_ASSERT(TOKEN_LINK_START == aFormToken.eTokenType,
1967 									"call SetLinkEnd for link start only!");
1968 			aFormToken.eTokenType = TOKEN_LINK_END;
1969 			aFormToken.sText.AssignAscii(SwForm::aFormLinkEnd);
1970 			SetText(aFormToken.sText);
1971 		}
1972 	void SetLinkStart()
1973 		{
1974 			DBG_ASSERT(TOKEN_LINK_END == aFormToken.eTokenType,
1975 									"call SetLinkStart for link start only!");
1976 			aFormToken.eTokenType = TOKEN_LINK_START;
1977 			aFormToken.sText.AssignAscii(SwForm::aFormLinkStt);
1978 			SetText(aFormToken.sText);
1979 		}
1980 };
1981 
1982 //---------------------------------------------------
1983 void	SwTOXButton::KeyInput( const KeyEvent& rKEvt )
1984 {
1985 	sal_Bool bCall = sal_False;
1986 	KeyCode aCode = rKEvt.GetKeyCode();
1987 	if(aCode.GetCode() == KEY_RIGHT)
1988 	{
1989 		bNextControl = sal_True;
1990 		bCall = sal_True;
1991 	}
1992 	else if(aCode.GetCode() == KEY_LEFT  )
1993 	{
1994 		bNextControl = sal_False;
1995 		bCall = sal_True;
1996 	}
1997 	else if(aCode.GetCode() == KEY_DELETE)
1998 	{
1999 		m_pParent->RemoveControl(this, sal_True);
2000 		//this is invalid here
2001 		return;
2002 	}
2003 	if(bCall && aPrevNextControlLink.IsSet())
2004 			aPrevNextControlLink.Call(this);
2005 	else
2006 		PushButton::KeyInput(rKEvt);
2007 }
2008 //---------------------------------------------------
2009 void	SwTOXButton::RequestHelp( const HelpEvent& rHEvt )
2010 {
2011 	if(!m_pParent->CreateQuickHelp(this, aFormToken, rHEvt))
2012 		Button::RequestHelp(rHEvt);
2013 }
2014 /* -----------------------------23.12.99 14:28--------------------------------
2015 
2016  ---------------------------------------------------------------------------*/
2017 SwIdxTreeListBox::SwIdxTreeListBox(SwTOXEntryTabPage* pPar, const ResId& rResId) :
2018 		SvTreeListBox(pPar, rResId),
2019 		pParent(pPar)
2020 {
2021 }
2022 /* -----------------------------23.12.99 14:19--------------------------------
2023 
2024  ---------------------------------------------------------------------------*/
2025 void    SwIdxTreeListBox::RequestHelp( const HelpEvent& rHEvt )
2026 {
2027 	if( rHEvt.GetMode() & HELPMODE_QUICK )
2028 	{
2029 	 Point aPos( ScreenToOutputPixel( rHEvt.GetMousePosPixel() ));
2030 		SvLBoxEntry* pEntry = GetEntry( aPos );
2031 		if( pEntry )
2032 		{
2033             sal_uInt16 nLevel = static_cast< sal_uInt16 >(GetModel()->GetAbsPos(pEntry));
2034 			String sEntry = pParent->GetLevelHelp(++nLevel);
2035 			if('*' == sEntry)
2036 				sEntry = GetEntryText(pEntry);
2037 			if(sEntry.Len())
2038 			{
2039 				SvLBoxTab* pTab;
2040 				SvLBoxItem* pItem = GetItem( pEntry, aPos.X(), &pTab );
2041 				if( pItem && SV_ITEM_ID_LBOXSTRING == pItem->IsA())
2042 				{
2043 					aPos = GetEntryPosition( pEntry );
2044 
2045 					aPos.X() = GetTabPos( pEntry, pTab );
2046 				 Size aSize( pItem->GetSize( this, pEntry ) );
2047 
2048 					if((aPos.X() + aSize.Width()) > GetSizePixel().Width())
2049 						aSize.Width() = GetSizePixel().Width() - aPos.X();
2050 
2051 					aPos = OutputToScreenPixel(aPos);
2052 				 	Rectangle aItemRect( aPos, aSize );
2053 					Help::ShowQuickHelp( this, aItemRect, sEntry,
2054 							QUICKHELP_LEFT|QUICKHELP_VCENTER );
2055 				}
2056 			}
2057 		}
2058 	}
2059 	else
2060 		SvTreeListBox::RequestHelp(rHEvt);
2061 }
2062 //---------------------------------------------------
2063 SwTOXEntryTabPage::SwTOXEntryTabPage(Window* pParent, const SfxItemSet& rAttrSet) :
2064 		SfxTabPage(pParent, SW_RES(TP_TOX_ENTRY), rAttrSet),
2065     aLevelFT(this,              SW_RES(FT_LEVEL              )),
2066     aLevelLB(this,              SW_RES(LB_LEVEL             )),
2067     aEntryFL(this,              SW_RES(FL_ENTRY              )),
2068 
2069     aTokenFT(this,              SW_RES(FT_TOKEN              )),
2070     aTokenWIN(this,             SW_RES(WIN_TOKEN             )),
2071     aAllLevelsPB(this,          SW_RES(PB_ALL_LEVELS            )),
2072 
2073     aEntryNoPB(this,            SW_RES(PB_ENTRYNO            )),
2074     aEntryPB(this,              SW_RES(PB_ENTRY             )),
2075     aTabPB(this,                SW_RES(PB_TAB                )),
2076     aChapterInfoPB(this,        SW_RES(PB_CHAPTERINFO        )),
2077     aPageNoPB(this,             SW_RES(PB_PAGENO                )),
2078     aHyperLinkPB(this,          SW_RES(PB_HYPERLINK         )),
2079 
2080     aAuthFieldsLB(this,         SW_RES(LB_AUTHFIELD          )),
2081     aAuthInsertPB(this,         SW_RES(PB_AUTHINSERT            )),
2082     aAuthRemovePB(this,         SW_RES(PB_AUTHREMOVE            )),
2083 
2084     aCharStyleFT(this,          SW_RES(FT_CHARSTYLE          )),
2085     aCharStyleLB(this,          SW_RES(LB_CHARSTYLE         )),
2086     aEditStylePB(this,          SW_RES(PB_EDITSTYLE         )),
2087 
2088     aChapterEntryFT(this,       SW_RES(FT_CHAPTERENTRY       )),
2089     aChapterEntryLB(this,       SW_RES(LB_CHAPTERENTRY       )),
2090 
2091     aNumberFormatFT(this, 		SW_RES(FT_ENTRY_NO           )),//i53420
2092     aNumberFormatLB(this, 		SW_RES(LB_ENTRY_NO           )),
2093     aEntryOutlineLevelFT(this,  SW_RES(FT_LEVEL_OL           )),//i53420
2094     aEntryOutlineLevelNF(this,  SW_RES(NF_LEVEL_OL           )),
2095 
2096     aFillCharFT(this,           SW_RES(FT_FILLCHAR           )),
2097     aFillCharCB(this,           SW_RES(CB_FILLCHAR          )),
2098     aTabPosFT(this,             SW_RES(FT_TABPOS                )),
2099     aTabPosMF(this,             SW_RES(MF_TABPOS                )),
2100     aAutoRightCB(this,          SW_RES(CB_AUTORIGHT         )),
2101     aFormatFL(this,             SW_RES(FL_FORMAT             )),
2102 
2103 
2104     aRelToStyleCB(this,         SW_RES(CB_RELTOSTYLE         )),
2105     aMainEntryStyleFT(this,     SW_RES(FT_MAIN_ENTRY_STYLE)),
2106     aMainEntryStyleLB(this,     SW_RES(LB_MAIN_ENTRY_STYLE)),
2107     aAlphaDelimCB(this,         SW_RES(CB_ALPHADELIM            )),
2108     aCommaSeparatedCB(this,     SW_RES(CB_COMMASEPARATED        )),
2109 
2110     aSortDocPosRB(this,         SW_RES(RB_DOCPOS                )),
2111     aSortContentRB(this,        SW_RES(RB_SORTCONTENT       )),
2112     aSortingFL(this,            SW_RES(FL_SORTING            )),
2113 
2114     aFirstKeyFT(this,           SW_RES(FT_FIRSTKEY          )),
2115     aFirstKeyLB(this,           SW_RES(LB_FIRSTKEY          )),
2116     aFirstSortUpRB(this,        SW_RES(RB_SORTUP1            )),
2117     aFirstSortDownRB(this,      SW_RES(RB_SORTDOWN1          )),
2118 
2119     aSecondKeyFT(this,          SW_RES(FT_SECONDKEY          )),
2120     aSecondKeyLB(this,          SW_RES(LB_SECONDKEY         )),
2121     aSecondSortUpRB(this,       SW_RES(RB_SORTUP2            )),
2122     aSecondSortDownRB(this,     SW_RES(RB_SORTDOWN2          )),
2123 
2124     aThirdKeyFT(this,           SW_RES(FT_THIRDDKEY          )),
2125     aThirdKeyLB(this,           SW_RES(LB_THIRDKEY           )),
2126     aThirdSortUpRB(this,        SW_RES(RB_SORTUP3           )),
2127     aThirdSortDownRB(this,      SW_RES(RB_SORTDOWN3          )),
2128 
2129     aSortKeyFL(this,            SW_RES(FL_SORTKEY            )),
2130 
2131     sDelimStr(                  SW_RES(STR_DELIM)),
2132     sAuthTypeStr(               SW_RES(ST_AUTHTYPE)),
2133 
2134     sNoCharStyle(               SW_RES(STR_NO_CHAR_STYLE)),
2135     sNoCharSortKey(             SW_RES(STR_NOSORTKEY        )),
2136     m_pCurrentForm(0),
2137 	bInLevelHdl(sal_False)
2138 {
2139 	aEditStylePB.SetAccessibleRelationMemberOf(&aEntryFL);
2140 	aHyperLinkPB.SetAccessibleRelationMemberOf(&aEntryFL);
2141 	aPageNoPB.SetAccessibleRelationMemberOf(&aEntryFL);
2142 	aTabPB.SetAccessibleRelationMemberOf(&aEntryFL);
2143 	aEntryPB.SetAccessibleRelationMemberOf(&aEntryFL);
2144 	aEntryNoPB.SetAccessibleRelationMemberOf(&aEntryFL);
2145 	aAllLevelsPB.SetAccessibleRelationMemberOf(&aEntryFL);
2146 	aTokenWIN.SetAccessibleRelationMemberOf(&aEntryFL);
2147 	aTokenWIN.SetAccessibleRelationLabeledBy(&aTokenFT);
2148 
2149 	Image aSortUpHC(SW_RES(IMG_SORTUP_HC ));
2150 	aFirstSortUpRB.SetModeRadioImage(aSortUpHC,BMP_COLOR_HIGHCONTRAST);
2151 	aSecondSortUpRB.SetModeRadioImage(aSortUpHC,BMP_COLOR_HIGHCONTRAST);
2152 	aThirdSortUpRB.SetModeRadioImage(aSortUpHC,BMP_COLOR_HIGHCONTRAST);
2153 
2154 	Image aSortDownHC(SW_RES(IMG_SORTDOWN_HC ));
2155 	aFirstSortDownRB.SetModeRadioImage(aSortDownHC,BMP_COLOR_HIGHCONTRAST);
2156 	aSecondSortDownRB.SetModeRadioImage(aSortDownHC,BMP_COLOR_HIGHCONTRAST);
2157 	aThirdSortDownRB.SetModeRadioImage(aSortDownHC,BMP_COLOR_HIGHCONTRAST);
2158 	FreeResource();
2159 
2160 	sLevelStr = aLevelFT.GetText();
2161 	aLevelLB.SetStyle( aLevelLB.GetStyle() | WB_HSCROLL );
2162 	aLevelLB.SetSpaceBetweenEntries(0);
2163 	aLevelLB.SetSelectionMode( SINGLE_SELECTION );
2164 	aLevelLB.SetHighlightRange();	// select full width
2165 	aLevelLB.SetHelpId(HID_INSERT_INDEX_ENTRY_LEVEL_LB);
2166 	aLevelLB.Show();
2167 
2168 	aLastTOXType.eType = (TOXTypes)USHRT_MAX;
2169 	aLastTOXType.nIndex = 0;
2170 	//aLevelGBSize = aLevelGB.GetSizePixel();
2171     aLevelFLSize = aLevelFT.GetSizePixel();
2172 
2173 	SetExchangeSupport();
2174 	aEntryNoPB.SetClickHdl(LINK(this, SwTOXEntryTabPage, InsertTokenHdl));
2175 	aEntryPB.SetClickHdl(LINK(this, SwTOXEntryTabPage, InsertTokenHdl));
2176 	aChapterInfoPB.SetClickHdl(LINK(this, SwTOXEntryTabPage, InsertTokenHdl));
2177 	aPageNoPB.SetClickHdl(LINK(this, SwTOXEntryTabPage, InsertTokenHdl));
2178 	aTabPB.SetClickHdl(LINK(this, SwTOXEntryTabPage, InsertTokenHdl));
2179 	aHyperLinkPB.SetClickHdl(LINK(this, SwTOXEntryTabPage, InsertTokenHdl));
2180 	aEditStylePB.SetClickHdl(LINK(this, SwTOXEntryTabPage, EditStyleHdl));
2181 	aLevelLB.SetSelectHdl(LINK(this, SwTOXEntryTabPage, LevelHdl));
2182 	aTokenWIN.SetButtonSelectedHdl(LINK(this, SwTOXEntryTabPage, TokenSelectedHdl));
2183 	aTokenWIN.SetModifyHdl(LINK(this, SwTOXEntryTabPage, ModifyHdl));
2184 	aCharStyleLB.SetSelectHdl(LINK(this, SwTOXEntryTabPage, StyleSelectHdl));
2185 	aCharStyleLB.InsertEntry(sNoCharStyle);
2186 	aChapterEntryLB.SetSelectHdl(LINK(this, SwTOXEntryTabPage, ChapterInfoHdl));
2187 	aEntryOutlineLevelNF.SetModifyHdl(LINK(this, SwTOXEntryTabPage, ChapterInfoOutlineHdl));
2188 	aNumberFormatLB.SetSelectHdl(LINK(this, SwTOXEntryTabPage, NumberFormatHdl));
2189 
2190 	aTabPosMF.SetModifyHdl(LINK(this, SwTOXEntryTabPage, TabPosHdl));
2191 	aFillCharCB.SetModifyHdl(LINK(this, SwTOXEntryTabPage, FillCharHdl));
2192 	aAutoRightCB.SetClickHdl(LINK(this, SwTOXEntryTabPage, AutoRightHdl));
2193 	aAuthInsertPB.SetClickHdl(LINK(this, SwTOXEntryTabPage, RemoveInsertAuthHdl));
2194 	aAuthRemovePB.SetClickHdl(LINK(this, SwTOXEntryTabPage, RemoveInsertAuthHdl));
2195 	aSortDocPosRB.SetClickHdl(LINK(this, SwTOXEntryTabPage, SortKeyHdl));
2196 	aSortContentRB.SetClickHdl(LINK(this, SwTOXEntryTabPage, SortKeyHdl));
2197 	aAllLevelsPB.SetClickHdl(LINK(this, SwTOXEntryTabPage, AllLevelsHdl));
2198 
2199 	aAlphaDelimCB.SetClickHdl(LINK(this, SwTOXEntryTabPage, ModifyHdl));
2200 	aCommaSeparatedCB.SetClickHdl(LINK(this, SwTOXEntryTabPage, ModifyHdl));
2201 	aRelToStyleCB.SetClickHdl(LINK(this, SwTOXEntryTabPage, ModifyHdl));
2202 
2203     FieldUnit aMetric = ::GetDfltMetric(sal_False);
2204     SetMetric(aTabPosMF, aMetric);
2205 
2206     aSortDocPosRB.Check();
2207 
2208 	aFillCharCB.SetMaxTextLen(1);
2209 	aFillCharCB.InsertEntry(' ');
2210 	aFillCharCB.InsertEntry('.');
2211 	aFillCharCB.InsertEntry('-');
2212 	aFillCharCB.InsertEntry('_');
2213 
2214 	aButtonPositions[0] = aEntryNoPB.GetPosPixel();
2215 	aButtonPositions[1] = aEntryPB.GetPosPixel();
2216 	aButtonPositions[2] = aChapterInfoPB.GetPosPixel();
2217 	aButtonPositions[3] = aPageNoPB.GetPosPixel();
2218 	aButtonPositions[4] = aTabPB.GetPosPixel();
2219 
2220 	aRelToStylePos = aRelToStyleCB.GetPosPixel();
2221 	aRelToStyleIdxPos = aCommaSeparatedCB.GetPosPixel();
2222 	aRelToStyleIdxPos.Y() +=
2223 		(aRelToStyleIdxPos.Y() - aAlphaDelimCB.GetPosPixel().Y());
2224 	aEditStylePB.Enable(sal_False);
2225 
2226 //get position for Numbering and other stuff
2227     aChapterEntryFTPosition = aChapterEntryFT.GetPosPixel();
2228     aEntryOutlineLevelFTPosition = aEntryOutlineLevelFT.GetPosPixel();
2229     nBiasToEntryPoint = aEntryOutlineLevelNF.GetPosPixel().X() -
2230                                aEntryOutlineLevelFT.GetPosPixel().X();
2231 
2232 	//fill the types in
2233     sal_uInt16 i;
2234 	for( i = 0; i < AUTH_FIELD_END; i++)
2235 	{
2236 		String sTmp(SW_RES(STR_AUTH_FIELD_START + i));
2237 		sal_uInt16 nPos = aAuthFieldsLB.InsertEntry(sTmp);
2238         aAuthFieldsLB.SetEntryData(nPos, reinterpret_cast< void * >(sal::static_int_cast< sal_uIntPtr >(i)));
2239 	}
2240 	sal_uInt16 nPos = aFirstKeyLB.InsertEntry(sNoCharSortKey);
2241     aFirstKeyLB.SetEntryData(nPos, reinterpret_cast< void * >(sal::static_int_cast< sal_uIntPtr >(USHRT_MAX)));
2242 	nPos = aSecondKeyLB.InsertEntry(sNoCharSortKey);
2243     aSecondKeyLB.SetEntryData(nPos, reinterpret_cast< void * >(sal::static_int_cast< sal_uIntPtr >(USHRT_MAX)));
2244 	nPos = aThirdKeyLB.InsertEntry(sNoCharSortKey);
2245     aThirdKeyLB.SetEntryData(nPos, reinterpret_cast< void * >(sal::static_int_cast< sal_uIntPtr >(USHRT_MAX)));
2246 
2247 	for( i = 0; i < AUTH_FIELD_END; i++)
2248 	{
2249 		String sTmp(aAuthFieldsLB.GetEntry(i));
2250 		void* pEntryData = aAuthFieldsLB.GetEntryData(i);
2251 		nPos = aFirstKeyLB.InsertEntry(sTmp);
2252 		aFirstKeyLB.SetEntryData(nPos, pEntryData);
2253 		nPos = aSecondKeyLB.InsertEntry(sTmp);
2254 		aSecondKeyLB.SetEntryData(nPos, pEntryData);
2255 		nPos = aThirdKeyLB.InsertEntry(sTmp);
2256 		aThirdKeyLB.SetEntryData(nPos, pEntryData);
2257 	}
2258 	aFirstKeyLB.SelectEntryPos(0);
2259 	aSecondKeyLB.SelectEntryPos(0);
2260 	aThirdKeyLB.SelectEntryPos(0);
2261 }
2262 /* -----------------30.11.99 13:37-------------------
2263 	pVoid is used as signal to change all levels of the example
2264  --------------------------------------------------*/
2265 IMPL_LINK(SwTOXEntryTabPage, ModifyHdl, void*, pVoid)
2266 {
2267 	UpdateDescriptor();
2268 	SwMultiTOXTabDialog* pTOXDlg = (SwMultiTOXTabDialog*)GetTabDialog();
2269 
2270 	if(pTOXDlg)
2271 	{
2272         sal_uInt16 nCurLevel = static_cast< sal_uInt16 >(aLevelLB.GetModel()->GetAbsPos(aLevelLB.FirstSelected()) + 1);
2273 		if(aLastTOXType.eType == TOX_CONTENT && pVoid)
2274 			nCurLevel = USHRT_MAX;
2275 		pTOXDlg->CreateOrUpdateExample(
2276 			pTOXDlg->GetCurrentTOXType().eType, TOX_PAGE_ENTRY, nCurLevel);
2277 	}
2278 	return 0;
2279 }
2280 
2281 /*-- 16.06.99 10:47:33---------------------------------------------------
2282 
2283   -----------------------------------------------------------------------*/
2284 SwTOXEntryTabPage::~SwTOXEntryTabPage()
2285 {
2286 }
2287 /*-- 16.06.99 10:47:33---------------------------------------------------
2288 
2289   -----------------------------------------------------------------------*/
2290 sal_Bool	SwTOXEntryTabPage::FillItemSet( SfxItemSet& )
2291 {
2292 	// nothing to do
2293 	return sal_True;
2294 }
2295 /*-- 16.06.99 10:47:34---------------------------------------------------
2296 
2297   -----------------------------------------------------------------------*/
2298 void SwTOXEntryTabPage::Reset( const SfxItemSet& )
2299 {
2300 	SwMultiTOXTabDialog* pTOXDlg = (SwMultiTOXTabDialog*)GetTabDialog();
2301 	const CurTOXType aCurType = pTOXDlg->GetCurrentTOXType();
2302     m_pCurrentForm = pTOXDlg->GetForm(aCurType);
2303 	if(TOX_INDEX == aCurType.eType)
2304 	{
2305 		SwTOXDescription& rDesc = pTOXDlg->GetTOXDescription(aCurType);
2306 		String sMainEntryCharStyle = rDesc.GetMainEntryCharStyle();
2307 		if(sMainEntryCharStyle.Len())
2308 		{
2309 			if( LISTBOX_ENTRY_NOTFOUND ==
2310 					aMainEntryStyleLB.GetEntryPos(sMainEntryCharStyle))
2311 				aMainEntryStyleLB.InsertEntry(
2312 						sMainEntryCharStyle);
2313 			aMainEntryStyleLB.SelectEntry(sMainEntryCharStyle);
2314 		}
2315         else
2316 			aMainEntryStyleLB.SelectEntry(sNoCharStyle);
2317         aAlphaDelimCB.Check( 0 != (rDesc.GetIndexOptions() & nsSwTOIOptions::TOI_ALPHA_DELIMITTER) );
2318 	}
2319     aRelToStyleCB.Check(m_pCurrentForm->IsRelTabPos());
2320     aCommaSeparatedCB.Check(m_pCurrentForm->IsCommaSeparated());
2321 }
2322 /*-- 16.06.99 10:47:34---------------------------------------------------
2323 
2324   -----------------------------------------------------------------------*/
2325 void lcl_ChgWidth(Window& rWin, long nDiff)
2326 {
2327  Size aTempSz(rWin.GetSizePixel());
2328 	aTempSz.Width() += nDiff;
2329 	rWin.SetSizePixel(aTempSz);
2330 }
2331 /* ----------------------------------------------------------------------
2332 
2333   -----------------------------------------------------------------------*/
2334 void lcl_ChgXPos(Window& rWin, long nDiff)
2335 {
2336 	Point aTempPos(rWin.GetPosPixel());
2337 	aTempPos.X() += nDiff;
2338 	rWin.SetPosPixel(aTempPos);
2339 }
2340 /* ----------------------------------------------------------------------
2341 
2342   -----------------------------------------------------------------------*/
2343 void SwTOXEntryTabPage::ActivatePage( const SfxItemSet& /*rSet*/)
2344 {
2345 	SwMultiTOXTabDialog* pTOXDlg = (SwMultiTOXTabDialog*)GetTabDialog();
2346 	const CurTOXType aCurType = pTOXDlg->GetCurrentTOXType();
2347 
2348     m_pCurrentForm = pTOXDlg->GetForm(aCurType);
2349 	if( !( aLastTOXType == aCurType ))
2350 	{
2351 		sal_Bool bToxIsAuthorities = TOX_AUTHORITIES == aCurType.eType;
2352 		sal_Bool bToxIsIndex =       TOX_INDEX == aCurType.eType;
2353 		sal_Bool bToxIsContent =     TOX_CONTENT == aCurType.eType;
2354 
2355 		aLevelLB.Clear();
2356         for(sal_uInt16 i = 1; i < m_pCurrentForm->GetFormMax(); i++)
2357 		{
2358 			if(bToxIsAuthorities)
2359 				aLevelLB.InsertEntry( SwAuthorityFieldType::GetAuthTypeName(
2360 											(ToxAuthorityType) (i - 1)) );
2361 			else if( bToxIsIndex )
2362 			{
2363 				if(i == 1)
2364 					aLevelLB.InsertEntry( sDelimStr );
2365 				else
2366 					aLevelLB.InsertEntry( String::CreateFromInt32(i - 1) );
2367 			}
2368 			else
2369 				aLevelLB.InsertEntry(String::CreateFromInt32(i));
2370 		}
2371 		if(bToxIsAuthorities)
2372 		{
2373 			//
2374 			SwWrtShell& rSh = pTOXDlg->GetWrtShell();
2375 			const SwAuthorityFieldType* pFType = (const SwAuthorityFieldType*)
2376 									rSh.GetFldType(RES_AUTHORITY, aEmptyStr);
2377 			if(pFType)
2378 			{
2379 				if(pFType->IsSortByDocument())
2380 					aSortDocPosRB.Check();
2381 				else
2382 				{
2383 					aSortContentRB.Check();
2384 					sal_uInt16 nKeyCount = pFType->GetSortKeyCount();
2385 					if(0 < nKeyCount)
2386 					{
2387 						const SwTOXSortKey* pKey = pFType->GetSortKey(0);
2388 						aFirstKeyLB.SelectEntryPos(
2389 							aFirstKeyLB.GetEntryPos((void*)(sal_uInt32)pKey->eField));
2390 						aFirstSortUpRB.Check(pKey->bSortAscending);
2391 						aFirstSortDownRB.Check(!pKey->bSortAscending);
2392 					}
2393 					if(1 < nKeyCount)
2394 					{
2395 						const SwTOXSortKey* pKey = pFType->GetSortKey(1);
2396 						aSecondKeyLB.SelectEntryPos(
2397 							aSecondKeyLB.GetEntryPos((void*)(sal_uInt32)pKey->eField));
2398 						aSecondSortUpRB.Check(pKey->bSortAscending);
2399 						aSecondSortDownRB.Check(!pKey->bSortAscending);
2400 					}
2401 					if(2 < nKeyCount)
2402 					{
2403 						const SwTOXSortKey* pKey = pFType->GetSortKey(2);
2404 						aThirdKeyLB.SelectEntryPos(
2405 							aThirdKeyLB.GetEntryPos((void*)(sal_uInt32)pKey->eField));
2406 						aThirdSortUpRB.Check(pKey->bSortAscending);
2407 						aThirdSortDownRB.Check(!pKey->bSortAscending);
2408 					}
2409 				}
2410 			}
2411 			SortKeyHdl(aSortDocPosRB.IsChecked() ? &aSortDocPosRB : &aSortContentRB);
2412 			aLevelFT.SetText(sAuthTypeStr);
2413 		}
2414 		else
2415 			aLevelFT.SetText(sLevelStr);
2416 
2417 		long nDiff = 0;
2418         if( bToxIsAuthorities ? aLevelFT.GetSizePixel() == aLevelFLSize
2419                               : aLevelFT.GetSizePixel() != aLevelFLSize )
2420 		{
2421             nDiff = aLevelFLSize.Width();
2422 			if( !bToxIsAuthorities )
2423 				nDiff *= -1;
2424 		}
2425 
2426 		if(nDiff)
2427 		{
2428 //          lcl_ChgWidth(aLevelFL, nDiff);
2429 			lcl_ChgWidth(aLevelFT, nDiff);
2430 			lcl_ChgWidth(aLevelLB, nDiff);
2431 			lcl_ChgXPos(aCharStyleFT, nDiff);
2432 			lcl_ChgXPos(aCharStyleLB, nDiff);
2433 			lcl_ChgWidth(aCharStyleLB, -nDiff);
2434 	//			lcl_ChgXPos(aEditStylePB, -nDiff);
2435 			lcl_ChgXPos(aFillCharFT,  nDiff);
2436 			lcl_ChgXPos(aFillCharCB,  nDiff);
2437 			lcl_ChgXPos(aTabPosFT, 	 nDiff);
2438 			lcl_ChgXPos(aTabPosMF, 	 nDiff);
2439 			lcl_ChgXPos(aAutoRightCB, nDiff);
2440 			lcl_ChgXPos(aAuthFieldsLB, 	 nDiff);
2441 			lcl_ChgXPos(aAuthInsertPB, 	 nDiff);
2442 			lcl_ChgXPos(aAuthRemovePB, 	 nDiff);
2443             lcl_ChgXPos(aTokenFT, nDiff);
2444             lcl_ChgXPos(aTokenWIN,   nDiff);
2445 			lcl_ChgWidth(aTokenWIN, -nDiff);
2446 			lcl_ChgXPos(aSortDocPosRB, 	 nDiff);
2447 			lcl_ChgXPos(aSortContentRB, 	 nDiff);
2448             lcl_ChgXPos(aFormatFL,  nDiff);
2449             lcl_ChgWidth(aFormatFL,     -nDiff);
2450             lcl_ChgXPos(aSortingFL, nDiff);
2451             lcl_ChgWidth(aSortingFL,    -nDiff);
2452             lcl_ChgXPos(aEntryFL,   nDiff);
2453             lcl_ChgWidth(aEntryFL,  -nDiff);
2454 
2455 			lcl_ChgXPos(aFirstKeyFT, nDiff);
2456 			lcl_ChgXPos(aFirstKeyLB, nDiff);
2457 			lcl_ChgXPos(aSecondKeyFT, nDiff);
2458 			lcl_ChgXPos(aSecondKeyLB, nDiff);
2459 			lcl_ChgXPos(aThirdKeyFT, nDiff);
2460 			lcl_ChgXPos(aThirdKeyLB, nDiff);
2461             lcl_ChgXPos(aSortKeyFL,     nDiff);
2462 
2463 			lcl_ChgWidth(aFirstKeyLB, -nDiff);
2464 			lcl_ChgWidth(aSecondKeyLB, -nDiff);
2465 			lcl_ChgWidth(aThirdKeyLB, -nDiff);
2466             lcl_ChgWidth(aSortKeyFL, -nDiff);
2467 		}
2468 		Link aLink = aLevelLB.GetSelectHdl();
2469 		aLevelLB.SetSelectHdl(Link());
2470 		aLevelLB.Select( aLevelLB.GetEntry( bToxIsIndex ? 1 : 0 ) );
2471 		aLevelLB.SetSelectHdl(aLink);
2472 
2473 		// sort token buttons
2474 		aEntryNoPB.SetPosPixel(aButtonPositions[0]);
2475 		aEntryPB.SetPosPixel(aButtonPositions[ bToxIsContent ? 1 : 0]);
2476 		aChapterInfoPB.SetPosPixel(aButtonPositions[2]);
2477 		aPageNoPB.SetPosPixel(aButtonPositions[3]);
2478 		sal_uInt16 nBtPos = 1;
2479 		if( bToxIsContent )
2480 			nBtPos = 2;
2481 		else if( bToxIsAuthorities )
2482 			nBtPos = 4;
2483 		aTabPB.SetPosPixel(aButtonPositions[nBtPos]);
2484 		aHyperLinkPB.SetPosPixel(aButtonPositions[4]);
2485 
2486 		//show or hide controls
2487 		aEntryNoPB.Show(		bToxIsContent );
2488 		aHyperLinkPB.Show(		bToxIsContent );
2489 		aRelToStyleCB.Show(	   !bToxIsAuthorities );
2490         aChapterInfoPB.Show(    !bToxIsContent && !bToxIsAuthorities);
2491 		aEntryPB.Show(		   !bToxIsAuthorities );
2492 		aPageNoPB.Show(		   !bToxIsAuthorities );
2493 		aAuthFieldsLB.Show(		bToxIsAuthorities );
2494 		aAuthInsertPB.Show(		bToxIsAuthorities );
2495 		aAuthRemovePB.Show(		bToxIsAuthorities );
2496         aFormatFL.Show(        !bToxIsAuthorities );
2497 		aSortDocPosRB.Show(		bToxIsAuthorities );
2498 		aSortContentRB.Show(	bToxIsAuthorities );
2499         aSortingFL.Show(        bToxIsAuthorities );
2500 		aFirstKeyFT.Show(		bToxIsAuthorities );
2501 		aFirstKeyLB.Show(		bToxIsAuthorities );
2502 		aSecondKeyFT.Show(		bToxIsAuthorities );
2503 		aSecondKeyLB.Show(		bToxIsAuthorities );
2504 		aThirdKeyFT.Show(		bToxIsAuthorities );
2505 		aThirdKeyLB.Show(		bToxIsAuthorities );
2506         aSortKeyFL.Show(        bToxIsAuthorities );
2507 		aFirstSortUpRB.Show(	bToxIsAuthorities );
2508 		aFirstSortDownRB.Show(	bToxIsAuthorities );
2509 		aSecondSortUpRB.Show(	bToxIsAuthorities );
2510 		aSecondSortDownRB.Show(	bToxIsAuthorities );
2511 		aThirdSortUpRB.Show(	bToxIsAuthorities );
2512 		aThirdSortDownRB.Show(	bToxIsAuthorities );
2513 
2514 		aRelToStyleCB.SetPosPixel( bToxIsIndex ? aRelToStyleIdxPos
2515 											   : aRelToStylePos );
2516 
2517 //		aRecalcTabCB.Show(	aCurType.eType == TOX_CONTENT);
2518 
2519 		aMainEntryStyleFT.Show(	bToxIsIndex );
2520 		aMainEntryStyleLB.Show(	bToxIsIndex );
2521 		aAlphaDelimCB.Show(		bToxIsIndex );
2522 		aCommaSeparatedCB.Show(	bToxIsIndex );
2523 	}
2524 	aLastTOXType = aCurType;
2525 
2526 	//invalidate PatternWindow
2527 	aTokenWIN.SetInvalid();
2528 	LevelHdl(&aLevelLB);
2529 }
2530 /* -----------------30.11.99 15:04-------------------
2531 
2532  --------------------------------------------------*/
2533 void SwTOXEntryTabPage::UpdateDescriptor()
2534 {
2535 	WriteBackLevel();
2536 	SwMultiTOXTabDialog* pTOXDlg = (SwMultiTOXTabDialog*)GetTabDialog();
2537 	SwTOXDescription& rDesc = pTOXDlg->GetTOXDescription(aLastTOXType);
2538 	if(TOX_INDEX == aLastTOXType.eType)
2539 	{
2540 		String sTemp(aMainEntryStyleLB.GetSelectEntry());
2541 		rDesc.SetMainEntryCharStyle(sNoCharStyle == sTemp ? aEmptyStr : sTemp);
2542         sal_uInt16 nIdxOptions = rDesc.GetIndexOptions() & ~nsSwTOIOptions::TOI_ALPHA_DELIMITTER;
2543 		if(aAlphaDelimCB.IsChecked())
2544             nIdxOptions |= nsSwTOIOptions::TOI_ALPHA_DELIMITTER;
2545 		rDesc.SetIndexOptions(nIdxOptions);
2546 	}
2547 	else if(TOX_AUTHORITIES == aLastTOXType.eType)
2548 	{
2549 		rDesc.SetSortByDocument(aSortDocPosRB.IsChecked());
2550 		SwTOXSortKey aKey1, aKey2, aKey3;
2551 		aKey1.eField = (ToxAuthorityField)(sal_uIntPtr)aFirstKeyLB.GetEntryData(
2552 									aFirstKeyLB.GetSelectEntryPos());
2553 		aKey1.bSortAscending = aFirstSortUpRB.IsChecked();
2554 		aKey2.eField = (ToxAuthorityField)(sal_uIntPtr)aSecondKeyLB.GetEntryData(
2555 									aSecondKeyLB.GetSelectEntryPos());
2556 		aKey2.bSortAscending = aSecondSortUpRB.IsChecked();
2557 		aKey3.eField = (ToxAuthorityField)(sal_uIntPtr)aThirdKeyLB.GetEntryData(
2558 								aThirdKeyLB.GetSelectEntryPos());
2559 		aKey3.bSortAscending = aThirdSortUpRB.IsChecked();
2560 
2561 
2562 		rDesc.SetSortKeys(aKey1, aKey2, aKey3);
2563 	}
2564 	SwForm*	pCurrentForm = pTOXDlg->GetForm(aLastTOXType);
2565 	if(aRelToStyleCB.IsVisible())
2566 	{
2567 		pCurrentForm->SetRelTabPos(aRelToStyleCB.IsChecked());
2568 	}
2569 	if(aCommaSeparatedCB.IsVisible())
2570 		pCurrentForm->SetCommaSeparated(aCommaSeparatedCB.IsChecked());
2571 }
2572 /*-- 16.06.99 10:47:34---------------------------------------------------
2573 
2574   -----------------------------------------------------------------------*/
2575 int SwTOXEntryTabPage::DeactivatePage( SfxItemSet* /*pSet*/)
2576 {
2577 	UpdateDescriptor();
2578 	return LEAVE_PAGE;
2579 }
2580 /*-- 16.06.99 10:47:34---------------------------------------------------
2581 
2582   -----------------------------------------------------------------------*/
2583 SfxTabPage*	SwTOXEntryTabPage::Create( Window* pParent, 	const SfxItemSet& rAttrSet)
2584 {
2585 	return new SwTOXEntryTabPage(pParent, rAttrSet);
2586 }
2587 /*-- 16.06.99 10:47:35---------------------------------------------------
2588 
2589   -----------------------------------------------------------------------*/
2590 IMPL_LINK(SwTOXEntryTabPage, EditStyleHdl, PushButton*, pBtn)
2591 {
2592 	if( LISTBOX_ENTRY_NOTFOUND != aCharStyleLB.GetSelectEntryPos())
2593 	{
2594 		SfxStringItem aStyle(SID_STYLE_EDIT, aCharStyleLB.GetSelectEntry());
2595 		SfxUInt16Item aFamily(SID_STYLE_FAMILY, SFX_STYLE_FAMILY_CHAR);
2596 		// TODO: WrtShell?
2597 //		SwPtrItem aShell(FN_PARAM_WRTSHELL, pWrtShell);
2598 		Window* pDefDlgParent = Application::GetDefDialogParent();
2599 		Application::SetDefDialogParent( pBtn );
2600 		((SwMultiTOXTabDialog*)GetTabDialog())->GetWrtShell().
2601 		GetView().GetViewFrame()->GetDispatcher()->Execute(
2602 		SID_STYLE_EDIT, SFX_CALLMODE_SYNCHRON|SFX_CALLMODE_MODAL,
2603 			&aStyle, &aFamily/*, &aShell*/, 0L);
2604 		Application::SetDefDialogParent( pDefDlgParent );
2605 	}
2606 	return 0;
2607 }
2608 /* -----------------04.10.99 11:34-------------------
2609 
2610  --------------------------------------------------*/
2611 IMPL_LINK(SwTOXEntryTabPage, RemoveInsertAuthHdl, PushButton*, pButton)
2612 {
2613 	sal_Bool bInsert = pButton == &aAuthInsertPB;
2614 	if(bInsert)
2615 	{
2616 		sal_uInt16 nSelPos = aAuthFieldsLB.GetSelectEntryPos();
2617 		String sToInsert(aAuthFieldsLB.GetSelectEntry());
2618 		SwFormToken aInsert(TOKEN_AUTHORITY);
2619 		aInsert.nAuthorityField = (sal_uInt16)(sal_uIntPtr)aAuthFieldsLB.GetEntryData(nSelPos);
2620 		aTokenWIN.InsertAtSelection(String::CreateFromAscii(
2621 											SwForm::aFormAuth), aInsert);
2622 		aAuthFieldsLB.RemoveEntry(sToInsert);
2623 		aAuthFieldsLB.SelectEntryPos( nSelPos ? nSelPos - 1 : 0);
2624 	}
2625 	else
2626 	{
2627 		Control* pCtrl = aTokenWIN.GetActiveControl();
2628 		DBG_ASSERT(WINDOW_EDIT != pCtrl->GetType(), "Remove should be disabled");
2629 		if( WINDOW_EDIT != pCtrl->GetType() )
2630 		{
2631 			//fill it into the ListBox
2632 			const SwFormToken& rToken = ((SwTOXButton*)pCtrl)->GetFormToken();
2633 			PreTokenButtonRemoved(rToken);
2634 			aTokenWIN.RemoveControl((SwTOXButton*)pCtrl);
2635 		}
2636 	}
2637 	ModifyHdl(0);
2638 	return 0;
2639 }
2640 /* -----------------------------17.01.00 13:44--------------------------------
2641 
2642  ---------------------------------------------------------------------------*/
2643 void SwTOXEntryTabPage::PreTokenButtonRemoved(const SwFormToken& rToken)
2644 {
2645 	//fill it into the ListBox
2646 	sal_uInt32 nData = rToken.nAuthorityField;
2647 	String sTemp(SW_RES(STR_AUTH_FIELD_START + nData));
2648 	sal_uInt16 nPos = aAuthFieldsLB.InsertEntry(sTemp);
2649 	aAuthFieldsLB.SetEntryData(nPos, (void*)(nData));
2650 }
2651 /*-- 16.06.99 10:47:35---------------------------------------------------
2652 
2653 This function inizializes the default value in the Token
2654 put here the UI dependent initializations
2655   -----------------------------------------------------------------------*/
2656 IMPL_LINK(SwTOXEntryTabPage, InsertTokenHdl, PushButton*, pBtn)
2657 {
2658 	String sText;
2659     FormTokenType eTokenType = TOKEN_ENTRY_NO;
2660     String sCharStyle;
2661     sal_uInt16  nChapterFormat = CF_NUMBER; // i89791
2662 	if(pBtn == &aEntryNoPB)
2663 	{
2664 		sText.AssignAscii(SwForm::aFormEntryNum);
2665 		eTokenType = TOKEN_ENTRY_NO;
2666 	}
2667 	else if(pBtn == &aEntryPB)
2668 	{
2669         if( TOX_CONTENT == m_pCurrentForm->GetTOXType() )
2670 		{
2671 			sText.AssignAscii( SwForm::aFormEntryTxt );
2672 			eTokenType = TOKEN_ENTRY_TEXT;
2673 		}
2674 		else
2675 		{
2676 			sText.AssignAscii( SwForm::aFormEntry);
2677 			eTokenType = TOKEN_ENTRY;
2678 		}
2679 	}
2680 	else if(pBtn == &aChapterInfoPB)
2681 	{
2682 		sText.AssignAscii( SwForm::aFormChapterMark);
2683 		eTokenType = TOKEN_CHAPTER_INFO;
2684         nChapterFormat = CF_NUM_NOPREPST_TITLE; // i89791
2685 	}
2686 	else if(pBtn == &aPageNoPB)
2687 	{
2688 		sText.AssignAscii(SwForm::aFormPageNums);
2689 		eTokenType = TOKEN_PAGE_NUMS;
2690 	}
2691 	else if(pBtn == &aHyperLinkPB)
2692 	{
2693 		sText.AssignAscii(SwForm::aFormLinkStt);
2694 		eTokenType = TOKEN_LINK_START;
2695         sCharStyle = String(SW_RES(STR_POOLCHR_INET_NORMAL));
2696 	}
2697 	else if(pBtn == &aTabPB)
2698 	{
2699 		sText.AssignAscii(SwForm::aFormTab);
2700 		eTokenType = TOKEN_TAB_STOP;
2701 	}
2702 	SwFormToken aInsert(eTokenType);
2703     aInsert.sCharStyleName = sCharStyle;
2704 	aInsert.nTabStopPosition = 0;
2705     aInsert.nChapterFormat = nChapterFormat; // i89791
2706 	aTokenWIN.InsertAtSelection(sText, aInsert);
2707 	ModifyHdl(0);
2708 	return 0;
2709 }
2710 /* -----------------------------14.01.00 11:53--------------------------------
2711 
2712  ---------------------------------------------------------------------------*/
2713 IMPL_LINK(SwTOXEntryTabPage, AllLevelsHdl, PushButton*, EMPTYARG)
2714 {
2715 	//get current level
2716 	//write it into all levels
2717 	if(aTokenWIN.IsValid())
2718 	{
2719 		String sNewToken = aTokenWIN.GetPattern();
2720         for(sal_uInt16 i = 1; i < m_pCurrentForm->GetFormMax(); i++)
2721             m_pCurrentForm->SetPattern(i, sNewToken);
2722 		//
2723 		ModifyHdl(this);
2724 	}
2725 	return 0;
2726 }
2727 
2728 /* -----------------02.12.99 12:40-------------------
2729 
2730  --------------------------------------------------*/
2731 void SwTOXEntryTabPage::WriteBackLevel()
2732 {
2733 	if(aTokenWIN.IsValid())
2734 	{
2735 		String sNewToken = aTokenWIN.GetPattern();
2736 		sal_uInt16 nLastLevel = aTokenWIN.GetLastLevel();
2737 		if(nLastLevel != USHRT_MAX)
2738             m_pCurrentForm->SetPattern(nLastLevel + 1, sNewToken );
2739 	}
2740 }
2741 /*-- 16.06.99 10:47:35---------------------------------------------------
2742 
2743   -----------------------------------------------------------------------*/
2744 IMPL_LINK(SwTOXEntryTabPage, LevelHdl, SvTreeListBox*, pBox)
2745 {
2746 	if(bInLevelHdl)
2747 		return 0;
2748 	bInLevelHdl = sal_True;
2749 	WriteBackLevel();
2750 
2751     sal_uInt16 nLevel = static_cast< sal_uInt16 >(pBox->GetModel()->GetAbsPos(pBox->FirstSelected()));
2752     aTokenWIN.SetForm(*m_pCurrentForm, nLevel);
2753     if(TOX_AUTHORITIES == m_pCurrentForm->GetTOXType())
2754 	{
2755 		//fill the types in
2756 		aAuthFieldsLB.Clear();
2757 		for( sal_uInt32 i = 0; i < AUTH_FIELD_END; i++)
2758 		{
2759 			String sTmp(SW_RES(STR_AUTH_FIELD_START + i));
2760 			sal_uInt16 nPos = aAuthFieldsLB.InsertEntry(sTmp);
2761 			aAuthFieldsLB.SetEntryData(nPos, (void*)(i));
2762 		}
2763 
2764         // #i21237#
2765         SwFormTokens aPattern = m_pCurrentForm->GetPattern(nLevel + 1);
2766         SwFormTokens::iterator aIt = aPattern.begin();;
2767 
2768 		while(aIt != aPattern.end())
2769 		{
2770 			SwFormToken aToken = *aIt; // #i21237#
2771 			if(TOKEN_AUTHORITY == aToken.eTokenType)
2772 			{
2773 				sal_uInt32 nSearch = aToken.nAuthorityField;
2774 				sal_uInt16	nLstBoxPos = aAuthFieldsLB.GetEntryPos( (void*) nSearch );
2775 				DBG_ASSERT(LISTBOX_ENTRY_NOTFOUND != nLstBoxPos, "Entry not found?");
2776 				aAuthFieldsLB.RemoveEntry(nLstBoxPos);
2777 			}
2778 
2779             aIt++; // #i21237#
2780 		}
2781 		aAuthFieldsLB.SelectEntryPos(0);
2782 	}
2783     bInLevelHdl = sal_False;
2784 	pBox->GrabFocus();
2785 	return 0;
2786 }
2787 /* -----------------20.10.99 13:16-------------------
2788 
2789  --------------------------------------------------*/
2790 IMPL_LINK(SwTOXEntryTabPage, SortKeyHdl, RadioButton*, pButton)
2791 {
2792 	sal_Bool bEnable = &aSortContentRB == pButton;
2793 	aFirstKeyFT.Enable(bEnable);
2794 	aFirstKeyLB.Enable(bEnable);
2795 	aSecondKeyFT.Enable(bEnable);
2796 	aSecondKeyLB.Enable(bEnable);
2797 	aThirdKeyFT.Enable(bEnable);
2798 	aThirdKeyLB.Enable(bEnable);
2799     aSortKeyFL.Enable(bEnable);
2800 	aFirstSortUpRB.Enable(bEnable);
2801 	aFirstSortDownRB.Enable(bEnable);
2802 	aSecondSortUpRB.Enable(bEnable);
2803 	aSecondSortDownRB.Enable(bEnable);
2804 	aThirdSortUpRB.Enable(bEnable);
2805 	aThirdSortDownRB.Enable(bEnable);
2806 	return 0;
2807 }
2808 /* -----------------01.07.99 12:21-------------------
2809 
2810  --------------------------------------------------*/
2811 IMPL_LINK(SwTOXEntryTabPage, TokenSelectedHdl, SwFormToken*, pToken)
2812 {
2813 	if(pToken->sCharStyleName.Len())
2814 		aCharStyleLB.SelectEntry(pToken->sCharStyleName);
2815 	else
2816 		aCharStyleLB.SelectEntry(sNoCharStyle);
2817 	//StyleSelectHdl(&aCharStyleLB);
2818 
2819 	String sEntry = aCharStyleLB.GetSelectEntry();
2820     aEditStylePB.Enable(sEntry != sNoCharStyle);
2821 
2822 	if(pToken->eTokenType == TOKEN_CHAPTER_INFO)
2823 	{
2824 //---> i89791
2825         switch(pToken->nChapterFormat)
2826         {
2827         default:
2828             aChapterEntryLB.SetNoSelection();//to alert the user
2829             break;
2830         case CF_NUM_NOPREPST_TITLE:
2831             aChapterEntryLB.SelectEntryPos(0);
2832             break;
2833         case CF_TITLE:
2834             aChapterEntryLB.SelectEntryPos(1);
2835            break;
2836         case CF_NUMBER_NOPREPST:
2837             aChapterEntryLB.SelectEntryPos(2);
2838             break;
2839         }
2840 //<---
2841 //i53420
2842 //move into position the fixed text
2843 //         aEntryOutlineLevelFT.SetPosPixel( aEntryOutlineLevelFTPosition );
2844 // // then the entry
2845 //         Point aPoint;
2846 //         aPoint.Y() = aEntryOutlineLevelFTPosition.Y();
2847 //         aPoint.X() = aEntryOutlineLevelFTPosition.X() + nBiasToEntryPoint;
2848 //         aEntryOutlineLevelNF.SetPosPixel( aPoint );
2849 
2850         aEntryOutlineLevelNF.SetValue(pToken->nOutlineLevel);
2851 	}
2852 
2853 //i53420
2854 	if(pToken->eTokenType == TOKEN_ENTRY_NO)
2855     {
2856 //move into position the fixed text
2857 //        aEntryOutlineLevelFT.SetPosPixel( aChapterEntryFTPosition );
2858 // // then the entry
2859 //         Point aPoint;
2860 //         aPoint.Y() = aChapterEntryFTPosition.Y();
2861 //         aPoint.X() = aChapterEntryFTPosition.X() + nBiasToEntryPoint;
2862 //         aEntryOutlineLevelNF.SetPosPixel( aPoint );
2863 
2864         aEntryOutlineLevelNF.SetValue(pToken->nOutlineLevel);
2865         sal_uInt16 nFormat = 0;
2866         if( pToken->nChapterFormat == CF_NUM_NOPREPST_TITLE )
2867             nFormat = 1;
2868         aNumberFormatLB.SelectEntryPos(nFormat);
2869     }
2870 
2871     sal_Bool bTabStop = TOKEN_TAB_STOP == pToken->eTokenType;
2872     aFillCharFT.Show(bTabStop);
2873 	aFillCharCB.Show(bTabStop);
2874 	aTabPosFT.Show(bTabStop);
2875 	aTabPosMF.Show(bTabStop);
2876 	aAutoRightCB.Show(bTabStop);
2877 	aAutoRightCB.Enable(bTabStop);
2878 	if(bTabStop)
2879 	{
2880 		aTabPosMF.SetValue(aTabPosMF.Normalize(pToken->nTabStopPosition), FUNIT_TWIP);
2881 		aAutoRightCB.Check(SVX_TAB_ADJUST_END == pToken->eTabAlign);
2882 		aFillCharCB.SetText(pToken->cTabFillChar);
2883 		aTabPosFT.Enable(!aAutoRightCB.IsChecked());
2884 		aTabPosMF.Enable(!aAutoRightCB.IsChecked());
2885 	}
2886 	else
2887 	{
2888 		aTabPosMF.Enable(sal_False);
2889 	}
2890 
2891     sal_Bool bIsChapterInfo = pToken->eTokenType == TOKEN_CHAPTER_INFO;
2892     sal_Bool bIsEntryNumber = pToken->eTokenType == TOKEN_ENTRY_NO;
2893 	aChapterEntryFT.Show( bIsChapterInfo );
2894 	aChapterEntryLB.Show( bIsChapterInfo );
2895     aEntryOutlineLevelFT.Show( bIsChapterInfo || bIsEntryNumber );
2896     aEntryOutlineLevelNF.Show( bIsChapterInfo || bIsEntryNumber );
2897     aNumberFormatFT.Show( bIsEntryNumber );
2898     aNumberFormatLB.Show( bIsEntryNumber );
2899 
2900 
2901 	//now enable the visible buttons
2902 	//- inserting the same type of control is not allowed
2903 	//- some types of controls can only appear once (EntryText EntryNumber)
2904 
2905 	if(aEntryNoPB.IsVisible())
2906 	{
2907 		aEntryNoPB.Enable(TOKEN_ENTRY_NO != pToken->eTokenType );
2908 	}
2909 	if(aEntryPB.IsVisible())
2910 	{
2911 		aEntryPB.Enable(TOKEN_ENTRY_TEXT != pToken->eTokenType &&
2912 								!aTokenWIN.Contains(TOKEN_ENTRY_TEXT)
2913 								&& !aTokenWIN.Contains(TOKEN_ENTRY));
2914 	}
2915 
2916 	if(aChapterInfoPB.IsVisible())
2917 	{
2918 		aChapterInfoPB.Enable(TOKEN_CHAPTER_INFO != pToken->eTokenType);
2919 	}
2920 	if(aPageNoPB.IsVisible())
2921 	{
2922 		aPageNoPB.Enable(TOKEN_PAGE_NUMS != pToken->eTokenType &&
2923 								!aTokenWIN.Contains(TOKEN_PAGE_NUMS));
2924 	}
2925 	if(aTabPB.IsVisible())
2926 	{
2927 		aTabPB.Enable(!bTabStop);
2928 	}
2929 	if(aHyperLinkPB.IsVisible())
2930 	{
2931 		aHyperLinkPB.Enable(TOKEN_LINK_START != pToken->eTokenType &&
2932 							TOKEN_LINK_END != pToken->eTokenType);
2933 	}
2934 	//table of authorities
2935 	if(aAuthInsertPB.IsVisible())
2936 	{
2937 		sal_Bool bText = TOKEN_TEXT == pToken->eTokenType;
2938 		aAuthInsertPB.Enable(bText && aAuthFieldsLB.GetSelectEntry().Len());
2939 		aAuthRemovePB.Enable(!bText);
2940 	}
2941 
2942 	return 0;
2943 }
2944 /* -----------------01.07.99 12:36-------------------
2945 
2946  --------------------------------------------------*/
2947 IMPL_LINK(SwTOXEntryTabPage, StyleSelectHdl, ListBox*, pBox)
2948 {
2949 	String sEntry = pBox->GetSelectEntry();
2950 	sal_uInt16 nId = (sal_uInt16)(long)pBox->GetEntryData(pBox->GetSelectEntryPos());
2951 	aEditStylePB.Enable(sEntry != sNoCharStyle);
2952 	if(sEntry == sNoCharStyle)
2953 		sEntry.Erase();
2954 	Control* pCtrl = aTokenWIN.GetActiveControl();
2955 	DBG_ASSERT(pCtrl, "no active control?");
2956 	if(pCtrl)
2957 	{
2958 		if(WINDOW_EDIT == pCtrl->GetType())
2959 			((SwTOXEdit*)pCtrl)->SetCharStyleName(sEntry, nId);
2960 		else
2961 			((SwTOXButton*)pCtrl)->SetCharStyleName(sEntry, nId);
2962 
2963 	}
2964 	ModifyHdl(0);
2965 	return 0;
2966 }
2967 /* -----------------------------11.01.00 12:54--------------------------------
2968 
2969  ---------------------------------------------------------------------------*/
2970 IMPL_LINK(SwTOXEntryTabPage, ChapterInfoHdl, ListBox*, pBox)
2971 {
2972 	sal_uInt16 nPos = pBox->GetSelectEntryPos();
2973 	if(LISTBOX_ENTRY_NOTFOUND != nPos)
2974 	{
2975 		Control* pCtrl = aTokenWIN.GetActiveControl();
2976 		DBG_ASSERT(pCtrl, "no active control?");
2977 		if(pCtrl && WINDOW_EDIT != pCtrl->GetType())
2978 			((SwTOXButton*)pCtrl)->SetChapterInfo(nPos);
2979 
2980 		ModifyHdl(0);
2981 	}
2982 	return 0;
2983 }
2984 
2985 IMPL_LINK(SwTOXEntryTabPage, ChapterInfoOutlineHdl, NumericField*, pField)
2986 {
2987     const sal_uInt16 nLevel = static_cast<sal_uInt8>(pField->GetValue());
2988 
2989     Control* pCtrl = aTokenWIN.GetActiveControl();
2990     DBG_ASSERT(pCtrl, "no active control?");
2991 	if(pCtrl && WINDOW_EDIT != pCtrl->GetType())
2992         ((SwTOXButton*)pCtrl)->SetOutlineLevel(nLevel);
2993 
2994     ModifyHdl(0);
2995 	return 0;
2996 }
2997 
2998 IMPL_LINK(SwTOXEntryTabPage, NumberFormatHdl, ListBox*, pBox)
2999 {
3000 	const sal_uInt16 nPos = pBox->GetSelectEntryPos();
3001 
3002 	if(LISTBOX_ENTRY_NOTFOUND != nPos)
3003 	{
3004 		Control* pCtrl = aTokenWIN.GetActiveControl();
3005 		DBG_ASSERT(pCtrl, "no active control?");
3006 		if(pCtrl && WINDOW_EDIT != pCtrl->GetType())
3007         {
3008            ((SwTOXButton*)pCtrl)->SetEntryNumberFormat(nPos);//i89791
3009         }
3010 		ModifyHdl(0);
3011 	}
3012 	return 0;
3013 }
3014 
3015 /* -----------------19.08.99 15:37-------------------
3016 
3017  --------------------------------------------------*/
3018 IMPL_LINK(SwTOXEntryTabPage, TabPosHdl, MetricField*, pField)
3019 {
3020 	Control* pCtrl = aTokenWIN.GetActiveControl();
3021 	DBG_ASSERT(pCtrl && WINDOW_EDIT != pCtrl->GetType() &&
3022 		TOKEN_TAB_STOP == ((SwTOXButton*)pCtrl)->GetFormToken().eTokenType,
3023 				"no active style::TabStop control?");
3024 	if( pCtrl && WINDOW_EDIT != pCtrl->GetType() )
3025 	{
3026         ((SwTOXButton*)pCtrl)->SetTabPosition( static_cast< SwTwips >(
3027                 pField->Denormalize( pField->GetValue( FUNIT_TWIP ))));
3028 	}
3029 	ModifyHdl(0);
3030 	return 0;
3031 }
3032 /* -----------------09.09.99 15:37-------------------
3033 
3034  --------------------------------------------------*/
3035 IMPL_LINK(SwTOXEntryTabPage, FillCharHdl, ComboBox*, pBox)
3036 {
3037 	Control* pCtrl = aTokenWIN.GetActiveControl();
3038 	DBG_ASSERT(pCtrl && WINDOW_EDIT != pCtrl->GetType() &&
3039 		TOKEN_TAB_STOP == ((SwTOXButton*)pCtrl)->GetFormToken().eTokenType,
3040 				"no active style::TabStop control?");
3041 	if(pCtrl && WINDOW_EDIT != pCtrl->GetType())
3042 	{
3043 		sal_Unicode cSet;
3044 		if( pBox->GetText().Len() )
3045 			cSet = pBox->GetText().GetChar(0);
3046 		else
3047 			cSet = ' ';
3048 		((SwTOXButton*)pCtrl)->SetFillChar( cSet );
3049 	}
3050 	ModifyHdl(0);
3051 	return 0;
3052 }
3053 
3054 /*-- 16.06.99 10:47:36---------------------------------------------------
3055 
3056   -----------------------------------------------------------------------*/
3057 IMPL_LINK(SwTOXEntryTabPage, AutoRightHdl, CheckBox*, pBox)
3058 {
3059 	//the most right style::TabStop is usually right aligned
3060 	Control* pCurCtrl = aTokenWIN.GetActiveControl();
3061 	DBG_ASSERT(WINDOW_EDIT != pCurCtrl->GetType() &&
3062 			((SwTOXButton*)pCurCtrl)->GetFormToken().eTokenType == TOKEN_TAB_STOP,
3063 			"no style::TabStop selected!");
3064 
3065 	const SwFormToken& rToken = ((SwTOXButton*)pCurCtrl)->GetFormToken();
3066 	sal_Bool bChecked = pBox->IsChecked();
3067 	if(rToken.eTokenType == TOKEN_TAB_STOP)
3068 		((SwTOXButton*)pCurCtrl)->SetTabAlign(
3069 			bChecked ? SVX_TAB_ADJUST_END : SVX_TAB_ADJUST_LEFT);
3070 	aTabPosFT.Enable(!bChecked);
3071 	aTabPosMF.Enable(!bChecked);
3072 	ModifyHdl(0);
3073 	return 0;
3074 }
3075 /* -----------------16.06.99 11:00-------------------
3076 
3077  --------------------------------------------------*/
3078 void SwTOXEntryTabPage::SetWrtShell(SwWrtShell& rSh)
3079 {
3080 	SwDocShell* pDocSh = rSh.GetView().GetDocShell();
3081     ::FillCharStyleListBox(aCharStyleLB, pDocSh, sal_True, sal_True);
3082     const String sDefault(SW_RES(STR_POOLCOLL_STANDARD));
3083     for(sal_uInt16 i = 0; i < aCharStyleLB.GetEntryCount(); i++)
3084 	{
3085         String sEntry = aCharStyleLB.GetEntry(i);
3086         if(sDefault != sEntry)
3087         {
3088             aMainEntryStyleLB.InsertEntry( sEntry );
3089             aMainEntryStyleLB.SetEntryData(i, aCharStyleLB.GetEntryData(i));
3090         }
3091 	}
3092 	aMainEntryStyleLB.SelectEntry( SwStyleNameMapper::GetUIName(
3093 								RES_POOLCHR_IDX_MAIN_ENTRY, aEmptyStr ));
3094 }
3095 /* -----------------------------23.12.99 14:23--------------------------------
3096 
3097  ---------------------------------------------------------------------------*/
3098 String 	SwTOXEntryTabPage::GetLevelHelp(sal_uInt16 nLevel) const
3099 {
3100 	String sRet;
3101 	SwMultiTOXTabDialog* pTOXDlg = (SwMultiTOXTabDialog*)GetTabDialog();
3102 	const CurTOXType aCurType = pTOXDlg->GetCurrentTOXType();
3103 	if( TOX_INDEX == aCurType.eType )
3104         SwStyleNameMapper::FillUIName( static_cast< sal_uInt16 >(1 == nLevel ? RES_POOLCOLL_TOX_IDXBREAK
3105                                   : RES_POOLCOLL_TOX_IDX1 + nLevel-2), sRet );
3106 
3107 	else if( TOX_AUTHORITIES == aCurType.eType )
3108 	{
3109 		//wildcard -> show entry text
3110 		sRet = '*';
3111 	}
3112 	return sRet;
3113 }
3114 /* -----------------16.06.99 15:18-------------------
3115 
3116  --------------------------------------------------*/
3117 
3118 SwTokenWindow::SwTokenWindow(SwTOXEntryTabPage* pParent, const ResId& rResId) :
3119 		Window( pParent, rResId ),
3120 		aLeftScrollWin(this, ResId(WIN_LEFT_SCROLL, *rResId.GetResMgr()	 )),
3121 		aCtrlParentWin(this, ResId(WIN_CTRL_PARENT, *rResId.GetResMgr()   )),
3122 		aRightScrollWin(this, ResId(WIN_RIGHT_SCROLL, *rResId.GetResMgr() )),
3123 		pForm(0),
3124 		nLevel(0),
3125 		bValid(sal_False),
3126         sCharStyle(ResId(STR_CHARSTYLE, *rResId.GetResMgr())),
3127 		pActiveCtrl(0),
3128         m_pParent(pParent)
3129 {
3130     SetStyle(GetStyle()|WB_TABSTOP|WB_DIALOGCONTROL);
3131     SetHelpId(HID_TOKEN_WINDOW);
3132 	for(sal_uInt16 i = 0; i < TOKEN_END; i++)
3133 	{
3134 		sal_uInt16 nTextId = STR_BUTTON_TEXT_START + i;
3135 		if( STR_TOKEN_ENTRY_TEXT == nTextId )
3136 			nTextId = STR_TOKEN_ENTRY;
3137 		aButtonTexts[i] = String(ResId(nTextId, *rResId.GetResMgr()));
3138 
3139 		sal_uInt16 nHelpId = STR_BUTTON_HELP_TEXT_START + i;
3140 		if(STR_TOKEN_HELP_ENTRY_TEXT == nHelpId)
3141 			nHelpId = STR_TOKEN_HELP_ENTRY;
3142 		aButtonHelpTexts[i] = String(ResId(nHelpId, *rResId.GetResMgr()));
3143 	}
3144 
3145 	FreeResource();
3146 
3147 	Link aLink(LINK(this, SwTokenWindow, ScrollHdl));
3148 	aLeftScrollWin.SetClickHdl(aLink);
3149 	aRightScrollWin.SetClickHdl(aLink);
3150 }
3151 /* -----------------01.07.99 12:17-------------------
3152 
3153  --------------------------------------------------*/
3154 SwTokenWindow::~SwTokenWindow()
3155 {
3156 //	for(sal_uInt16 i = GetItemCount(); i ; i--)
3157 //		RemoveItem(i - 1);
3158 
3159     for( sal_uInt32 n = 0; n < aControlList.Count(); ++n )
3160     {
3161         Control* pControl = aControlList.GetObject( n );
3162         pControl->SetGetFocusHdl( Link() );
3163         pControl->SetLoseFocusHdl( Link() );
3164     }
3165 
3166     for( sal_uLong i = aControlList.Count(); i; )
3167 	{
3168 		Control* pControl = aControlList.Remove( --i );
3169 		delete pControl;
3170 	}
3171 }
3172 /* -----------------16.06.99 13:56-------------------
3173 
3174  --------------------------------------------------*/
3175 void	SwTokenWindow::SetForm(SwForm& rForm, sal_uInt16 nL)
3176 {
3177 	SetActiveControl(0);
3178 	bValid = sal_True;
3179 	if(pForm)
3180 	{
3181 		//apply current level settings to the form
3182         for( sal_uLong i = aControlList.Count(); i; )
3183 		{
3184 			Control* pControl = aControlList.Remove( --i );
3185 			delete pControl;
3186 		}
3187 	}
3188 	nLevel = nL;
3189 	pForm = &rForm;
3190 	//now the display
3191 	if(nLevel < MAXLEVEL || rForm.GetTOXType() == TOX_AUTHORITIES)
3192 	{
3193 	 	Size aToolBoxSize = GetSizePixel();
3194 
3195         // #i21237#
3196         SwFormTokens aPattern = pForm->GetPattern(nLevel + 1);
3197         SwFormTokens::iterator aIt = aPattern.begin();
3198 		sal_Bool bLastWasText = sal_False; //assure alternating text - code - text
3199 
3200 		Control* pSetActiveControl = 0;
3201 		while(aIt != aPattern.end()) // #i21237#
3202 		{
3203 			SwFormToken aToken(*aIt); // #i21237#
3204 
3205 			if(TOKEN_TEXT == aToken.eTokenType)
3206 			{
3207 				DBG_ASSERT(!bLastWasText, "text following text is invalid");
3208 				Control* pCtrl = InsertItem(aToken.sText, aToken);
3209 				bLastWasText = sal_True;
3210 				if(!GetActiveControl())
3211 					SetActiveControl(pCtrl);
3212 			}
3213 			else
3214 			{
3215 				if( !bLastWasText )
3216 				{
3217 					bLastWasText = sal_True;
3218 					SwFormToken aTemp(TOKEN_TEXT);
3219 					Control* pCtrl = InsertItem(aEmptyStr, aTemp);
3220 					if(!pSetActiveControl)
3221 						pSetActiveControl = pCtrl;
3222 				}
3223 				const sal_Char* pTmp = 0;
3224 				switch( aToken.eTokenType )
3225 				{
3226 				case TOKEN_ENTRY_NO:	pTmp = SwForm::aFormEntryNum; break;
3227 				case TOKEN_ENTRY_TEXT:  pTmp = SwForm::aFormEntryTxt; break;
3228 				case TOKEN_ENTRY:       pTmp = SwForm::aFormEntry; break;
3229 				case TOKEN_TAB_STOP:    pTmp = SwForm::aFormTab; break;
3230 				case TOKEN_PAGE_NUMS:   pTmp = SwForm::aFormPageNums; break;
3231 				case TOKEN_CHAPTER_INFO:pTmp = SwForm::aFormChapterMark; break;
3232 				case TOKEN_LINK_START:  pTmp = SwForm::aFormLinkStt; break;
3233 				case TOKEN_LINK_END:    pTmp = SwForm::aFormLinkEnd; break;
3234 				case TOKEN_AUTHORITY:   pTmp = SwForm::aFormAuth; break;
3235                 default:; //prevent warning
3236 				}
3237 
3238 				InsertItem( pTmp ? String::CreateFromAscii(pTmp)
3239 								 : aEmptyStr, aToken );
3240 				bLastWasText = sal_False;
3241 			}
3242 
3243             aIt++; // #i21237#
3244 		}
3245 		if(!bLastWasText)
3246 		{
3247 			bLastWasText = sal_True;
3248 			SwFormToken aTemp(TOKEN_TEXT);
3249 			Control* pCtrl = InsertItem(aEmptyStr, aTemp);
3250 			if(!pSetActiveControl)
3251 				pSetActiveControl = pCtrl;
3252 		}
3253 		SetActiveControl(pSetActiveControl);
3254 	}
3255 	AdjustScrolling();
3256 }
3257 /* -----------------19.08.99 13:00-------------------
3258 
3259  --------------------------------------------------*/
3260 void SwTokenWindow::SetActiveControl(Control* pSet)
3261 {
3262     if( pSet != pActiveCtrl )
3263 	{
3264 		pActiveCtrl = pSet;
3265 		if( pActiveCtrl )
3266 		{
3267 			pActiveCtrl->GrabFocus();
3268 			//it must be a SwTOXEdit
3269 			const SwFormToken* pFToken;
3270 			if( WINDOW_EDIT == pActiveCtrl->GetType() )
3271 				pFToken = &((SwTOXEdit*)pActiveCtrl)->GetFormToken();
3272 			else
3273 				pFToken = &((SwTOXButton*)pActiveCtrl)->GetFormToken();
3274 
3275 			SwFormToken aTemp( *pFToken );
3276 			aButtonSelectedHdl.Call( &aTemp );
3277 		}
3278 	}
3279 }
3280 
3281 /* -----------------17.06.99 09:53-------------------
3282 
3283  --------------------------------------------------*/
3284 Control*	SwTokenWindow::InsertItem(const String& rText, const SwFormToken& rToken)
3285 {
3286 	Control* pRet = 0;
3287 	Control* pLast = aControlList.Last();
3288 	Size aControlSize(GetOutputSizePixel());
3289  	Point aControlPos;
3290 	if( pLast )
3291 	{
3292 		aControlSize = pLast->GetSizePixel();
3293 		aControlPos = pLast->GetPosPixel();
3294 		aControlPos.X() += aControlSize.Width();
3295 	}
3296 	if(TOKEN_TEXT == rToken.eTokenType)
3297 	{
3298 		SwTOXEdit* pEdit = new SwTOXEdit(&aCtrlParentWin, this, rToken);
3299 		pEdit->SetPosPixel(aControlPos);
3300 		aControlList.Insert(pEdit, aControlList.Count());
3301 		pEdit->SetText(rText);
3302 	 	Size aEditSize(aControlSize);
3303 		aEditSize.Width() = pEdit->GetTextWidth(rText) + EDIT_MINWIDTH;
3304 		pEdit->SetSizePixel(aEditSize);
3305 		pEdit->SetModifyHdl(LINK(this, SwTokenWindow, EditResize ));
3306 		pEdit->SetPrevNextLink(LINK(this, SwTokenWindow, NextItemHdl));
3307 		pEdit->SetGetFocusHdl(LINK(this, SwTokenWindow, TbxFocusHdl));
3308 		pEdit->Show();
3309 		pRet = pEdit;
3310 	}
3311 	else
3312 	{
3313         SwTOXButton* pButton = new SwTOXButton(&aCtrlParentWin, this, rToken);
3314 		pButton->SetPosPixel(aControlPos);
3315 		aControlList.Insert(pButton, aControlList.Count());
3316 	 	Size aEditSize(aControlSize);
3317 		aEditSize.Width() = pButton->GetTextWidth(rText) + 5;
3318 //        pButton->SetControlBackground(aCtrlColor);
3319 //        pButton->SetControlForeground(aTextColor);
3320         pButton->SetSizePixel(aEditSize);
3321 		pButton->SetPrevNextLink(LINK(this, SwTokenWindow, NextItemBtnHdl));
3322 		pButton->SetGetFocusHdl(LINK(this, SwTokenWindow, TbxFocusBtnHdl));
3323 		if(TOKEN_AUTHORITY != rToken.eTokenType)
3324 			pButton->SetText(aButtonTexts[rToken.eTokenType]);
3325 		else
3326 		{
3327 			//use the first two chars as symbol
3328 			String sTmp(SwAuthorityFieldType::GetAuthFieldName(
3329 						(ToxAuthorityField)rToken.nAuthorityField));
3330 			pButton->SetText(sTmp.Copy(0, 2));
3331 		}
3332 		pButton->Show();
3333 		pRet = pButton;
3334 	}
3335 	return pRet;
3336 }
3337 /* -----------------16.07.99 11:50-------------------
3338 
3339  --------------------------------------------------*/
3340 void	SwTokenWindow::InsertAtSelection(
3341 			const String& rText,
3342 			const SwFormToken& rToken)
3343 {
3344 	DBG_ASSERT(pActiveCtrl, "no active control!");
3345 	if(!pActiveCtrl)
3346 		return;
3347 	SwFormToken aToInsertToken(rToken);
3348 	if(TOKEN_LINK_START == aToInsertToken.eTokenType)
3349 	{
3350 		//determine if start or end of hyperlink is appropriate
3351 		//eventually change a following link start into a link end
3352 		// groups of LS LE should be ignored
3353 		// <insert>
3354 		//LS <insert>
3355 		//LE <insert>
3356 		//<insert> LS
3357 		//<insert> LE
3358 		//<insert>
3359 		sal_Bool bPreStartLinkFound = sal_False; //
3360 		sal_Bool bPreEndLinkFound = sal_False;
3361 
3362 		const Control* pControl = aControlList.First();
3363 		const Control* pExchange = 0;
3364 		while( pControl && pActiveCtrl != pControl )
3365 		{
3366 			if( WINDOW_EDIT != pControl->GetType())
3367 			{
3368 				const SwFormToken& rNewToken =
3369 								((SwTOXButton*)pControl)->GetFormToken();
3370 				if( TOKEN_LINK_START == rNewToken.eTokenType )
3371 				{
3372 					bPreStartLinkFound = sal_True;
3373 					pExchange = 0;
3374 				}
3375 				else if(TOKEN_LINK_END == rNewToken.eTokenType)
3376 				{
3377 					if( bPreStartLinkFound )
3378 						bPreStartLinkFound = sal_False;
3379 					else
3380 					{
3381 						bPreEndLinkFound = sal_False;
3382 						pExchange = pControl;
3383 					}
3384 				}
3385 			}
3386 			pControl = aControlList.Next();
3387 		}
3388 
3389 		sal_Bool bPostLinkEndFound = sal_False;
3390 		sal_Bool bPostLinkStartFound = sal_False;
3391 		if(!bPreStartLinkFound && !bPreEndLinkFound)
3392 			while(pControl)
3393 			{
3394 				if( pControl != pActiveCtrl &&
3395 					WINDOW_EDIT != pControl->GetType())
3396 				{
3397 					const SwFormToken& rNewToken =
3398 									((SwTOXButton*)pControl)->GetFormToken();
3399 					if( TOKEN_LINK_START == rNewToken.eTokenType )
3400 					{
3401 						if(bPostLinkStartFound)
3402 							break;
3403 						bPostLinkStartFound = sal_True;
3404 						pExchange = pControl;
3405 					}
3406 					else if(TOKEN_LINK_END == rNewToken.eTokenType )
3407 					{
3408 						if(bPostLinkStartFound)
3409 						{
3410 							bPostLinkStartFound = sal_False;
3411 							pExchange = 0;
3412 						}
3413 						else
3414 						{
3415 							bPostLinkEndFound = sal_True;
3416 						}
3417 						break;
3418 					}
3419 				}
3420 				pControl = aControlList.Next();
3421 			}
3422 
3423 		if(bPreStartLinkFound)
3424 		{
3425 			aToInsertToken.eTokenType = TOKEN_LINK_END;
3426 			aToInsertToken.sText = 	aButtonTexts[TOKEN_LINK_END];
3427 		}
3428 
3429 		if(bPostLinkStartFound)
3430 		{
3431 			DBG_ASSERT(pExchange, "no control to exchange?");
3432 			if(pExchange)
3433 			{
3434 				((SwTOXButton*)pExchange)->SetLinkEnd();
3435 				((SwTOXButton*)pExchange)->SetText(aButtonTexts[TOKEN_LINK_END]);
3436 			}
3437 		}
3438 
3439 		if(bPreEndLinkFound)
3440 		{
3441 			DBG_ASSERT(pExchange, "no control to exchange?");
3442 			if(pExchange)
3443 			{
3444 				((SwTOXButton*)pExchange)->SetLinkStart();
3445 				((SwTOXButton*)pExchange)->SetText(aButtonTexts[TOKEN_LINK_START]);
3446 			}
3447 		}
3448 	}
3449 
3450 	//if the active control is text then insert a new button at the selection
3451 	//else replace the button
3452 	sal_uInt32 nActivePos = aControlList.GetPos(pActiveCtrl);
3453 	sal_uInt32 nInsertPos = nActivePos;
3454 
3455     Size aControlSize(GetOutputSizePixel());
3456 	if( WINDOW_EDIT == pActiveCtrl->GetType())
3457 	{
3458 		nInsertPos++;
3459 	 	Selection aSel = ((SwTOXEdit*)pActiveCtrl)->GetSelection();
3460 		aSel.Justify();
3461 		String sEditText = ((SwTOXEdit*)pActiveCtrl)->GetText();
3462         String sLeft = sEditText.Copy( 0, static_cast< sal_uInt16 >(aSel.A()) );
3463         String sRight = sEditText.Copy( static_cast< sal_uInt16 >(aSel.B()),
3464                                         static_cast< sal_uInt16 >(sEditText.Len() - aSel.B()));
3465 
3466 		((SwTOXEdit*)pActiveCtrl)->SetText(sLeft);
3467 		((SwTOXEdit*)pActiveCtrl)->AdjustSize();
3468 
3469 		SwFormToken aTmpToken(TOKEN_TEXT);
3470 		SwTOXEdit* pEdit = new SwTOXEdit(&aCtrlParentWin, this, aTmpToken);
3471 		aControlList.Insert(pEdit, nActivePos + 1);
3472 		pEdit->SetText(sRight);
3473 		pEdit->SetSizePixel(aControlSize);
3474 		pEdit->AdjustSize();
3475 		pEdit->SetModifyHdl(LINK(this, SwTokenWindow, EditResize ));
3476 		pEdit->SetPrevNextLink(LINK(this, SwTokenWindow, NextItemHdl));
3477 		pEdit->SetGetFocusHdl(LINK(this, SwTokenWindow, TbxFocusHdl));
3478 		pEdit->Show();
3479 	}
3480 	else
3481 	{
3482 		aControlList.Remove(pActiveCtrl);
3483 		pActiveCtrl->Hide();
3484 		delete pActiveCtrl;
3485 	}
3486 
3487     //now the new button
3488 	SwTOXButton* pButton = new SwTOXButton(&aCtrlParentWin, this, aToInsertToken);
3489 	aControlList.Insert(pButton, nInsertPos);
3490     pButton->SetPrevNextLink(LINK(this, SwTokenWindow, NextItemBtnHdl));
3491 	pButton->SetGetFocusHdl(LINK(this, SwTokenWindow, TbxFocusBtnHdl));
3492 	if(TOKEN_AUTHORITY != aToInsertToken.eTokenType)
3493 		pButton->SetText(aButtonTexts[aToInsertToken.eTokenType]);
3494 	else
3495 	{
3496 		//use the first two chars as symbol
3497 		String sTmp(SwAuthorityFieldType::GetAuthFieldName(
3498 					(ToxAuthorityField)aToInsertToken.nAuthorityField));
3499 		pButton->SetText(sTmp.Copy(0, 2));
3500 	}
3501 
3502  Size aEditSize(GetOutputSizePixel());
3503 	aEditSize.Width() = pButton->GetTextWidth(rText) + 5;
3504 	pButton->SetSizePixel(aEditSize);
3505 	pButton->Check(sal_True);
3506 	pButton->Show();
3507 	SetActiveControl(pButton);
3508 
3509 	AdjustPositions();
3510 }
3511 /* -----------------19.08.99 12:42-------------------
3512 
3513  --------------------------------------------------*/
3514 void SwTokenWindow::RemoveControl(SwTOXButton* pDel, sal_Bool bInternalCall )
3515 {
3516 	if(bInternalCall && TOX_AUTHORITIES == pForm->GetTOXType())
3517 		m_pParent->PreTokenButtonRemoved(pDel->GetFormToken());
3518 
3519 	sal_uInt32 nActivePos = aControlList.GetPos(pDel);
3520 	DBG_ASSERT(nActivePos != 0xffffffff, "Control does not exist!");
3521 	// the two neighbours of the box must be merged
3522 	// the properties of the right one will be lost
3523 	DBG_ASSERT(nActivePos && nActivePos < aControlList.Count() - 1,
3524 		"Button at first or last position?");
3525 	aControlList.Seek(nActivePos - 1);
3526 	Control* pLeftEdit = aControlList.GetCurObject();
3527 	aControlList.Seek(nActivePos + 1);
3528 	Control* pRightEdit = aControlList.GetCurObject();
3529 	String sTemp(((SwTOXEdit*)pLeftEdit)->GetText());
3530 	sTemp += ((SwTOXEdit*)pRightEdit)->GetText();
3531 	((SwTOXEdit*)pLeftEdit)->SetText(sTemp);
3532 	((SwTOXEdit*)pLeftEdit)->AdjustSize();
3533 
3534 	aControlList.Remove(pRightEdit);
3535 	delete pRightEdit;
3536 
3537 	aControlList.Remove(pDel);
3538 	pActiveCtrl->Hide();
3539 	delete pActiveCtrl;
3540 	SetActiveControl(pLeftEdit);
3541 	AdjustPositions();
3542 	if(aModifyHdl.IsSet())
3543 		aModifyHdl.Call(0);
3544 }
3545 
3546 /* -----------------16.07.99 12:39-------------------
3547 
3548  --------------------------------------------------*/
3549 void SwTokenWindow::AdjustPositions()
3550 {
3551 	if(aControlList.Count() > 1)
3552 	{
3553 		Control* pCtrl = aControlList.First();
3554 	 Point aNextPos = pCtrl->GetPosPixel();
3555 		aNextPos.X() += pCtrl->GetSizePixel().Width();
3556 		while(0 != (pCtrl = aControlList.Next()))
3557 		{
3558 			pCtrl->SetPosPixel(aNextPos);
3559 			aNextPos.X() += pCtrl->GetSizePixel().Width();
3560 		}
3561 		AdjustScrolling();
3562 	}
3563 };
3564 /* -----------------------------16.08.00 13:22--------------------------------
3565 
3566  ---------------------------------------------------------------------------*/
3567 void SwTokenWindow::MoveControls(long nOffset)
3568 {
3569 	// move the complete list
3570 	Control* pCtrl = aControlList.First();
3571 	do
3572 	{
3573 		Point aPos = pCtrl->GetPosPixel();
3574 		aPos.X() += nOffset;
3575 		pCtrl->SetPosPixel(aPos);
3576 	}while(0 != (pCtrl = aControlList.Next()));
3577 }
3578 /* -----------------------------14.01.00 13:03--------------------------------
3579 
3580  ---------------------------------------------------------------------------*/
3581 void SwTokenWindow::AdjustScrolling()
3582 {
3583 	if(aControlList.Count() > 1)
3584 	{
3585 		//validate scroll buttons
3586 		Control* pLastCtrl = aControlList.Last();
3587 		Control* pFirstCtrl = aControlList.First();
3588 		long nSpace = aCtrlParentWin.GetSizePixel().Width();
3589 		long nWidth = pLastCtrl->GetPosPixel().X() - pFirstCtrl->GetPosPixel().X()
3590 													+ pLastCtrl->GetSizePixel().Width();
3591 		sal_Bool bEnable = nWidth > nSpace;
3592 		//the active control must be visible
3593 		if(bEnable && pActiveCtrl)
3594 		{
3595 		 	Point aActivePos(pActiveCtrl->GetPosPixel());
3596 			long nMove = 0;
3597 			if(aActivePos.X() < 0)
3598 				nMove = -aActivePos.X();
3599 			else if((aActivePos.X() + pActiveCtrl->GetSizePixel().Width())  > nSpace)
3600 				nMove = -(aActivePos.X() + pActiveCtrl->GetSizePixel().Width() - nSpace);
3601 			if(nMove)
3602 				MoveControls(nMove);
3603 			aLeftScrollWin.Enable(aControlList.First()->GetPosPixel().X() < 0);
3604 			Control* pCtrl = aControlList.Last();
3605 			aRightScrollWin.Enable((pCtrl->GetPosPixel().X() + pCtrl->GetSizePixel().Width()) > nSpace);
3606 		}
3607 		else
3608 		{
3609 			if(pFirstCtrl)
3610 			{
3611 				//if the control fits into the space then the first control must be at postion 0
3612 				long nFirstPos = pFirstCtrl->GetPosPixel().X();
3613 				if(nFirstPos != 0)
3614 					MoveControls(-nFirstPos);
3615 			}
3616 			aRightScrollWin.Enable(sal_False);
3617 			aLeftScrollWin.Enable(sal_False);
3618 		}
3619 	}
3620 }
3621 /* -----------------------------14.01.00 13:57--------------------------------
3622 
3623  ---------------------------------------------------------------------------*/
3624 IMPL_LINK(SwTokenWindow, ScrollHdl, ImageButton*, pBtn )
3625 {
3626 	if(aControlList.Count())
3627 	{
3628 		const long nSpace = aCtrlParentWin.GetSizePixel().Width();
3629 #if OSL_DEBUG_LEVEL > 1
3630 	//find all start/end positions and print it
3631 	String sMessage(String::CreateFromAscii("Space: "));
3632 	sMessage += String::CreateFromInt32(nSpace);
3633 	sMessage += String::CreateFromAscii(" | ");
3634 	Control* pDebugCtrl = aControlList.First();
3635 	do
3636 	{
3637 		long nDebugXPos = pDebugCtrl->GetPosPixel().X();
3638 		long nDebugWidth = pDebugCtrl->GetSizePixel().Width();
3639 		sMessage += String::CreateFromInt32( nDebugXPos );
3640 		sMessage += String::CreateFromAscii(" ");
3641 		sMessage += String::CreateFromInt32(nDebugXPos + nDebugWidth);
3642 		sMessage += String::CreateFromAscii(" | ");
3643 
3644 	}while(0 != (pDebugCtrl = aControlList.Next()));
3645 
3646 #endif
3647 
3648 		long nMove = 0;
3649 		if(pBtn == &aLeftScrollWin)
3650 		{
3651 			//find the first completely visible control (left edge visible)
3652 			for(sal_uInt16 i = 0; i < aControlList.Count(); i++ )
3653 			{
3654 				Control* pCtrl = aControlList.GetObject(i);
3655 				long nXPos = pCtrl->GetPosPixel().X();
3656 				if(nXPos >= 0)
3657 				{
3658 					if(!i)
3659 						//move the current control to the left edge
3660 						nMove = -nXPos;
3661 					else
3662 						//move the left neighbor to the start position
3663 						nMove = -aControlList.GetObject(i - 1)->GetPosPixel().X();
3664 					break;
3665 				}
3666 			}
3667 		}
3668 		else
3669 		{
3670 			//find the first completely visible control (left edge visible)
3671             for(sal_uLong i = aControlList.Count(); i; i-- )
3672 			{
3673 				Control* pCtrl = aControlList.GetObject(i - 1);
3674 				long nCtrlWidth = pCtrl->GetSizePixel().Width();
3675 				long nXPos = pCtrl->GetPosPixel().X() + nCtrlWidth;
3676 				if(nXPos <= nSpace)
3677 				{
3678 					if( i < aControlList.Count())
3679 					{
3680 						//move the right neighbor  to the right edge right aligned
3681 						Control* pRight = aControlList.GetObject(i);
3682 						nMove = nSpace - pRight->GetPosPixel().X() - pRight->GetSizePixel().Width();
3683 					}
3684 					break;
3685 				}
3686 			}
3687 
3688 			//move it left until it's completely visible
3689 		}
3690 		if(nMove)
3691 		{
3692 			// move the complete list
3693 			Control* pCtrl = aControlList.First();
3694 			do
3695 			{
3696 			 Point aPos = pCtrl->GetPosPixel();
3697 				aPos.X() += nMove;
3698 				pCtrl->SetPosPixel(aPos);
3699 			}while(0 != (pCtrl = aControlList.Next()));
3700 			aLeftScrollWin.Enable(aControlList.First()->GetPosPixel().X() < 0);
3701 			pCtrl = aControlList.Last();
3702 			aRightScrollWin.Enable((pCtrl->GetPosPixel().X() + pCtrl->GetSizePixel().Width()) > nSpace);
3703 
3704 #if OSL_DEBUG_LEVEL > 1
3705 			sMessage.AppendAscii("Move: ");
3706 			sMessage += String::CreateFromInt32(nMove);
3707 			GetParent()->GetParent()->GetParent()->SetText(sMessage);
3708 #endif
3709 		}
3710 	}
3711 	return 0;
3712 }
3713 /* -----------------17.06.99 11:59-------------------
3714 
3715  --------------------------------------------------*/
3716 String	SwTokenWindow::GetPattern() const
3717 {
3718 	String sRet;
3719 	const Control* pControl = ((SwTokenWindow*)this)->aControlList.First();
3720 	while(pControl)
3721 	{
3722 		const SwFormToken& rNewToken = WINDOW_EDIT == pControl->GetType()
3723 					? ((SwTOXEdit*)pControl)->GetFormToken()
3724 					: ((SwTOXButton*)pControl)->GetFormToken();
3725 
3726 		//TODO: prevent input of TOX_STYLE_DELIMITER in KeyInput
3727 		sRet += rNewToken.GetString();
3728 
3729 		pControl = ((SwTokenWindow*)this)->aControlList.Next();
3730 	}
3731 	return sRet;
3732 }
3733 /* -----------------19.08.99 11:27-------------------
3734 	Description: Check if a control of the specified
3735 					TokenType is already contained in the list
3736  --------------------------------------------------*/
3737 sal_Bool SwTokenWindow::Contains(FormTokenType eSearchFor) const
3738 {
3739 	sal_Bool bRet = sal_False;
3740 	const Control* pControl = ((SwTokenWindow*)this)->aControlList.First();
3741 	while(pControl)
3742 	{
3743 		const SwFormToken& rNewToken = WINDOW_EDIT == pControl->GetType()
3744 					? ((SwTOXEdit*)pControl)->GetFormToken()
3745 					: ((SwTOXButton*)pControl)->GetFormToken();
3746 
3747 		if(eSearchFor == rNewToken.eTokenType)
3748 		{
3749 			bRet = sal_True;
3750 			break;
3751 		}
3752 		pControl = ((SwTokenWindow*)this)->aControlList.Next();
3753 	}
3754 	return bRet;
3755 }
3756 //---------------------------------------------------
3757 sal_Bool SwTokenWindow::CreateQuickHelp(Control* pCtrl,
3758 			const SwFormToken& rToken,
3759 			const HelpEvent& rHEvt)
3760 {
3761 	sal_Bool bRet = sal_False;
3762 	if( rHEvt.GetMode() & HELPMODE_QUICK )
3763 	{
3764 		sal_Bool bBalloon = Help::IsBalloonHelpEnabled();
3765 		String sEntry;
3766 		if(bBalloon || rToken.eTokenType != TOKEN_AUTHORITY)
3767 			sEntry = (aButtonHelpTexts[rToken.eTokenType]);
3768 		if(rToken.eTokenType == TOKEN_AUTHORITY )
3769 		{
3770  			sEntry += SwAuthorityFieldType::GetAuthFieldName(
3771 								(ToxAuthorityField) rToken.nAuthorityField);
3772 		}
3773 
3774 	 Point aPos = OutputToScreenPixel(pCtrl->GetPosPixel());
3775 	 Rectangle aItemRect( aPos, pCtrl->GetSizePixel() );
3776 		if(rToken.eTokenType == TOKEN_TAB_STOP )
3777 		{
3778 //			sEntry += '\n';
3779 //		  	sEntry += rToken.nTabStopPosition;
3780 		}
3781 		else
3782 		{
3783 			if(rToken.sCharStyleName.Len())
3784 			{
3785 				if(bBalloon)
3786 					sEntry += '\n';
3787 				else
3788 					sEntry += ' ';
3789 				sEntry += sCharStyle;
3790 		  		sEntry += rToken.sCharStyleName;
3791 			}
3792 		}
3793 		if(bBalloon)
3794 		{
3795 			Help::ShowBalloon( this, aPos, aItemRect, sEntry );
3796 		}
3797 		else
3798 			Help::ShowQuickHelp( this, aItemRect, sEntry,
3799 				QUICKHELP_LEFT|QUICKHELP_VCENTER );
3800 		bRet = sal_True;
3801 	}
3802 	return bRet;
3803 }
3804 /* -----------------------------14.01.00 12:22--------------------------------
3805 
3806  ---------------------------------------------------------------------------*/
3807 void SwTokenWindow::Resize()
3808 {
3809  Size aCompleteSize(GetOutputSizePixel());
3810 
3811  Point aRightPos(aRightScrollWin.GetPosPixel());
3812  Size aRightSize(aRightScrollWin.GetSizePixel());
3813 
3814  Size aMiddleSize(aCtrlParentWin.GetSizePixel());
3815 
3816 	long nMove = aCompleteSize.Width() - aRightSize.Width() - aRightPos.X();
3817 
3818 	aRightPos.X() += nMove;
3819 	aRightScrollWin.SetPosPixel(aRightPos);
3820 	aMiddleSize.Width() += nMove;
3821 	aCtrlParentWin.SetSizePixel(aMiddleSize);
3822 }
3823 
3824 /* -----------------16.06.99 15:23-------------------
3825 
3826  --------------------------------------------------*/
3827 IMPL_LINK(SwTokenWindow, EditResize, Edit*, pEdit)
3828 {
3829 	((SwTOXEdit*)pEdit)->AdjustSize();
3830 	AdjustPositions();
3831 	if(aModifyHdl.IsSet())
3832 		aModifyHdl.Call(0);
3833 	return 0;
3834 }
3835 /* -----------------16.06.99 15:56-------------------
3836 
3837  --------------------------------------------------*/
3838 IMPL_LINK(SwTokenWindow, NextItemHdl, SwTOXEdit*,  pEdit)
3839 {
3840 	sal_uInt16 nPos = (sal_uInt16)aControlList.GetPos(pEdit);
3841 	if( (nPos && !pEdit->IsNextControl()) ||
3842 		(nPos < aControlList.Count() - 1 && pEdit->IsNextControl()))
3843 	{
3844 		aControlList.Seek(nPos);
3845 		Control* pNextPrev = pEdit->IsNextControl() ? aControlList.Next() : aControlList.Prev();
3846 		nPos += pEdit->IsNextControl() ? 1 : -1;
3847 		pNextPrev->GrabFocus();
3848 		((SwTOXButton*)pNextPrev)->Check();
3849 		AdjustScrolling();
3850 	}
3851 	return 0;
3852 }
3853 /* -----------------17.06.99 08:58-------------------
3854 
3855  --------------------------------------------------*/
3856 IMPL_LINK(SwTokenWindow, TbxFocusHdl, SwTOXEdit*, pEdit)
3857 {
3858 	for(sal_uInt16 i = 0; i < aControlList.Count(); i++)
3859 	{
3860 		Control* pControl = aControlList.First();
3861 		while(pControl)
3862 		{
3863 			if(WINDOW_EDIT != pControl->GetType() )
3864 				((SwTOXButton*)pControl)->Check(sal_False);
3865 			pControl = aControlList.Next();
3866 		}
3867 	}
3868 	SetActiveControl(pEdit);
3869 	return 0;
3870 }
3871 /* -----------------17.06.99 10:05-------------------
3872 
3873  --------------------------------------------------*/
3874 IMPL_LINK(SwTokenWindow, NextItemBtnHdl, SwTOXButton*, pBtn )
3875 {
3876 	sal_uInt16 nPos = (sal_uInt16)aControlList.GetPos(pBtn);
3877 	if( (nPos && !pBtn->IsNextControl()) ||
3878 		(nPos < aControlList.Count() - 1 && pBtn->IsNextControl()))
3879 	{
3880 		aControlList.Seek(nPos);
3881 		sal_Bool bNext = pBtn->IsNextControl();
3882 		Control* pNextPrev = bNext ? aControlList.Next() : aControlList.Prev();
3883 		pNextPrev->GrabFocus();
3884 	 	Selection aSel(0, 0);
3885 		if(!bNext)
3886 		{
3887 			sal_uInt16 nLen = ((SwTOXEdit*)pNextPrev)->GetText().Len();
3888 			aSel.A() = nLen;
3889 			aSel.B() = nLen;
3890 		}
3891 		((SwTOXEdit*)pNextPrev)->SetSelection(aSel);
3892 		pBtn->Check(sal_False);
3893 		AdjustScrolling();
3894 	}
3895 	return 0;
3896 }
3897 
3898 /* -----------------17.06.99 10:04-------------------
3899 
3900  --------------------------------------------------*/
3901 IMPL_LINK(SwTokenWindow, TbxFocusBtnHdl, SwTOXButton*, pBtn )
3902 {
3903 	for(sal_uInt16 i = 0; i < aControlList.Count(); i++)
3904 	{
3905 		Control* pControl = aControlList.First();
3906 		while(pControl)
3907 		{
3908 			if(WINDOW_EDIT != pControl->GetType() )
3909 				((SwTOXButton*)pControl)->Check(pBtn == pControl);
3910 			pControl = aControlList.Next();
3911 		}
3912 	}
3913 	SetActiveControl(pBtn);
3914 	return 0;
3915 }
3916 /* -----------------------------28.01.2002 12:22------------------------------
3917 
3918  ---------------------------------------------------------------------------*/
3919 void SwTokenWindow::GetFocus()
3920 {
3921     if(GETFOCUS_TAB & GetGetFocusFlags())
3922     {
3923        Control* pFirst = aControlList.First();
3924        if(pFirst)
3925        {
3926             pFirst->GrabFocus();
3927             SetActiveControl(pFirst);
3928             AdjustScrolling();
3929        }
3930     }
3931 }
3932 /* -----------------25.03.99 15:17-------------------
3933  *
3934  * --------------------------------------------------*/
3935 SwTOXStylesTabPage::SwTOXStylesTabPage(Window* pParent, const SfxItemSet& rAttrSet ) :
3936 	SfxTabPage(pParent, SW_RES(TP_TOX_STYLES), rAttrSet),
3937     aFormatFL(this,     SW_RES(FL_FORMAT  )),
3938     aLevelFT2(this,		SW_RES(FT_LEVEL	 )),
3939 	aLevelLB(this,		SW_RES(LB_LEVEL	 )),
3940 	aAssignBT(this,		SW_RES(BT_ASSIGN  )),
3941     aTemplateFT(this,	SW_RES(FT_TEMPLATE)),
3942 	aParaLayLB(this,	SW_RES(LB_PARALAY )),
3943 	aStdBT(this,		SW_RES(BT_STD  	 )),
3944 	aEditStyleBT(this, 	SW_RES(BT_EDIT_STYLE	)),
3945     m_pCurrentForm(0)
3946 {
3947 	FreeResource();
3948 
3949 	SetExchangeSupport( sal_True );
3950 
3951 	aAssignBT.SetModeImage( Image( SW_RES( IMG_ONE_LEFT_HC ) ), BMP_COLOR_HIGHCONTRAST );
3952 
3953 	aEditStyleBT.SetClickHdl   (LINK(	this, SwTOXStylesTabPage, EditStyleHdl));
3954 	aAssignBT.SetClickHdl  	   (LINK(	this, SwTOXStylesTabPage, AssignHdl));
3955 	aStdBT.SetClickHdl	  	   (LINK(	this, SwTOXStylesTabPage, StdHdl));
3956 	aParaLayLB.SetSelectHdl	   (LINK(	this, SwTOXStylesTabPage, EnableSelectHdl));
3957 	aLevelLB.SetSelectHdl  	   (LINK(	this, SwTOXStylesTabPage, EnableSelectHdl));
3958 	aParaLayLB.SetDoubleClickHdl(LINK(	this, SwTOXStylesTabPage, DoubleClickHdl));
3959 
3960 	aStdBT.SetAccessibleRelationMemberOf(&aFormatFL);
3961 	aAssignBT.SetAccessibleRelationMemberOf(&aFormatFL);
3962 	aEditStyleBT.SetAccessibleRelationMemberOf(&aFormatFL);
3963 
3964 }
3965 /* -----------------25.03.99 15:17-------------------
3966  *
3967  * --------------------------------------------------*/
3968 SwTOXStylesTabPage::~SwTOXStylesTabPage()
3969 {
3970     delete m_pCurrentForm;
3971 }
3972 /* -----------------25.03.99 15:17-------------------
3973  *
3974  * --------------------------------------------------*/
3975 sal_Bool	SwTOXStylesTabPage::FillItemSet( SfxItemSet& )
3976 {
3977 	return sal_True;
3978 }
3979 /* -----------------25.03.99 15:17-------------------
3980  *
3981  * --------------------------------------------------*/
3982 void	SwTOXStylesTabPage::Reset( const SfxItemSet& rSet )
3983 {
3984 	ActivatePage(rSet);
3985 }
3986 /* -----------------25.03.99 15:17-------------------
3987  *
3988  * --------------------------------------------------*/
3989 void	SwTOXStylesTabPage::ActivatePage( const SfxItemSet& )
3990 {
3991     m_pCurrentForm = new SwForm(GetForm());
3992 	aParaLayLB.Clear();
3993 	aLevelLB.Clear();
3994 
3995 	// kein Hyperlink fuer Benutzerverzeichnisse
3996 
3997     sal_uInt16 i, nSize = m_pCurrentForm->GetFormMax();
3998 
3999 	// form-Pattern anzeigen ohne Titel
4000 
4001 	//1. TemplateEntry	anzeigen
4002 	String aStr( SW_RES( STR_TITLE ));
4003     if( m_pCurrentForm->GetTemplate( 0 ).Len() )
4004 	{
4005 		aStr += ' ';
4006 		aStr += aDeliStart;
4007         aStr += m_pCurrentForm->GetTemplate( 0 );
4008 		aStr += aDeliEnd;
4009 	}
4010 	aLevelLB.InsertEntry(aStr);
4011 
4012 	for( i=1; i < nSize; ++i )
4013 	{
4014         if( TOX_INDEX == m_pCurrentForm->GetTOXType() &&
4015 			FORM_ALPHA_DELIMITTER == i )
4016 			aStr = SW_RESSTR(STR_ALPHA);
4017 		else
4018 		{
4019 			aStr  = SW_RESSTR(STR_LEVEL);
4020 			aStr += String::CreateFromInt32(
4021                     TOX_INDEX == m_pCurrentForm->GetTOXType() ? i - 1 : i );
4022 		}
4023 		String aCpy( aStr );
4024 
4025         if( m_pCurrentForm->GetTemplate( i ).Len() )
4026 		{
4027 			aCpy += ' ';
4028 			aCpy += aDeliStart;
4029             aCpy += m_pCurrentForm->GetTemplate( i );
4030 			aCpy += aDeliEnd;
4031 		}
4032 		aLevelLB.InsertEntry( aCpy );
4033 	}
4034 
4035 	// Templates initialisieren
4036 	const SwTxtFmtColl *pColl;
4037 	SwWrtShell& rSh = ((SwMultiTOXTabDialog*)GetTabDialog())->GetWrtShell();
4038 	const sal_uInt16 nSz = rSh.GetTxtFmtCollCount();
4039 
4040 	for( i = 0; i < nSz; ++i )
4041 		if( !(pColl = &rSh.GetTxtFmtColl( i ))->IsDefault() )
4042 			aParaLayLB.InsertEntry( pColl->GetName() );
4043 
4044 	// Pool-Collections abfragen und fuer das Verzeichnis setzen
4045     for( i = 0; i < m_pCurrentForm->GetFormMax(); ++i )
4046 	{
4047         aStr = m_pCurrentForm->GetTemplate( i );
4048 		if( aStr.Len() &&
4049 			LISTBOX_ENTRY_NOTFOUND == aParaLayLB.GetEntryPos( aStr ))
4050 			aParaLayLB.InsertEntry( aStr );
4051 	}
4052 
4053 	EnableSelectHdl(&aParaLayLB);
4054 }
4055 /* -----------------25.03.99 15:17-------------------
4056  *
4057  * --------------------------------------------------*/
4058 int     SwTOXStylesTabPage::DeactivatePage( SfxItemSet* /*pSet*/  )
4059 {
4060     GetForm() = *m_pCurrentForm;
4061 	return LEAVE_PAGE;
4062 }
4063 
4064 /* -----------------25.03.99 15:17-------------------
4065  *
4066  * --------------------------------------------------*/
4067 SfxTabPage*	SwTOXStylesTabPage::Create( Window* pParent,
4068 								const SfxItemSet& rAttrSet)
4069 {
4070 	return new SwTOXStylesTabPage(pParent, rAttrSet);
4071 }
4072 /* -----------------26.03.99 12:47-------------------
4073  *
4074  * --------------------------------------------------*/
4075 IMPL_LINK( SwTOXStylesTabPage, EditStyleHdl, Button *, pBtn )
4076 {
4077 	if( LISTBOX_ENTRY_NOTFOUND != aParaLayLB.GetSelectEntryPos())
4078 	{
4079 		SfxStringItem aStyle(SID_STYLE_EDIT, aParaLayLB.GetSelectEntry());
4080 		SfxUInt16Item aFamily(SID_STYLE_FAMILY, SFX_STYLE_FAMILY_PARA);
4081 //		SwPtrItem aShell(FN_PARAM_WRTSHELL, pWrtShell);
4082 		Window* pDefDlgParent = Application::GetDefDialogParent();
4083 		Application::SetDefDialogParent( pBtn );
4084 		SwWrtShell& rSh = ((SwMultiTOXTabDialog*)GetTabDialog())->GetWrtShell();
4085 		rSh.GetView().GetViewFrame()->GetDispatcher()->Execute(
4086 		SID_STYLE_EDIT, SFX_CALLMODE_SYNCHRON|SFX_CALLMODE_MODAL,
4087 			&aStyle, &aFamily/*, &aShell*/, 0L);
4088 		Application::SetDefDialogParent( pDefDlgParent );
4089 	}
4090 	return 0;
4091 }
4092 /*--------------------------------------------------------------------
4093 	 Beschreibung: Vorlagen zuweisen
4094  --------------------------------------------------------------------*/
4095 IMPL_LINK( SwTOXStylesTabPage, AssignHdl, Button *, EMPTYARG )
4096 {
4097 	sal_uInt16 nLevPos 	 = aLevelLB.GetSelectEntryPos();
4098 	sal_uInt16 nTemplPos = aParaLayLB.GetSelectEntryPos();
4099 	if(nLevPos 	 != LISTBOX_ENTRY_NOTFOUND &&
4100 	   nTemplPos != LISTBOX_ENTRY_NOTFOUND)
4101 	{
4102 		String aStr(aLevelLB.GetEntry(nLevPos));
4103 		sal_uInt16 nDelPos = aStr.Search(aDeliStart);
4104 		if(nDelPos != STRING_NOTFOUND)
4105 			aStr.Erase(nDelPos-1);
4106 		aStr += ' ';
4107 		aStr += aDeliStart;
4108 		aStr += aParaLayLB.GetSelectEntry();
4109 
4110         m_pCurrentForm->SetTemplate(nLevPos, aParaLayLB.GetSelectEntry());
4111 
4112 		aStr += aDeliEnd;
4113 
4114 		aLevelLB.RemoveEntry(nLevPos);
4115 		aLevelLB.InsertEntry(aStr, nLevPos);
4116 		aLevelLB.SelectEntry(aStr);
4117 		ModifyHdl(0);
4118 	}
4119 	return 0;
4120 }
4121 /* -----------------26.03.99 09:10-------------------
4122  *
4123  * --------------------------------------------------*/
4124 IMPL_LINK( SwTOXStylesTabPage, StdHdl, Button *, EMPTYARG )
4125 {
4126 	sal_uInt16 nPos = aLevelLB.GetSelectEntryPos();
4127 	if(nPos != LISTBOX_ENTRY_NOTFOUND)
4128 	{	String aStr(aLevelLB.GetEntry(nPos));
4129 		sal_uInt16 nDelPos = aStr.Search(aDeliStart);
4130 		if(nDelPos != STRING_NOTFOUND)
4131 			aStr.Erase(nDelPos-1);
4132 		aLevelLB.RemoveEntry(nPos);
4133 		aLevelLB.InsertEntry(aStr, nPos);
4134 		aLevelLB.SelectEntry(aStr);
4135         m_pCurrentForm->SetTemplate(nPos, aEmptyStr);
4136 		ModifyHdl(0);
4137 	}
4138 	return 0;
4139 }
4140 /* -----------------26.03.99 09:11-------------------
4141  *
4142  * --------------------------------------------------*/
4143 IMPL_LINK_INLINE_START( SwTOXStylesTabPage, DoubleClickHdl, Button *, EMPTYARG )
4144 {
4145 	String aTmpName( aParaLayLB.GetSelectEntry() );
4146 	SwWrtShell& rSh = ((SwMultiTOXTabDialog*)GetTabDialog())->GetWrtShell();
4147 
4148 	if(aParaLayLB.GetSelectEntryPos() != LISTBOX_ENTRY_NOTFOUND &&
4149 	   (aLevelLB.GetSelectEntryPos() == 0 || SwMultiTOXTabDialog::IsNoNum(rSh, aTmpName)))
4150 		AssignHdl(&aAssignBT);
4151 	return 0;
4152 }
4153 IMPL_LINK_INLINE_END( SwTOXStylesTabPage, DoubleClickHdl, Button *, EMPTYARG )
4154 /*--------------------------------------------------------------------
4155 	 Beschreibung: nur wenn selektiert enable
4156  --------------------------------------------------------------------*/
4157 IMPL_LINK( SwTOXStylesTabPage, EnableSelectHdl, ListBox *, EMPTYARG )
4158 {
4159 	//UpdatePattern();
4160 	aStdBT.Enable(aLevelLB.GetSelectEntryPos()  != LISTBOX_ENTRY_NOTFOUND);
4161 
4162 	SwWrtShell& rSh = ((SwMultiTOXTabDialog*)GetTabDialog())->GetWrtShell();
4163 	String aTmpName(aParaLayLB.GetSelectEntry());
4164 	aAssignBT.Enable(aParaLayLB.GetSelectEntryPos() != LISTBOX_ENTRY_NOTFOUND &&
4165 					 LISTBOX_ENTRY_NOTFOUND != aLevelLB.GetSelectEntryPos() &&
4166 	   (aLevelLB.GetSelectEntryPos() == 0 || SwMultiTOXTabDialog::IsNoNum(rSh, aTmpName)));
4167 	aEditStyleBT.Enable(aParaLayLB.GetSelectEntryPos() != LISTBOX_ENTRY_NOTFOUND );
4168 	return 0;
4169 }
4170 /* -----------------------------18.01.00 16:54--------------------------------
4171 
4172  ---------------------------------------------------------------------------*/
4173 IMPL_LINK(SwTOXStylesTabPage, ModifyHdl, void*, EMPTYARG)
4174 {
4175 	SwMultiTOXTabDialog* pTOXDlg = (SwMultiTOXTabDialog*)GetTabDialog();
4176 	if(pTOXDlg)
4177 	{
4178         GetForm() = *m_pCurrentForm;
4179 		pTOXDlg->CreateOrUpdateExample(pTOXDlg->GetCurrentTOXType().eType, TOX_PAGE_STYLES);
4180 	}
4181 	return 0;
4182 }
4183 /******************************************************************************
4184 
4185 ******************************************************************************/
4186 #define ITEM_SEARCH			1
4187 #define ITEM_ALTERNATIVE    2
4188 #define ITEM_PRIM_KEY       3
4189 #define ITEM_SEC_KEY        4
4190 #define ITEM_COMMENT        5
4191 #define ITEM_CASE			6
4192 #define ITEM_WORDONLY       7
4193 
4194 
4195 SwEntryBrowseBox::SwEntryBrowseBox(Window* pParent, const ResId& rId,
4196 							   						BrowserMode nMode ) :
4197 			SwEntryBrowseBox_Base( pParent, rId, nMode,
4198 						   BROWSER_KEEPSELECTION |
4199 						   BROWSER_COLUMNSELECTION |
4200 						   BROWSER_MULTISELECTION |
4201 						   BROWSER_TRACKING_TIPS |
4202 						   BROWSER_HLINESFULL |
4203 						   BROWSER_VLINESFULL |
4204 						   BROWSER_AUTO_VSCROLL|
4205 						   BROWSER_HIDECURSOR	),
4206             aCellEdit(&GetDataWindow(), 0),
4207             aCellCheckBox(&GetDataWindow()),
4208 
4209             sSearch(        ResId(ST_SEARCH, *rId.GetResMgr()         )),
4210             sAlternative(   ResId(ST_ALTERNATIVE, *rId.GetResMgr()  )),
4211             sPrimKey(       ResId(ST_PRIMKEY, *rId.GetResMgr()      )),
4212             sSecKey(        ResId(ST_SECKEY, *rId.GetResMgr()           )),
4213             sComment(       ResId(ST_COMMENT, *rId.GetResMgr()      )),
4214             sCaseSensitive( ResId(ST_CASESENSITIVE, *rId.GetResMgr()    )),
4215             sWordOnly(      ResId(ST_WORDONLY, *rId.GetResMgr()     )),
4216             sYes(           ResId(ST_TRUE, *rId.GetResMgr()             )),
4217             sNo(            ResId(ST_FALSE, *rId.GetResMgr()            )),
4218 			bModified(sal_False)
4219 {
4220 	FreeResource();
4221 	aCellCheckBox.GetBox().EnableTriState(sal_False);
4222 	xController = new ::svt::EditCellController(&aCellEdit);
4223 	xCheckController = new ::svt::CheckBoxCellController(&aCellCheckBox);
4224 
4225 	//////////////////////////////////////////////////////////////////////
4226 	// HACK: BrowseBox invalidiert nicht ihre Childs, wie es eigentlich sein sollte.
4227 	// Deshalb wird WB_CLIPCHILDREN zurueckgesetzt, wodurch das Invalidieren
4228 	// der Childs erzwungen wird.
4229 	WinBits aStyle = GetStyle();
4230 	if( aStyle & WB_CLIPCHILDREN )
4231 	{
4232 		aStyle &= ~WB_CLIPCHILDREN;
4233 		SetStyle( aStyle );
4234 	}
4235 	const String* aTitles[7] =
4236 	{
4237 		&sSearch,
4238 		&sAlternative,
4239 		&sPrimKey,
4240 		&sSecKey,
4241 		&sComment,
4242 		&sCaseSensitive,
4243 		&sWordOnly
4244 	};
4245 
4246 	long nWidth = GetSizePixel().Width();
4247 	nWidth /=7;
4248 	--nWidth;
4249 	for(sal_uInt16 i = 1; i < 8; i++)
4250 		InsertDataColumn( i, *aTitles[i - 1], nWidth,
4251 						  HIB_STDSTYLE, HEADERBAR_APPEND );
4252 
4253 }
4254 /* -----------------------------19.01.00 11:29--------------------------------
4255 
4256  ---------------------------------------------------------------------------*/
4257 sal_Bool    SwEntryBrowseBox::SeekRow( long nRow )
4258 {
4259 	nCurrentRow = nRow;
4260 	return sal_True;
4261 }
4262 /* -----------------------------19.01.00 15:32--------------------------------
4263 
4264  ---------------------------------------------------------------------------*/
4265 String SwEntryBrowseBox::GetCellText(long nRow, sal_uInt16 nColumn) const
4266 {
4267 	const String* pRet = &aEmptyStr;
4268 	if(aEntryArr.Count() > nRow)
4269 	{
4270         AutoMarkEntry* pEntry = aEntryArr[ static_cast< sal_uInt16 >(nRow) ];
4271 		switch(nColumn)
4272 		{
4273 			case  ITEM_SEARCH		:pRet = &pEntry->sSearch; break;
4274 			case  ITEM_ALTERNATIVE  :pRet = &pEntry->sAlternative; break;
4275 			case  ITEM_PRIM_KEY     :pRet = &pEntry->sPrimKey	; break;
4276 			case  ITEM_SEC_KEY      :pRet = &pEntry->sSecKey	; break;
4277 			case  ITEM_COMMENT      :pRet = &pEntry->sComment	; break;
4278 			case  ITEM_CASE		    :pRet = pEntry->bCase ? &sYes : &sNo; break;
4279 			case  ITEM_WORDONLY		:pRet = pEntry->bWord ? &sYes : &sNo; break;
4280 		}
4281 	}
4282 	return *pRet;
4283 }
4284 
4285 /* -----------------------------19.01.00 11:29--------------------------------
4286 
4287  ---------------------------------------------------------------------------*/
4288 void 	SwEntryBrowseBox::PaintCell(OutputDevice& rDev,
4289 								const Rectangle& rRect, sal_uInt16 nColumnId) const
4290 {
4291 	String sPaint = GetCellText( nCurrentRow, nColumnId );
4292 	sal_uInt16 nStyle = TEXT_DRAW_CLIP | TEXT_DRAW_CENTER;
4293 	rDev.DrawText( rRect, sPaint, nStyle );
4294 }
4295 /* -----------------------------19.01.00 14:51--------------------------------
4296 
4297  ---------------------------------------------------------------------------*/
4298 ::svt::CellController* SwEntryBrowseBox::GetController(long /*nRow*/, sal_uInt16 nCol)
4299 {
4300 	return nCol < ITEM_CASE ? xController : xCheckController;
4301 }
4302 /* -----------------------------19.01.00 15:36--------------------------------
4303 
4304  ---------------------------------------------------------------------------*/
4305 sal_Bool SwEntryBrowseBox::SaveModified()
4306 {
4307 	SetModified();
4308     sal_uInt16 nRow = static_cast< sal_uInt16 >(GetCurRow());
4309 	sal_uInt16 nCol = GetCurColumnId();
4310 
4311 	String sNew;
4312 	sal_Bool bVal = sal_False;
4313 	::svt::CellController* pController = 0;
4314 	if(nCol < ITEM_CASE)
4315 	{
4316 		pController = xController;
4317 		sNew = ((::svt::EditCellController*)pController)->GetEditImplementation()->GetText( LINEEND_LF );
4318 	}
4319 	else
4320 	{
4321 		pController = xCheckController;
4322 		bVal = ((::svt::CheckBoxCellController*)pController)->GetCheckBox().IsChecked();
4323 	}
4324 	AutoMarkEntry* pEntry = nRow >= aEntryArr.Count() ? new AutoMarkEntry
4325 													  : aEntryArr[nRow];
4326 	switch(nCol)
4327 	{
4328 		case  ITEM_SEARCH		: pEntry->sSearch = sNew; break;
4329 		case  ITEM_ALTERNATIVE  : pEntry->sAlternative = sNew; break;
4330 		case  ITEM_PRIM_KEY     : pEntry->sPrimKey	 = sNew; break;
4331 		case  ITEM_SEC_KEY      : pEntry->sSecKey	 = sNew; break;
4332 		case  ITEM_COMMENT      : pEntry->sComment	 = sNew; break;
4333 		case  ITEM_CASE		    : pEntry->bCase = bVal; break;
4334 		case  ITEM_WORDONLY		: pEntry->bWord = bVal; break;
4335 	}
4336 	if(nRow >= aEntryArr.Count())
4337 	{
4338 		aEntryArr.Insert( pEntry, aEntryArr.Count() );
4339 		RowInserted(nRow, 1, sal_True, sal_True);
4340 		if(nCol < ITEM_WORDONLY)
4341 		{
4342 			pController->ClearModified();
4343 			GoToRow( nRow );
4344 		}
4345 	}
4346 	return sal_True;
4347 }
4348 /* -----------------------------19.01.00 14:32--------------------------------
4349 
4350  ---------------------------------------------------------------------------*/
4351 void 	SwEntryBrowseBox::InitController(
4352 				::svt::CellControllerRef& rController, long nRow, sal_uInt16 nCol)
4353 {
4354 	String rTxt = GetCellText( nRow, nCol );
4355 	if(nCol < ITEM_CASE)
4356 	{
4357 		rController = xController;
4358 		::svt::CellController* pController = xController;
4359 		((::svt::EditCellController*)pController)->GetEditImplementation()->SetText( rTxt );
4360 	}
4361 	else
4362 	{
4363 		rController = xCheckController;
4364 		::svt::CellController* pController = xCheckController;
4365 		((::svt::CheckBoxCellController*)pController)->GetCheckBox().Check(
4366 															rTxt == sYes );
4367  	}
4368 }
4369 /* -----------------------------19.01.00 12:19--------------------------------
4370 
4371  ---------------------------------------------------------------------------*/
4372 void	SwEntryBrowseBox::ReadEntries(SvStream& rInStr)
4373 {
4374 	AutoMarkEntry* pToInsert = 0;
4375 	const String sZero('0');
4376 	rtl_TextEncoding  eTEnc = gsl_getSystemTextEncoding();
4377 	while( !rInStr.GetError() && !rInStr.IsEof() )
4378 	{
4379 		String sLine;
4380 		rInStr.ReadByteStringLine( sLine, eTEnc );
4381 
4382 		// # -> comment
4383 		// ; -> delimiter between entries ->
4384 		// Format: TextToSearchFor;AlternativeString;PrimaryKey;SecondaryKey
4385 		// Leading and trailing blanks are ignored
4386 		if( sLine.Len() )
4387 		{
4388 			//comments are contained in separate lines but are put into the struct of the following data
4389 			//line (if available)
4390 			if( '#' != sLine.GetChar(0) )
4391 			{
4392 				if( !pToInsert )
4393 					pToInsert = new AutoMarkEntry;
4394 
4395 				sal_uInt16 nSttPos = 0;
4396 				pToInsert->sSearch 		= sLine.GetToken(0, ';', nSttPos );
4397 				pToInsert->sAlternative = sLine.GetToken(0, ';', nSttPos );
4398 				pToInsert->sPrimKey 	= sLine.GetToken(0, ';', nSttPos );
4399 				pToInsert->sSecKey 		= sLine.GetToken(0, ';', nSttPos );
4400 
4401 				String sStr = sLine.GetToken(0, ';', nSttPos );
4402 				pToInsert->bCase = sStr.Len() && sStr != sZero;
4403 
4404 				sStr = sLine.GetToken(0, ';', nSttPos );
4405 				pToInsert->bWord = sStr.Len() && sStr != sZero;
4406 
4407 				aEntryArr.Insert( pToInsert, aEntryArr.Count() );
4408 				pToInsert = 0;
4409 			}
4410 			else
4411 			{
4412 				if(pToInsert)
4413 					aEntryArr.Insert(pToInsert, aEntryArr.Count());
4414 				pToInsert = new AutoMarkEntry;
4415 				pToInsert->sComment = sLine;
4416 				pToInsert->sComment.Erase(0, 1);
4417 			}
4418 		}
4419 	}
4420 	if( pToInsert )
4421 		aEntryArr.Insert(pToInsert, aEntryArr.Count());
4422 	RowInserted(0, aEntryArr.Count() + 1, sal_True);
4423 }
4424 /* -----------------------------19.01.00 12:19--------------------------------
4425 
4426  ---------------------------------------------------------------------------*/
4427 void	SwEntryBrowseBox::WriteEntries(SvStream& rOutStr)
4428 {
4429 	//check if the current controller is modified
4430 	sal_uInt16 nCol = GetCurColumnId();
4431 	::svt::CellController* pController;
4432 	if(nCol < ITEM_CASE)
4433 		pController = xController;
4434 	else
4435 		pController = xCheckController;
4436 	if(pController ->IsModified())
4437 		GoToColumnId(nCol < ITEM_CASE ? ++nCol : --nCol );
4438 
4439 	rtl_TextEncoding  eTEnc = gsl_getSystemTextEncoding();
4440 	for(sal_uInt16 i = 0; i < aEntryArr.Count();i++)
4441 	{
4442 		AutoMarkEntry* pEntry = aEntryArr[i];
4443 		if(pEntry->sComment.Len())
4444 		{
4445 			String sWrite('#');
4446 			sWrite += pEntry->sComment;
4447 			rOutStr.WriteByteStringLine( sWrite, eTEnc );
4448 		}
4449 
4450 		String sWrite( pEntry->sSearch );
4451 		sWrite += ';';
4452 		sWrite += pEntry->sAlternative;
4453 		sWrite += ';';
4454 		sWrite += pEntry->sPrimKey;
4455 		sWrite += ';';
4456 		sWrite += pEntry->sSecKey;
4457 		sWrite += ';';
4458 		sWrite += pEntry->bCase ? '1' : '0';
4459 		sWrite += ';';
4460 		sWrite += pEntry->bWord ? '1' : '0';
4461 
4462 		if( sWrite.Len() > 5 )
4463 			rOutStr.WriteByteStringLine( sWrite, eTEnc );
4464 	}
4465 }
4466 /* -----------------------------21.01.00 11:49--------------------------------
4467 
4468  ---------------------------------------------------------------------------*/
4469 sal_Bool SwEntryBrowseBox::IsModified()const
4470 {
4471 	if(bModified)
4472 		return sal_True;
4473 
4474 
4475 	//check if the current controller is modified
4476 	sal_uInt16 nCol = GetCurColumnId();
4477 	::svt::CellController* pController;
4478 	if(nCol < ITEM_CASE)
4479 		pController = xController;
4480 	else
4481 		pController = xCheckController;
4482 	return pController ->IsModified();
4483 }
4484 /* -----------------------------19.01.00 11:29--------------------------------
4485 
4486  ---------------------------------------------------------------------------*/
4487 SwAutoMarkDlg_Impl::SwAutoMarkDlg_Impl(Window* pParent, const String& rAutoMarkURL,
4488 		const String& rAutoMarkType, sal_Bool bCreate) :
4489 	ModalDialog(pParent, SW_RES(DLG_CREATE_AUTOMARK)),
4490 	aOKPB(		this, SW_RES(PB_OK		)),
4491 	aCancelPB(	this, SW_RES(PB_CANCEL	)),
4492 	aHelpPB(	this, SW_RES(PB_HELP		)),
4493 	aEntriesBB(	this, SW_RES(BB_ENTRIES	)),
4494     aEntriesFL( this, SW_RES(FL_ENTRIES  )),
4495 	sAutoMarkURL(rAutoMarkURL),
4496 	sAutoMarkType(rAutoMarkType),
4497 	bCreateMode(bCreate)
4498 {
4499 	FreeResource();
4500 	aOKPB.SetClickHdl(LINK(this, SwAutoMarkDlg_Impl, OkHdl));
4501 
4502 	String sTitle = GetText();
4503 	sTitle.AppendAscii( RTL_CONSTASCII_STRINGPARAM(": "));
4504 	sTitle += sAutoMarkURL;
4505 	SetText(sTitle);
4506 	sal_Bool bError = sal_False;
4507 	if( bCreateMode )
4508 		aEntriesBB.RowInserted(0, 1, sal_True);
4509 	else
4510 	{
4511 		SfxMedium aMed( sAutoMarkURL, STREAM_STD_READ, sal_False );
4512 		if( aMed.GetInStream() && !aMed.GetInStream()->GetError() )
4513 			aEntriesBB.ReadEntries( *aMed.GetInStream() );
4514 		else
4515 			bError = sal_True;
4516 	}
4517 
4518 	if(bError)
4519 		EndDialog(RET_CANCEL);
4520 }
4521 /* -----------------------------19.01.00 11:12--------------------------------
4522 
4523  ---------------------------------------------------------------------------*/
4524 SwAutoMarkDlg_Impl::~SwAutoMarkDlg_Impl()
4525 {
4526 }
4527 /* -----------------------------19.01.00 16:43--------------------------------
4528 
4529  ---------------------------------------------------------------------------*/
4530 IMPL_LINK(SwAutoMarkDlg_Impl, OkHdl, OKButton*, EMPTYARG)
4531 {
4532 	sal_Bool bError = sal_False;
4533 	if(aEntriesBB.IsModified() || bCreateMode)
4534 	{
4535 		SfxMedium aMed( sAutoMarkURL,
4536 						bCreateMode ? STREAM_WRITE
4537 									: STREAM_WRITE| STREAM_TRUNC,
4538 						sal_False );
4539 		SvStream* pStrm = aMed.GetOutStream();
4540 		pStrm->SetStreamCharSet( RTL_TEXTENCODING_MS_1253 );
4541 		if( !pStrm->GetError() )
4542 		{
4543 			aEntriesBB.WriteEntries( *pStrm );
4544 			aMed.Commit();
4545 		}
4546 		else
4547 			bError = sal_True;
4548 	}
4549 	if( !bError )
4550 		EndDialog(RET_OK);
4551 	return 0;
4552 }
4553 
4554