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