xref: /aoo4110/main/sw/source/ui/index/cnttab.cxx (revision b1cdbd2c)
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  --------------------------------------------------*/
lcl_CreateAutoMarkFileDlg(const String & rURL,const String & rFileString,sal_Bool bOpen)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 
AutoMarkEntryAutoMarkEntry180 	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 
SetModified()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  --------------------------------------------------*/
GetFlatIndex() const259 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  --------------------------------------------------*/
SwMultiTOXTabDialog(Window * pParent,const SfxItemSet & rSet,SwWrtShell & rShell,SwTOXBase * pCurTOX,sal_uInt16 nToxType,sal_Bool bGlobal)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   -----------------------------------------------------------------------*/
~SwMultiTOXTabDialog()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   -----------------------------------------------------------------------*/
PageCreated(sal_uInt16 nId,SfxTabPage & rPage)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   -----------------------------------------------------------------------*/
Ok()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  --------------------------------------------------*/
GetForm(CurTOXType eType)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  --------------------------------------------------*/
GetTOXDescription(CurTOXType eType)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  --------------------------------------------------*/
CreateTOXDescFromTOXBase(const SwTOXBase * pCurTOX)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 
IMPL_LINK(SwMultiTOXTabDialog,ShowPreviewHdl,CheckBox *,pBox)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  --------------------------------------------------*/
IsNoNum(SwWrtShell & rSh,const String & rName)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:
SwIndexTreeLB(Window * pWin,const ResId & rResId)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* );
SetHeaderBar(const HeaderBar * pHB)665 	void			SetHeaderBar(const HeaderBar* pHB) {pHeaderBar = pHB;}
666 };
667 /* -----------------14.07.99 16:03-------------------
668 
669  --------------------------------------------------*/
GetTabPos(SvLBoxEntry * pEntry,SvLBoxTab * pTab)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  --------------------------------------------------*/
KeyInput(const KeyEvent & rKEvt)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 
GetHeaderBar()731 	HeaderBar&		GetHeaderBar() {return aStylesHB;}
GetTreeListBox()732 	SwIndexTreeLB& 	GetTreeListBox() { return aStylesTLB;}
733 
734 	virtual void	GetFocus();
735 };
736 /* -----------------16.07.99 10:11-------------------
737 
738  --------------------------------------------------*/
SwHeaderTree(Window * pParent,const ResId rResId)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  --------------------------------------------------*/
GetFocus()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  --------------------------------------------------*/
SwAddStylesDlg_Impl(Window * pParent,SwWrtShell & rWrtSh,String rStringArr[])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  --------------------------------------------------*/
~SwAddStylesDlg_Impl()881 SwAddStylesDlg_Impl::~SwAddStylesDlg_Impl()
882 {
883 }
884 /* -----------------13.07.99 15:39-------------------
885 
886  --------------------------------------------------*/
IMPL_LINK(SwAddStylesDlg_Impl,OkHdl,OKButton *,EMPTYARG)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  --------------------------------------------------*/
IMPL_LINK(SwAddStylesDlg_Impl,HeaderDragHdl,HeaderBar *,EMPTYARG)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  --------------------------------------------------*/
IMPL_LINK(SwAddStylesDlg_Impl,LeftRightHdl,PushButton *,pBtn)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   -----------------------------------------------------------------------*/
SwTOXSelectTabPage(Window * pParent,const SfxItemSet & rAttrSet)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   -----------------------------------------------------------------------*/
~SwTOXSelectTabPage()1086 SwTOXSelectTabPage::~SwTOXSelectTabPage()
1087 {
1088     delete pIndexRes;
1089     delete pIndexEntryWrapper;
1090 }
1091 /* -----------------21.10.99 17:03-------------------
1092 
1093  --------------------------------------------------*/
SetWrtShell(SwWrtShell & rSh)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  --------------------------------------------------*/
FillItemSet(SfxItemSet &)1114 sal_Bool SwTOXSelectTabPage::FillItemSet( SfxItemSet& )
1115 {
1116 	return sal_True;
1117 }
1118 /* -----------------25.08.99 14:31-------------------
1119 
1120  --------------------------------------------------*/
lcl_TOXTypesToUserData(CurTOXType eType)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 //-----------------------------------------------------------------
SelectType(TOXTypes eSet)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 //-----------------------------------------------------------------
lcl_UserData2TOXTypes(sal_uInt16 nData)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  --------------------------------------------------*/
ApplyTOXDescription()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  --------------------------------------------------*/
FillTOXDescription()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  --------------------------------------------------*/
Reset(const SfxItemSet &)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   -----------------------------------------------------------------------*/
ActivatePage(const SfxItemSet &)1447 void SwTOXSelectTabPage::ActivatePage( const SfxItemSet& )
1448 {
1449 	//nothing to do
1450 }
1451 /*-- 14.06.99 13:11:00---------------------------------------------------
1452 
1453   -----------------------------------------------------------------------*/
DeactivatePage(SfxItemSet * _pSet)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  --------------------------------------------------*/
Create(Window * pParent,const SfxItemSet & rAttrSet)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  --------------------------------------------------*/
IMPL_LINK(SwTOXSelectTabPage,TOXTypeHdl,ListBox *,pBox)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  --------------------------------------------------*/
IMPL_LINK(SwTOXSelectTabPage,ModifyHdl,void *,EMPTYARG)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  --------------------------------------------------*/
IMPL_LINK(SwTOXSelectTabPage,CheckBoxHdl,CheckBox *,pBox)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  --------------------------------------------------*/
IMPL_LINK(SwTOXSelectTabPage,RadioButtonHdl,RadioButton *,EMPTYARG)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  ---------------------------------------------------------------------------*/
IMPL_LINK(SwTOXSelectTabPage,LanguageHdl,ListBox *,pBox)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  --------------------------------------------------*/
IMPL_LINK(SwTOXSelectTabPage,TOXAreaHdl,ListBox *,pBox)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  --------------------------------------------------*/
IMPL_LINK(SwTOXSelectTabPage,AddStylesHdl,PushButton *,pButton)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 
IMPL_LINK(SwTOXSelectTabPage,MenuEnableHdl,Menu *,pMenu)1759 IMPL_LINK(SwTOXSelectTabPage, MenuEnableHdl, Menu*, pMenu)
1760 {
1761     pMenu->EnableItem(MN_AUTOMARK_EDIT, sAutoMarkURL.Len() > 0);
1762 	return 0;
1763 }
1764 
IMPL_LINK(SwTOXSelectTabPage,MenuExecuteHdl,Menu *,pMenu)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:
SwTOXEdit(Window * pParent,SwTokenWindow * pTokenWin,const SwFormToken & aToken)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 
IsNextControl() const1819 	sal_Bool	IsNextControl() const {return bNextControl;}
SetPrevNextLink(const Link & rLink)1820 	void SetPrevNextLink( const Link& rLink )	{aPrevNextControlLink = rLink;}
1821 
GetFormToken()1822 	const SwFormToken&	GetFormToken()
1823 		{
1824 			aFormToken.sText = GetText();
1825 			return aFormToken;
1826 		}
1827 
SetCharStyleName(const String & rSet,sal_uInt16 nPoolId)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 //---------------------------------------------------
RequestHelp(const HelpEvent & rHEvt)1838 void	SwTOXEdit::RequestHelp( const HelpEvent& rHEvt )
1839 {
1840 	if(!m_pParent->CreateQuickHelp(this, aFormToken, rHEvt))
1841 		Edit::RequestHelp(rHEvt);
1842 }
1843 //---------------------------------------------------
KeyInput(const KeyEvent & rKEvt)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 		else if ( (aCode.GetCode() == KEY_F3) && aCode.IsShift() && !aCode.IsMod1() && !aCode.IsMod2() )
1864 		{
1865 			if ( m_pParent )
1866 			{
1867 				m_pParent->SetFocus2theAllBtn();
1868 			}
1869 		}
1870 		if(bCall && aPrevNextControlLink.IsSet())
1871 			aPrevNextControlLink.Call(this);
1872 
1873 	}
1874 	Edit::KeyInput(rKEvt);
1875 }
1876 /* -----------------16.07.99 12:41-------------------
1877 
1878  --------------------------------------------------*/
AdjustSize()1879 void SwTOXEdit::AdjustSize()
1880 {
1881  	Size aSize(GetSizePixel());
1882  	Size aTextSize(GetTextWidth(GetText()), GetTextHeight());
1883 	aTextSize = LogicToPixel(aTextSize);
1884 	aSize.Width() = aTextSize.Width() + EDIT_MINWIDTH;
1885 	SetSizePixel(aSize);
1886 }
1887 
1888 //---------------------------------------------------
1889 //---------------------------------------------------
1890 class SwTOXButton : public PushButton
1891 {
1892 	SwFormToken	aFormToken;
1893 	Link		aPrevNextControlLink;
1894 	sal_Bool		bNextControl;
1895 	SwTokenWindow* m_pParent;
1896 public:
SwTOXButton(Window * pParent,SwTokenWindow * pTokenWin,const SwFormToken & rToken)1897 	SwTOXButton( Window* pParent, SwTokenWindow* pTokenWin,
1898 				const SwFormToken& rToken)
1899 		: PushButton(pParent, WB_BORDER|WB_TABSTOP),
1900         aFormToken(rToken),
1901 		bNextControl(sal_False),
1902 		m_pParent(pTokenWin)
1903 	{
1904 		SetHelpId(HID_TOX_ENTRY_BUTTON);
1905 	}
1906 
1907 	virtual void	KeyInput( const KeyEvent& rKEvt );
1908 	virtual void	RequestHelp( const HelpEvent& rHEvt );
1909 
IsNextControl() const1910 	sal_Bool IsNextControl() const 			{return bNextControl;}
SetPrevNextLink(const Link & rLink)1911 	void SetPrevNextLink(const Link& rLink) {aPrevNextControlLink = rLink;}
GetFormToken() const1912 	const SwFormToken& GetFormToken() const	{return aFormToken;}
1913 
SetCharStyleName(const String & rSet,sal_uInt16 nPoolId)1914 	void SetCharStyleName(const String& rSet, sal_uInt16 nPoolId)
1915 		{
1916 			aFormToken.sCharStyleName = rSet;
1917 			aFormToken.nPoolId = nPoolId;
1918 		}
1919 
SetTabPosition(SwTwips nSet)1920 	void SetTabPosition(SwTwips nSet)
1921 		{ aFormToken.nTabStopPosition = nSet; }
1922 
SetFillChar(sal_Unicode cSet)1923 	void SetFillChar( sal_Unicode cSet )
1924 		{ aFormToken.cTabFillChar = cSet; }
1925 
SetTabAlign(SvxTabAdjust eAlign)1926 	void SetTabAlign(SvxTabAdjust eAlign)
1927 		 {	aFormToken.eTabAlign = eAlign;}
1928 
1929 //---> i89791
1930     //used for entry number format, in TOC only
1931     //needed for different UI dialog position
SetEntryNumberFormat(sal_uInt16 nSet)1932     void SetEntryNumberFormat(sal_uInt16 nSet) {
1933         switch(nSet)
1934         {
1935         default:
1936         case 0:
1937             aFormToken.nChapterFormat = CF_NUMBER;
1938             break;
1939         case 1:
1940             aFormToken.nChapterFormat = CF_NUM_NOPREPST_TITLE;
1941             break;
1942         }
1943     }
1944 
SetChapterInfo(sal_uInt16 nSet)1945     void SetChapterInfo(sal_uInt16 nSet) {
1946         switch(nSet)
1947         {
1948         default:
1949         case 0:
1950             aFormToken.nChapterFormat = CF_NUM_NOPREPST_TITLE;
1951             break;
1952         case 1:
1953             aFormToken.nChapterFormat = CF_TITLE;
1954             break;
1955         case 2:
1956             aFormToken.nChapterFormat = CF_NUMBER_NOPREPST;
1957             break;
1958         }
1959     }
1960 //<---
GetChapterInfo() const1961 	sal_uInt16 GetChapterInfo() const{ return aFormToken.nChapterFormat;}
1962 
SetOutlineLevel(sal_uInt16 nSet)1963     void SetOutlineLevel( sal_uInt16 nSet ) { aFormToken.nOutlineLevel = nSet;}//i53420
GetOutlineLevel() const1964     sal_uInt16 GetOutlineLevel() const{ return aFormToken.nOutlineLevel;}
1965 
SetLinkEnd()1966 	void SetLinkEnd()
1967 		{
1968 			DBG_ASSERT(TOKEN_LINK_START == aFormToken.eTokenType,
1969 									"call SetLinkEnd for link start only!");
1970 			aFormToken.eTokenType = TOKEN_LINK_END;
1971 			aFormToken.sText.AssignAscii(SwForm::aFormLinkEnd);
1972 			SetText(aFormToken.sText);
1973 		}
SetLinkStart()1974 	void SetLinkStart()
1975 		{
1976 			DBG_ASSERT(TOKEN_LINK_END == aFormToken.eTokenType,
1977 									"call SetLinkStart for link start only!");
1978 			aFormToken.eTokenType = TOKEN_LINK_START;
1979 			aFormToken.sText.AssignAscii(SwForm::aFormLinkStt);
1980 			SetText(aFormToken.sText);
1981 		}
1982 };
1983 
1984 //---------------------------------------------------
KeyInput(const KeyEvent & rKEvt)1985 void	SwTOXButton::KeyInput( const KeyEvent& rKEvt )
1986 {
1987 	sal_Bool bCall = sal_False;
1988 	KeyCode aCode = rKEvt.GetKeyCode();
1989 	if(aCode.GetCode() == KEY_RIGHT)
1990 	{
1991 		bNextControl = sal_True;
1992 		bCall = sal_True;
1993 	}
1994 	else if(aCode.GetCode() == KEY_LEFT  )
1995 	{
1996 		bNextControl = sal_False;
1997 		bCall = sal_True;
1998 	}
1999 	else if(aCode.GetCode() == KEY_DELETE)
2000 	{
2001 		m_pParent->RemoveControl(this, sal_True);
2002 		//this is invalid here
2003 		return;
2004 	}
2005 	else if ( (aCode.GetCode() == KEY_F3) && aCode.IsShift() && !aCode.IsMod1() && !aCode.IsMod2() )
2006 	{
2007 		if ( m_pParent )
2008 		{
2009 			m_pParent->SetFocus2theAllBtn();
2010 		}
2011 	}
2012 	if(bCall && aPrevNextControlLink.IsSet())
2013 			aPrevNextControlLink.Call(this);
2014 	else
2015 		PushButton::KeyInput(rKEvt);
2016 }
2017 //---------------------------------------------------
RequestHelp(const HelpEvent & rHEvt)2018 void	SwTOXButton::RequestHelp( const HelpEvent& rHEvt )
2019 {
2020 	if(!m_pParent->CreateQuickHelp(this, aFormToken, rHEvt))
2021 		Button::RequestHelp(rHEvt);
2022 }
2023 /* -----------------------------23.12.99 14:28--------------------------------
2024 
2025  ---------------------------------------------------------------------------*/
SwIdxTreeListBox(SwTOXEntryTabPage * pPar,const ResId & rResId)2026 SwIdxTreeListBox::SwIdxTreeListBox(SwTOXEntryTabPage* pPar, const ResId& rResId) :
2027 		SvTreeListBox(pPar, rResId),
2028 		pParent(pPar)
2029 {
2030 }
2031 /* -----------------------------23.12.99 14:19--------------------------------
2032 
2033  ---------------------------------------------------------------------------*/
RequestHelp(const HelpEvent & rHEvt)2034 void    SwIdxTreeListBox::RequestHelp( const HelpEvent& rHEvt )
2035 {
2036 	if( rHEvt.GetMode() & HELPMODE_QUICK )
2037 	{
2038 	 Point aPos( ScreenToOutputPixel( rHEvt.GetMousePosPixel() ));
2039 		SvLBoxEntry* pEntry = GetEntry( aPos );
2040 		if( pEntry )
2041 		{
2042             sal_uInt16 nLevel = static_cast< sal_uInt16 >(GetModel()->GetAbsPos(pEntry));
2043 			String sEntry = pParent->GetLevelHelp(++nLevel);
2044 			if('*' == sEntry)
2045 				sEntry = GetEntryText(pEntry);
2046 			if(sEntry.Len())
2047 			{
2048 				SvLBoxTab* pTab;
2049 				SvLBoxItem* pItem = GetItem( pEntry, aPos.X(), &pTab );
2050 				if( pItem && SV_ITEM_ID_LBOXSTRING == pItem->IsA())
2051 				{
2052 					aPos = GetEntryPosition( pEntry );
2053 
2054 					aPos.X() = GetTabPos( pEntry, pTab );
2055 				 Size aSize( pItem->GetSize( this, pEntry ) );
2056 
2057 					if((aPos.X() + aSize.Width()) > GetSizePixel().Width())
2058 						aSize.Width() = GetSizePixel().Width() - aPos.X();
2059 
2060 					aPos = OutputToScreenPixel(aPos);
2061 				 	Rectangle aItemRect( aPos, aSize );
2062 					Help::ShowQuickHelp( this, aItemRect, sEntry,
2063 							QUICKHELP_LEFT|QUICKHELP_VCENTER );
2064 				}
2065 			}
2066 		}
2067 	}
2068 	else
2069 		SvTreeListBox::RequestHelp(rHEvt);
2070 }
2071 //---------------------------------------------------
SwTOXEntryTabPage(Window * pParent,const SfxItemSet & rAttrSet)2072 SwTOXEntryTabPage::SwTOXEntryTabPage(Window* pParent, const SfxItemSet& rAttrSet) :
2073 		SfxTabPage(pParent, SW_RES(TP_TOX_ENTRY), rAttrSet),
2074     aLevelFT(this,              SW_RES(FT_LEVEL              )),
2075     aLevelLB(this,              SW_RES(LB_LEVEL             )),
2076     aEntryFL(this,              SW_RES(FL_ENTRY              )),
2077 
2078     aTokenFT(this,              SW_RES(FT_TOKEN              )),
2079     aTokenWIN(this,             SW_RES(WIN_TOKEN             )),
2080     aAllLevelsPB(this,          SW_RES(PB_ALL_LEVELS            )),
2081 
2082     aEntryNoPB(this,            SW_RES(PB_ENTRYNO            )),
2083     aEntryPB(this,              SW_RES(PB_ENTRY             )),
2084     aTabPB(this,                SW_RES(PB_TAB                )),
2085     aChapterInfoPB(this,        SW_RES(PB_CHAPTERINFO        )),
2086     aPageNoPB(this,             SW_RES(PB_PAGENO                )),
2087     aHyperLinkPB(this,          SW_RES(PB_HYPERLINK         )),
2088 
2089     aAuthFieldsLB(this,         SW_RES(LB_AUTHFIELD          )),
2090     aAuthInsertPB(this,         SW_RES(PB_AUTHINSERT            )),
2091     aAuthRemovePB(this,         SW_RES(PB_AUTHREMOVE            )),
2092 
2093     aCharStyleFT(this,          SW_RES(FT_CHARSTYLE          )),
2094     aCharStyleLB(this,          SW_RES(LB_CHARSTYLE         )),
2095     aEditStylePB(this,          SW_RES(PB_EDITSTYLE         )),
2096 
2097     aChapterEntryFT(this,       SW_RES(FT_CHAPTERENTRY       )),
2098     aChapterEntryLB(this,       SW_RES(LB_CHAPTERENTRY       )),
2099 
2100     aNumberFormatFT(this, 		SW_RES(FT_ENTRY_NO           )),//i53420
2101     aNumberFormatLB(this, 		SW_RES(LB_ENTRY_NO           )),
2102     aEntryOutlineLevelFT(this,  SW_RES(FT_LEVEL_OL           )),//i53420
2103     aEntryOutlineLevelNF(this,  SW_RES(NF_LEVEL_OL           )),
2104 
2105     aFillCharFT(this,           SW_RES(FT_FILLCHAR           )),
2106     aFillCharCB(this,           SW_RES(CB_FILLCHAR          )),
2107     aTabPosFT(this,             SW_RES(FT_TABPOS                )),
2108     aTabPosMF(this,             SW_RES(MF_TABPOS                )),
2109     aAutoRightCB(this,          SW_RES(CB_AUTORIGHT         )),
2110     aFormatFL(this,             SW_RES(FL_FORMAT             )),
2111 
2112 
2113     aRelToStyleCB(this,         SW_RES(CB_RELTOSTYLE         )),
2114     aMainEntryStyleFT(this,     SW_RES(FT_MAIN_ENTRY_STYLE)),
2115     aMainEntryStyleLB(this,     SW_RES(LB_MAIN_ENTRY_STYLE)),
2116     aAlphaDelimCB(this,         SW_RES(CB_ALPHADELIM            )),
2117     aCommaSeparatedCB(this,     SW_RES(CB_COMMASEPARATED        )),
2118 
2119     aSortDocPosRB(this,         SW_RES(RB_DOCPOS                )),
2120     aSortContentRB(this,        SW_RES(RB_SORTCONTENT       )),
2121     aSortingFL(this,            SW_RES(FL_SORTING            )),
2122 
2123     aFirstKeyFT(this,           SW_RES(FT_FIRSTKEY          )),
2124     aFirstKeyLB(this,           SW_RES(LB_FIRSTKEY          )),
2125     aFirstSortUpRB(this,        SW_RES(RB_SORTUP1            )),
2126     aFirstSortDownRB(this,      SW_RES(RB_SORTDOWN1          )),
2127 
2128     aSecondKeyFT(this,          SW_RES(FT_SECONDKEY          )),
2129     aSecondKeyLB(this,          SW_RES(LB_SECONDKEY         )),
2130     aSecondSortUpRB(this,       SW_RES(RB_SORTUP2            )),
2131     aSecondSortDownRB(this,     SW_RES(RB_SORTDOWN2          )),
2132 
2133     aThirdKeyFT(this,           SW_RES(FT_THIRDDKEY          )),
2134     aThirdKeyLB(this,           SW_RES(LB_THIRDKEY           )),
2135     aThirdSortUpRB(this,        SW_RES(RB_SORTUP3           )),
2136     aThirdSortDownRB(this,      SW_RES(RB_SORTDOWN3          )),
2137 
2138     aSortKeyFL(this,            SW_RES(FL_SORTKEY            )),
2139 
2140     sDelimStr(                  SW_RES(STR_DELIM)),
2141     sAuthTypeStr(               SW_RES(ST_AUTHTYPE)),
2142 
2143     sNoCharStyle(               SW_RES(STR_NO_CHAR_STYLE)),
2144     sNoCharSortKey(             SW_RES(STR_NOSORTKEY        )),
2145     m_pCurrentForm(0),
2146 	bInLevelHdl(sal_False)
2147 {
2148 	aEditStylePB.SetAccessibleRelationMemberOf(&aEntryFL);
2149 	aHyperLinkPB.SetAccessibleRelationMemberOf(&aEntryFL);
2150 	aPageNoPB.SetAccessibleRelationMemberOf(&aEntryFL);
2151 	aTabPB.SetAccessibleRelationMemberOf(&aEntryFL);
2152 	aEntryPB.SetAccessibleRelationMemberOf(&aEntryFL);
2153 	aEntryNoPB.SetAccessibleRelationMemberOf(&aEntryFL);
2154 	aAllLevelsPB.SetAccessibleRelationMemberOf(&aEntryFL);
2155 	aTokenWIN.SetAccessibleRelationMemberOf(&aEntryFL);
2156 	aTokenWIN.SetAccessibleRelationLabeledBy(&aTokenFT);
2157 
2158 	Image aSortUpHC(SW_RES(IMG_SORTUP_HC ));
2159 	aFirstSortUpRB.SetModeRadioImage(aSortUpHC,BMP_COLOR_HIGHCONTRAST);
2160 	aSecondSortUpRB.SetModeRadioImage(aSortUpHC,BMP_COLOR_HIGHCONTRAST);
2161 	aThirdSortUpRB.SetModeRadioImage(aSortUpHC,BMP_COLOR_HIGHCONTRAST);
2162 
2163 	Image aSortDownHC(SW_RES(IMG_SORTDOWN_HC ));
2164 	aFirstSortDownRB.SetModeRadioImage(aSortDownHC,BMP_COLOR_HIGHCONTRAST);
2165 	aSecondSortDownRB.SetModeRadioImage(aSortDownHC,BMP_COLOR_HIGHCONTRAST);
2166 	aThirdSortDownRB.SetModeRadioImage(aSortDownHC,BMP_COLOR_HIGHCONTRAST);
2167 	FreeResource();
2168 
2169 	sLevelStr = aLevelFT.GetText();
2170 	aLevelLB.SetStyle( aLevelLB.GetStyle() | WB_HSCROLL );
2171 	aLevelLB.SetSpaceBetweenEntries(0);
2172 	aLevelLB.SetSelectionMode( SINGLE_SELECTION );
2173 	aLevelLB.SetHighlightRange();	// select full width
2174 	aLevelLB.SetHelpId(HID_INSERT_INDEX_ENTRY_LEVEL_LB);
2175 	aLevelLB.Show();
2176 
2177 	aLastTOXType.eType = (TOXTypes)USHRT_MAX;
2178 	aLastTOXType.nIndex = 0;
2179 	//aLevelGBSize = aLevelGB.GetSizePixel();
2180     aLevelFLSize = aLevelFT.GetSizePixel();
2181 
2182 	SetExchangeSupport();
2183 	aEntryNoPB.SetClickHdl(LINK(this, SwTOXEntryTabPage, InsertTokenHdl));
2184 	aEntryPB.SetClickHdl(LINK(this, SwTOXEntryTabPage, InsertTokenHdl));
2185 	aChapterInfoPB.SetClickHdl(LINK(this, SwTOXEntryTabPage, InsertTokenHdl));
2186 	aPageNoPB.SetClickHdl(LINK(this, SwTOXEntryTabPage, InsertTokenHdl));
2187 	aTabPB.SetClickHdl(LINK(this, SwTOXEntryTabPage, InsertTokenHdl));
2188 	aHyperLinkPB.SetClickHdl(LINK(this, SwTOXEntryTabPage, InsertTokenHdl));
2189 	aEditStylePB.SetClickHdl(LINK(this, SwTOXEntryTabPage, EditStyleHdl));
2190 	aLevelLB.SetSelectHdl(LINK(this, SwTOXEntryTabPage, LevelHdl));
2191 	aTokenWIN.SetButtonSelectedHdl(LINK(this, SwTOXEntryTabPage, TokenSelectedHdl));
2192 	aTokenWIN.SetModifyHdl(LINK(this, SwTOXEntryTabPage, ModifyHdl));
2193 	aCharStyleLB.SetSelectHdl(LINK(this, SwTOXEntryTabPage, StyleSelectHdl));
2194 	aCharStyleLB.InsertEntry(sNoCharStyle);
2195 	aChapterEntryLB.SetSelectHdl(LINK(this, SwTOXEntryTabPage, ChapterInfoHdl));
2196 	aEntryOutlineLevelNF.SetModifyHdl(LINK(this, SwTOXEntryTabPage, ChapterInfoOutlineHdl));
2197 	aNumberFormatLB.SetSelectHdl(LINK(this, SwTOXEntryTabPage, NumberFormatHdl));
2198 
2199 	aTabPosMF.SetModifyHdl(LINK(this, SwTOXEntryTabPage, TabPosHdl));
2200 	aFillCharCB.SetModifyHdl(LINK(this, SwTOXEntryTabPage, FillCharHdl));
2201 	aAutoRightCB.SetClickHdl(LINK(this, SwTOXEntryTabPage, AutoRightHdl));
2202 	aAuthInsertPB.SetClickHdl(LINK(this, SwTOXEntryTabPage, RemoveInsertAuthHdl));
2203 	aAuthRemovePB.SetClickHdl(LINK(this, SwTOXEntryTabPage, RemoveInsertAuthHdl));
2204 	aSortDocPosRB.SetClickHdl(LINK(this, SwTOXEntryTabPage, SortKeyHdl));
2205 	aSortContentRB.SetClickHdl(LINK(this, SwTOXEntryTabPage, SortKeyHdl));
2206 	aAllLevelsPB.SetClickHdl(LINK(this, SwTOXEntryTabPage, AllLevelsHdl));
2207 
2208 	aAlphaDelimCB.SetClickHdl(LINK(this, SwTOXEntryTabPage, ModifyHdl));
2209 	aCommaSeparatedCB.SetClickHdl(LINK(this, SwTOXEntryTabPage, ModifyHdl));
2210 	aRelToStyleCB.SetClickHdl(LINK(this, SwTOXEntryTabPage, ModifyHdl));
2211 
2212     FieldUnit aMetric = ::GetDfltMetric(sal_False);
2213     SetMetric(aTabPosMF, aMetric);
2214 
2215     aSortDocPosRB.Check();
2216 
2217 	aFillCharCB.SetMaxTextLen(1);
2218 	aFillCharCB.InsertEntry(' ');
2219 	aFillCharCB.InsertEntry('.');
2220 	aFillCharCB.InsertEntry('-');
2221 	aFillCharCB.InsertEntry('_');
2222 
2223 	aButtonPositions[0] = aEntryNoPB.GetPosPixel();
2224 	aButtonPositions[1] = aEntryPB.GetPosPixel();
2225 	aButtonPositions[2] = aChapterInfoPB.GetPosPixel();
2226 	aButtonPositions[3] = aPageNoPB.GetPosPixel();
2227 	aButtonPositions[4] = aTabPB.GetPosPixel();
2228 
2229 	aRelToStylePos = aRelToStyleCB.GetPosPixel();
2230 	aRelToStyleIdxPos = aCommaSeparatedCB.GetPosPixel();
2231 	aRelToStyleIdxPos.Y() +=
2232 		(aRelToStyleIdxPos.Y() - aAlphaDelimCB.GetPosPixel().Y());
2233 	aEditStylePB.Enable(sal_False);
2234 
2235 //get position for Numbering and other stuff
2236     aChapterEntryFTPosition = aChapterEntryFT.GetPosPixel();
2237     aEntryOutlineLevelFTPosition = aEntryOutlineLevelFT.GetPosPixel();
2238     nBiasToEntryPoint = aEntryOutlineLevelNF.GetPosPixel().X() -
2239                                aEntryOutlineLevelFT.GetPosPixel().X();
2240 
2241 	//fill the types in
2242     sal_uInt16 i;
2243 	for( i = 0; i < AUTH_FIELD_END; i++)
2244 	{
2245 		String sTmp(SW_RES(STR_AUTH_FIELD_START + i));
2246 		sal_uInt16 nPos = aAuthFieldsLB.InsertEntry(sTmp);
2247         aAuthFieldsLB.SetEntryData(nPos, reinterpret_cast< void * >(sal::static_int_cast< sal_uIntPtr >(i)));
2248 	}
2249 	sal_uInt16 nPos = aFirstKeyLB.InsertEntry(sNoCharSortKey);
2250     aFirstKeyLB.SetEntryData(nPos, reinterpret_cast< void * >(sal::static_int_cast< sal_uIntPtr >(USHRT_MAX)));
2251 	nPos = aSecondKeyLB.InsertEntry(sNoCharSortKey);
2252     aSecondKeyLB.SetEntryData(nPos, reinterpret_cast< void * >(sal::static_int_cast< sal_uIntPtr >(USHRT_MAX)));
2253 	nPos = aThirdKeyLB.InsertEntry(sNoCharSortKey);
2254     aThirdKeyLB.SetEntryData(nPos, reinterpret_cast< void * >(sal::static_int_cast< sal_uIntPtr >(USHRT_MAX)));
2255 
2256 	for( i = 0; i < AUTH_FIELD_END; i++)
2257 	{
2258 		String sTmp(aAuthFieldsLB.GetEntry(i));
2259 		void* pEntryData = aAuthFieldsLB.GetEntryData(i);
2260 		nPos = aFirstKeyLB.InsertEntry(sTmp);
2261 		aFirstKeyLB.SetEntryData(nPos, pEntryData);
2262 		nPos = aSecondKeyLB.InsertEntry(sTmp);
2263 		aSecondKeyLB.SetEntryData(nPos, pEntryData);
2264 		nPos = aThirdKeyLB.InsertEntry(sTmp);
2265 		aThirdKeyLB.SetEntryData(nPos, pEntryData);
2266 	}
2267 	aFirstKeyLB.SelectEntryPos(0);
2268 	aSecondKeyLB.SelectEntryPos(0);
2269 	aThirdKeyLB.SelectEntryPos(0);
2270 }
2271 /* -----------------30.11.99 13:37-------------------
2272 	pVoid is used as signal to change all levels of the example
2273  --------------------------------------------------*/
IMPL_LINK(SwTOXEntryTabPage,ModifyHdl,void *,pVoid)2274 IMPL_LINK(SwTOXEntryTabPage, ModifyHdl, void*, pVoid)
2275 {
2276 	UpdateDescriptor();
2277 	SwMultiTOXTabDialog* pTOXDlg = (SwMultiTOXTabDialog*)GetTabDialog();
2278 
2279 	if(pTOXDlg)
2280 	{
2281         sal_uInt16 nCurLevel = static_cast< sal_uInt16 >(aLevelLB.GetModel()->GetAbsPos(aLevelLB.FirstSelected()) + 1);
2282 		if(aLastTOXType.eType == TOX_CONTENT && pVoid)
2283 			nCurLevel = USHRT_MAX;
2284 		pTOXDlg->CreateOrUpdateExample(
2285 			pTOXDlg->GetCurrentTOXType().eType, TOX_PAGE_ENTRY, nCurLevel);
2286 	}
2287 	return 0;
2288 }
2289 
2290 /*-- 16.06.99 10:47:33---------------------------------------------------
2291 
2292   -----------------------------------------------------------------------*/
~SwTOXEntryTabPage()2293 SwTOXEntryTabPage::~SwTOXEntryTabPage()
2294 {
2295 }
2296 /*-- 16.06.99 10:47:33---------------------------------------------------
2297 
2298   -----------------------------------------------------------------------*/
FillItemSet(SfxItemSet &)2299 sal_Bool	SwTOXEntryTabPage::FillItemSet( SfxItemSet& )
2300 {
2301 	// nothing to do
2302 	return sal_True;
2303 }
2304 /*-- 16.06.99 10:47:34---------------------------------------------------
2305 
2306   -----------------------------------------------------------------------*/
Reset(const SfxItemSet &)2307 void SwTOXEntryTabPage::Reset( const SfxItemSet& )
2308 {
2309 	SwMultiTOXTabDialog* pTOXDlg = (SwMultiTOXTabDialog*)GetTabDialog();
2310 	const CurTOXType aCurType = pTOXDlg->GetCurrentTOXType();
2311     m_pCurrentForm = pTOXDlg->GetForm(aCurType);
2312 	if(TOX_INDEX == aCurType.eType)
2313 	{
2314 		SwTOXDescription& rDesc = pTOXDlg->GetTOXDescription(aCurType);
2315 		String sMainEntryCharStyle = rDesc.GetMainEntryCharStyle();
2316 		if(sMainEntryCharStyle.Len())
2317 		{
2318 			if( LISTBOX_ENTRY_NOTFOUND ==
2319 					aMainEntryStyleLB.GetEntryPos(sMainEntryCharStyle))
2320 				aMainEntryStyleLB.InsertEntry(
2321 						sMainEntryCharStyle);
2322 			aMainEntryStyleLB.SelectEntry(sMainEntryCharStyle);
2323 		}
2324         else
2325 			aMainEntryStyleLB.SelectEntry(sNoCharStyle);
2326         aAlphaDelimCB.Check( 0 != (rDesc.GetIndexOptions() & nsSwTOIOptions::TOI_ALPHA_DELIMITTER) );
2327 	}
2328     aRelToStyleCB.Check(m_pCurrentForm->IsRelTabPos());
2329     aCommaSeparatedCB.Check(m_pCurrentForm->IsCommaSeparated());
2330 }
2331 /*-- 16.06.99 10:47:34---------------------------------------------------
2332 
2333   -----------------------------------------------------------------------*/
lcl_ChgWidth(Window & rWin,long nDiff)2334 void lcl_ChgWidth(Window& rWin, long nDiff)
2335 {
2336  Size aTempSz(rWin.GetSizePixel());
2337 	aTempSz.Width() += nDiff;
2338 	rWin.SetSizePixel(aTempSz);
2339 }
2340 /* ----------------------------------------------------------------------
2341 
2342   -----------------------------------------------------------------------*/
lcl_ChgXPos(Window & rWin,long nDiff)2343 void lcl_ChgXPos(Window& rWin, long nDiff)
2344 {
2345 	Point aTempPos(rWin.GetPosPixel());
2346 	aTempPos.X() += nDiff;
2347 	rWin.SetPosPixel(aTempPos);
2348 }
2349 /* ----------------------------------------------------------------------
2350 
2351   -----------------------------------------------------------------------*/
ActivatePage(const SfxItemSet &)2352 void SwTOXEntryTabPage::ActivatePage( const SfxItemSet& /*rSet*/)
2353 {
2354 	SwMultiTOXTabDialog* pTOXDlg = (SwMultiTOXTabDialog*)GetTabDialog();
2355 	const CurTOXType aCurType = pTOXDlg->GetCurrentTOXType();
2356 
2357     m_pCurrentForm = pTOXDlg->GetForm(aCurType);
2358 	if( !( aLastTOXType == aCurType ))
2359 	{
2360 		sal_Bool bToxIsAuthorities = TOX_AUTHORITIES == aCurType.eType;
2361 		sal_Bool bToxIsIndex =       TOX_INDEX == aCurType.eType;
2362 		sal_Bool bToxIsContent =     TOX_CONTENT == aCurType.eType;
2363 
2364 		aLevelLB.Clear();
2365         for(sal_uInt16 i = 1; i < m_pCurrentForm->GetFormMax(); i++)
2366 		{
2367 			if(bToxIsAuthorities)
2368 				aLevelLB.InsertEntry( SwAuthorityFieldType::GetAuthTypeName(
2369 											(ToxAuthorityType) (i - 1)) );
2370 			else if( bToxIsIndex )
2371 			{
2372 				if(i == 1)
2373 					aLevelLB.InsertEntry( sDelimStr );
2374 				else
2375 					aLevelLB.InsertEntry( String::CreateFromInt32(i - 1) );
2376 			}
2377 			else
2378 				aLevelLB.InsertEntry(String::CreateFromInt32(i));
2379 		}
2380 		if(bToxIsAuthorities)
2381 		{
2382 			//
2383 			SwWrtShell& rSh = pTOXDlg->GetWrtShell();
2384 			const SwAuthorityFieldType* pFType = (const SwAuthorityFieldType*)
2385 									rSh.GetFldType(RES_AUTHORITY, aEmptyStr);
2386 			if(pFType)
2387 			{
2388 				if(pFType->IsSortByDocument())
2389 					aSortDocPosRB.Check();
2390 				else
2391 				{
2392 					aSortContentRB.Check();
2393 					sal_uInt16 nKeyCount = pFType->GetSortKeyCount();
2394 					if(0 < nKeyCount)
2395 					{
2396 						const SwTOXSortKey* pKey = pFType->GetSortKey(0);
2397 						aFirstKeyLB.SelectEntryPos(
2398 							aFirstKeyLB.GetEntryPos((void*)(sal_uInt32)pKey->eField));
2399 						aFirstSortUpRB.Check(pKey->bSortAscending);
2400 						aFirstSortDownRB.Check(!pKey->bSortAscending);
2401 					}
2402 					if(1 < nKeyCount)
2403 					{
2404 						const SwTOXSortKey* pKey = pFType->GetSortKey(1);
2405 						aSecondKeyLB.SelectEntryPos(
2406 							aSecondKeyLB.GetEntryPos((void*)(sal_uInt32)pKey->eField));
2407 						aSecondSortUpRB.Check(pKey->bSortAscending);
2408 						aSecondSortDownRB.Check(!pKey->bSortAscending);
2409 					}
2410 					if(2 < nKeyCount)
2411 					{
2412 						const SwTOXSortKey* pKey = pFType->GetSortKey(2);
2413 						aThirdKeyLB.SelectEntryPos(
2414 							aThirdKeyLB.GetEntryPos((void*)(sal_uInt32)pKey->eField));
2415 						aThirdSortUpRB.Check(pKey->bSortAscending);
2416 						aThirdSortDownRB.Check(!pKey->bSortAscending);
2417 					}
2418 				}
2419 			}
2420 			SortKeyHdl(aSortDocPosRB.IsChecked() ? &aSortDocPosRB : &aSortContentRB);
2421 			aLevelFT.SetText(sAuthTypeStr);
2422 		}
2423 		else
2424 			aLevelFT.SetText(sLevelStr);
2425 
2426 		long nDiff = 0;
2427         if( bToxIsAuthorities ? aLevelFT.GetSizePixel() == aLevelFLSize
2428                               : aLevelFT.GetSizePixel() != aLevelFLSize )
2429 		{
2430             nDiff = aLevelFLSize.Width();
2431 			if( !bToxIsAuthorities )
2432 				nDiff *= -1;
2433 		}
2434 
2435 		if(nDiff)
2436 		{
2437 //          lcl_ChgWidth(aLevelFL, nDiff);
2438 			lcl_ChgWidth(aLevelFT, nDiff);
2439 			lcl_ChgWidth(aLevelLB, nDiff);
2440 			lcl_ChgXPos(aCharStyleFT, nDiff);
2441 			lcl_ChgXPos(aCharStyleLB, nDiff);
2442 			lcl_ChgWidth(aCharStyleLB, -nDiff);
2443 	//			lcl_ChgXPos(aEditStylePB, -nDiff);
2444 			lcl_ChgXPos(aFillCharFT,  nDiff);
2445 			lcl_ChgXPos(aFillCharCB,  nDiff);
2446 			lcl_ChgXPos(aTabPosFT, 	 nDiff);
2447 			lcl_ChgXPos(aTabPosMF, 	 nDiff);
2448 			lcl_ChgXPos(aAutoRightCB, nDiff);
2449 			lcl_ChgXPos(aAuthFieldsLB, 	 nDiff);
2450 			lcl_ChgXPos(aAuthInsertPB, 	 nDiff);
2451 			lcl_ChgXPos(aAuthRemovePB, 	 nDiff);
2452             lcl_ChgXPos(aTokenFT, nDiff);
2453             lcl_ChgXPos(aTokenWIN,   nDiff);
2454 			lcl_ChgWidth(aTokenWIN, -nDiff);
2455 			lcl_ChgXPos(aSortDocPosRB, 	 nDiff);
2456 			lcl_ChgXPos(aSortContentRB, 	 nDiff);
2457             lcl_ChgXPos(aFormatFL,  nDiff);
2458             lcl_ChgWidth(aFormatFL,     -nDiff);
2459             lcl_ChgXPos(aSortingFL, nDiff);
2460             lcl_ChgWidth(aSortingFL,    -nDiff);
2461             lcl_ChgXPos(aEntryFL,   nDiff);
2462             lcl_ChgWidth(aEntryFL,  -nDiff);
2463 
2464 			lcl_ChgXPos(aFirstKeyFT, nDiff);
2465 			lcl_ChgXPos(aFirstKeyLB, nDiff);
2466 			lcl_ChgXPos(aSecondKeyFT, nDiff);
2467 			lcl_ChgXPos(aSecondKeyLB, nDiff);
2468 			lcl_ChgXPos(aThirdKeyFT, nDiff);
2469 			lcl_ChgXPos(aThirdKeyLB, nDiff);
2470             lcl_ChgXPos(aSortKeyFL,     nDiff);
2471 
2472 			lcl_ChgWidth(aFirstKeyLB, -nDiff);
2473 			lcl_ChgWidth(aSecondKeyLB, -nDiff);
2474 			lcl_ChgWidth(aThirdKeyLB, -nDiff);
2475             lcl_ChgWidth(aSortKeyFL, -nDiff);
2476 		}
2477 		Link aLink = aLevelLB.GetSelectHdl();
2478 		aLevelLB.SetSelectHdl(Link());
2479 		aLevelLB.Select( aLevelLB.GetEntry( bToxIsIndex ? 1 : 0 ) );
2480 		aLevelLB.SetSelectHdl(aLink);
2481 
2482 		// sort token buttons
2483 		aEntryNoPB.SetPosPixel(aButtonPositions[0]);
2484 		aEntryPB.SetPosPixel(aButtonPositions[ bToxIsContent ? 1 : 0]);
2485 		aChapterInfoPB.SetPosPixel(aButtonPositions[2]);
2486 		aPageNoPB.SetPosPixel(aButtonPositions[3]);
2487 		sal_uInt16 nBtPos = 1;
2488 		if( bToxIsContent )
2489 			nBtPos = 2;
2490 		else if( bToxIsAuthorities )
2491 			nBtPos = 4;
2492 		aTabPB.SetPosPixel(aButtonPositions[nBtPos]);
2493 		aHyperLinkPB.SetPosPixel(aButtonPositions[4]);
2494 
2495 		//show or hide controls
2496 		aEntryNoPB.Show(		bToxIsContent );
2497 		aHyperLinkPB.Show(		bToxIsContent );
2498 		aRelToStyleCB.Show(	   !bToxIsAuthorities );
2499         aChapterInfoPB.Show(    !bToxIsContent && !bToxIsAuthorities);
2500 		aEntryPB.Show(		   !bToxIsAuthorities );
2501 		aPageNoPB.Show(		   !bToxIsAuthorities );
2502 		aAuthFieldsLB.Show(		bToxIsAuthorities );
2503 		aAuthInsertPB.Show(		bToxIsAuthorities );
2504 		aAuthRemovePB.Show(		bToxIsAuthorities );
2505         aFormatFL.Show(        !bToxIsAuthorities );
2506 		aSortDocPosRB.Show(		bToxIsAuthorities );
2507 		aSortContentRB.Show(	bToxIsAuthorities );
2508         aSortingFL.Show(        bToxIsAuthorities );
2509 		aFirstKeyFT.Show(		bToxIsAuthorities );
2510 		aFirstKeyLB.Show(		bToxIsAuthorities );
2511 		aSecondKeyFT.Show(		bToxIsAuthorities );
2512 		aSecondKeyLB.Show(		bToxIsAuthorities );
2513 		aThirdKeyFT.Show(		bToxIsAuthorities );
2514 		aThirdKeyLB.Show(		bToxIsAuthorities );
2515         aSortKeyFL.Show(        bToxIsAuthorities );
2516 		aFirstSortUpRB.Show(	bToxIsAuthorities );
2517 		aFirstSortDownRB.Show(	bToxIsAuthorities );
2518 		aSecondSortUpRB.Show(	bToxIsAuthorities );
2519 		aSecondSortDownRB.Show(	bToxIsAuthorities );
2520 		aThirdSortUpRB.Show(	bToxIsAuthorities );
2521 		aThirdSortDownRB.Show(	bToxIsAuthorities );
2522 
2523 		aRelToStyleCB.SetPosPixel( bToxIsIndex ? aRelToStyleIdxPos
2524 											   : aRelToStylePos );
2525 
2526 //		aRecalcTabCB.Show(	aCurType.eType == TOX_CONTENT);
2527 
2528 		aMainEntryStyleFT.Show(	bToxIsIndex );
2529 		aMainEntryStyleLB.Show(	bToxIsIndex );
2530 		aAlphaDelimCB.Show(		bToxIsIndex );
2531 		aCommaSeparatedCB.Show(	bToxIsIndex );
2532 	}
2533 	aLastTOXType = aCurType;
2534 
2535 	//invalidate PatternWindow
2536 	aTokenWIN.SetInvalid();
2537 	LevelHdl(&aLevelLB);
2538 }
2539 /* -----------------30.11.99 15:04-------------------
2540 
2541  --------------------------------------------------*/
UpdateDescriptor()2542 void SwTOXEntryTabPage::UpdateDescriptor()
2543 {
2544 	WriteBackLevel();
2545 	SwMultiTOXTabDialog* pTOXDlg = (SwMultiTOXTabDialog*)GetTabDialog();
2546 	SwTOXDescription& rDesc = pTOXDlg->GetTOXDescription(aLastTOXType);
2547 	if(TOX_INDEX == aLastTOXType.eType)
2548 	{
2549 		String sTemp(aMainEntryStyleLB.GetSelectEntry());
2550 		rDesc.SetMainEntryCharStyle(sNoCharStyle == sTemp ? aEmptyStr : sTemp);
2551         sal_uInt16 nIdxOptions = rDesc.GetIndexOptions() & ~nsSwTOIOptions::TOI_ALPHA_DELIMITTER;
2552 		if(aAlphaDelimCB.IsChecked())
2553             nIdxOptions |= nsSwTOIOptions::TOI_ALPHA_DELIMITTER;
2554 		rDesc.SetIndexOptions(nIdxOptions);
2555 	}
2556 	else if(TOX_AUTHORITIES == aLastTOXType.eType)
2557 	{
2558 		rDesc.SetSortByDocument(aSortDocPosRB.IsChecked());
2559 		SwTOXSortKey aKey1, aKey2, aKey3;
2560 		aKey1.eField = (ToxAuthorityField)(sal_uIntPtr)aFirstKeyLB.GetEntryData(
2561 									aFirstKeyLB.GetSelectEntryPos());
2562 		aKey1.bSortAscending = aFirstSortUpRB.IsChecked();
2563 		aKey2.eField = (ToxAuthorityField)(sal_uIntPtr)aSecondKeyLB.GetEntryData(
2564 									aSecondKeyLB.GetSelectEntryPos());
2565 		aKey2.bSortAscending = aSecondSortUpRB.IsChecked();
2566 		aKey3.eField = (ToxAuthorityField)(sal_uIntPtr)aThirdKeyLB.GetEntryData(
2567 								aThirdKeyLB.GetSelectEntryPos());
2568 		aKey3.bSortAscending = aThirdSortUpRB.IsChecked();
2569 
2570 
2571 		rDesc.SetSortKeys(aKey1, aKey2, aKey3);
2572 	}
2573 	SwForm*	pCurrentForm = pTOXDlg->GetForm(aLastTOXType);
2574 	if(aRelToStyleCB.IsVisible())
2575 	{
2576 		pCurrentForm->SetRelTabPos(aRelToStyleCB.IsChecked());
2577 	}
2578 	if(aCommaSeparatedCB.IsVisible())
2579 		pCurrentForm->SetCommaSeparated(aCommaSeparatedCB.IsChecked());
2580 }
2581 /*-- 16.06.99 10:47:34---------------------------------------------------
2582 
2583   -----------------------------------------------------------------------*/
DeactivatePage(SfxItemSet *)2584 int SwTOXEntryTabPage::DeactivatePage( SfxItemSet* /*pSet*/)
2585 {
2586 	UpdateDescriptor();
2587 	return LEAVE_PAGE;
2588 }
2589 /*-- 16.06.99 10:47:34---------------------------------------------------
2590 
2591   -----------------------------------------------------------------------*/
Create(Window * pParent,const SfxItemSet & rAttrSet)2592 SfxTabPage*	SwTOXEntryTabPage::Create( Window* pParent, 	const SfxItemSet& rAttrSet)
2593 {
2594 	return new SwTOXEntryTabPage(pParent, rAttrSet);
2595 }
2596 /*-- 16.06.99 10:47:35---------------------------------------------------
2597 
2598   -----------------------------------------------------------------------*/
IMPL_LINK(SwTOXEntryTabPage,EditStyleHdl,PushButton *,pBtn)2599 IMPL_LINK(SwTOXEntryTabPage, EditStyleHdl, PushButton*, pBtn)
2600 {
2601 	if( LISTBOX_ENTRY_NOTFOUND != aCharStyleLB.GetSelectEntryPos())
2602 	{
2603 		SfxStringItem aStyle(SID_STYLE_EDIT, aCharStyleLB.GetSelectEntry());
2604 		SfxUInt16Item aFamily(SID_STYLE_FAMILY, SFX_STYLE_FAMILY_CHAR);
2605 		// TODO: WrtShell?
2606 //		SwPtrItem aShell(FN_PARAM_WRTSHELL, pWrtShell);
2607 		Window* pDefDlgParent = Application::GetDefDialogParent();
2608 		Application::SetDefDialogParent( pBtn );
2609 		((SwMultiTOXTabDialog*)GetTabDialog())->GetWrtShell().
2610 		GetView().GetViewFrame()->GetDispatcher()->Execute(
2611 		SID_STYLE_EDIT, SFX_CALLMODE_SYNCHRON|SFX_CALLMODE_MODAL,
2612 			&aStyle, &aFamily/*, &aShell*/, 0L);
2613 		Application::SetDefDialogParent( pDefDlgParent );
2614 	}
2615 	return 0;
2616 }
2617 /* -----------------04.10.99 11:34-------------------
2618 
2619  --------------------------------------------------*/
IMPL_LINK(SwTOXEntryTabPage,RemoveInsertAuthHdl,PushButton *,pButton)2620 IMPL_LINK(SwTOXEntryTabPage, RemoveInsertAuthHdl, PushButton*, pButton)
2621 {
2622 	sal_Bool bInsert = pButton == &aAuthInsertPB;
2623 	if(bInsert)
2624 	{
2625 		sal_uInt16 nSelPos = aAuthFieldsLB.GetSelectEntryPos();
2626 		String sToInsert(aAuthFieldsLB.GetSelectEntry());
2627 		SwFormToken aInsert(TOKEN_AUTHORITY);
2628 		aInsert.nAuthorityField = (sal_uInt16)(sal_uIntPtr)aAuthFieldsLB.GetEntryData(nSelPos);
2629 		aTokenWIN.InsertAtSelection(String::CreateFromAscii(
2630 											SwForm::aFormAuth), aInsert);
2631 		aAuthFieldsLB.RemoveEntry(sToInsert);
2632 		aAuthFieldsLB.SelectEntryPos( nSelPos ? nSelPos - 1 : 0);
2633 	}
2634 	else
2635 	{
2636 		Control* pCtrl = aTokenWIN.GetActiveControl();
2637 		DBG_ASSERT(WINDOW_EDIT != pCtrl->GetType(), "Remove should be disabled");
2638 		if( WINDOW_EDIT != pCtrl->GetType() )
2639 		{
2640 			//fill it into the ListBox
2641 			const SwFormToken& rToken = ((SwTOXButton*)pCtrl)->GetFormToken();
2642 			PreTokenButtonRemoved(rToken);
2643 			aTokenWIN.RemoveControl((SwTOXButton*)pCtrl);
2644 		}
2645 	}
2646 	ModifyHdl(0);
2647 	return 0;
2648 }
2649 /* -----------------------------17.01.00 13:44--------------------------------
2650 
2651  ---------------------------------------------------------------------------*/
PreTokenButtonRemoved(const SwFormToken & rToken)2652 void SwTOXEntryTabPage::PreTokenButtonRemoved(const SwFormToken& rToken)
2653 {
2654 	//fill it into the ListBox
2655 	sal_uInt32 nData = rToken.nAuthorityField;
2656 	String sTemp(SW_RES(STR_AUTH_FIELD_START + nData));
2657 	sal_uInt16 nPos = aAuthFieldsLB.InsertEntry(sTemp);
2658 	aAuthFieldsLB.SetEntryData(nPos, (void*)(nData));
2659 }
SetFocus2theAllBtn()2660 void SwTOXEntryTabPage::SetFocus2theAllBtn()
2661 {
2662 	aAllLevelsPB.GrabFocus();
2663 }
Notify(NotifyEvent & rNEvt)2664 long SwTOXEntryTabPage::Notify( NotifyEvent& rNEvt )
2665 {
2666 	if ( rNEvt.GetType() == EVENT_KEYINPUT )
2667 	{
2668 		const KeyEvent& rKEvt = *rNEvt.GetKeyEvent();
2669 		KeyCode aCode = rKEvt.GetKeyCode();
2670 		if ( (aCode.GetCode() == KEY_F4) && aCode.IsShift() && !aCode.IsMod1() && !aCode.IsMod2() )
2671 		{
2672 			if ( aTokenWIN.GetActiveControl() )
2673 			{
2674 				aTokenWIN.GetActiveControl()->GrabFocus();
2675 			}
2676 		}
2677 
2678 	}
2679 
2680 	return SfxTabPage::Notify( rNEvt );
2681 }
2682 /*-- 16.06.99 10:47:35---------------------------------------------------
2683 
2684 This function inizializes the default value in the Token
2685 put here the UI dependent initializations
2686   -----------------------------------------------------------------------*/
IMPL_LINK(SwTOXEntryTabPage,InsertTokenHdl,PushButton *,pBtn)2687 IMPL_LINK(SwTOXEntryTabPage, InsertTokenHdl, PushButton*, pBtn)
2688 {
2689 	String sText;
2690     FormTokenType eTokenType = TOKEN_ENTRY_NO;
2691     String sCharStyle;
2692     sal_uInt16  nChapterFormat = CF_NUMBER; // i89791
2693 	if(pBtn == &aEntryNoPB)
2694 	{
2695 		sText.AssignAscii(SwForm::aFormEntryNum);
2696 		eTokenType = TOKEN_ENTRY_NO;
2697 	}
2698 	else if(pBtn == &aEntryPB)
2699 	{
2700         if( TOX_CONTENT == m_pCurrentForm->GetTOXType() )
2701 		{
2702 			sText.AssignAscii( SwForm::aFormEntryTxt );
2703 			eTokenType = TOKEN_ENTRY_TEXT;
2704 		}
2705 		else
2706 		{
2707 			sText.AssignAscii( SwForm::aFormEntry);
2708 			eTokenType = TOKEN_ENTRY;
2709 		}
2710 	}
2711 	else if(pBtn == &aChapterInfoPB)
2712 	{
2713 		sText.AssignAscii( SwForm::aFormChapterMark);
2714 		eTokenType = TOKEN_CHAPTER_INFO;
2715         nChapterFormat = CF_NUM_NOPREPST_TITLE; // i89791
2716 	}
2717 	else if(pBtn == &aPageNoPB)
2718 	{
2719 		sText.AssignAscii(SwForm::aFormPageNums);
2720 		eTokenType = TOKEN_PAGE_NUMS;
2721 	}
2722 	else if(pBtn == &aHyperLinkPB)
2723 	{
2724 		sText.AssignAscii(SwForm::aFormLinkStt);
2725 		eTokenType = TOKEN_LINK_START;
2726         sCharStyle = String(SW_RES(STR_POOLCHR_INET_NORMAL));
2727 	}
2728 	else if(pBtn == &aTabPB)
2729 	{
2730 		sText.AssignAscii(SwForm::aFormTab);
2731 		eTokenType = TOKEN_TAB_STOP;
2732 	}
2733 	SwFormToken aInsert(eTokenType);
2734     aInsert.sCharStyleName = sCharStyle;
2735 	aInsert.nTabStopPosition = 0;
2736     aInsert.nChapterFormat = nChapterFormat; // i89791
2737 	aTokenWIN.InsertAtSelection(sText, aInsert);
2738 	ModifyHdl(0);
2739 	return 0;
2740 }
2741 /* -----------------------------14.01.00 11:53--------------------------------
2742 
2743  ---------------------------------------------------------------------------*/
IMPL_LINK(SwTOXEntryTabPage,AllLevelsHdl,PushButton *,EMPTYARG)2744 IMPL_LINK(SwTOXEntryTabPage, AllLevelsHdl, PushButton*, EMPTYARG)
2745 {
2746 	//get current level
2747 	//write it into all levels
2748 	if(aTokenWIN.IsValid())
2749 	{
2750 		String sNewToken = aTokenWIN.GetPattern();
2751         for(sal_uInt16 i = 1; i < m_pCurrentForm->GetFormMax(); i++)
2752             m_pCurrentForm->SetPattern(i, sNewToken);
2753 		//
2754 		ModifyHdl(this);
2755 	}
2756 	return 0;
2757 }
2758 
2759 /* -----------------02.12.99 12:40-------------------
2760 
2761  --------------------------------------------------*/
WriteBackLevel()2762 void SwTOXEntryTabPage::WriteBackLevel()
2763 {
2764 	if(aTokenWIN.IsValid())
2765 	{
2766 		String sNewToken = aTokenWIN.GetPattern();
2767 		sal_uInt16 nLastLevel = aTokenWIN.GetLastLevel();
2768 		if(nLastLevel != USHRT_MAX)
2769             m_pCurrentForm->SetPattern(nLastLevel + 1, sNewToken );
2770 	}
2771 }
2772 /*-- 16.06.99 10:47:35---------------------------------------------------
2773 
2774   -----------------------------------------------------------------------*/
IMPL_LINK(SwTOXEntryTabPage,LevelHdl,SvTreeListBox *,pBox)2775 IMPL_LINK(SwTOXEntryTabPage, LevelHdl, SvTreeListBox*, pBox)
2776 {
2777 	if(bInLevelHdl)
2778 		return 0;
2779 	bInLevelHdl = sal_True;
2780 	WriteBackLevel();
2781 
2782     sal_uInt16 nLevel = static_cast< sal_uInt16 >(pBox->GetModel()->GetAbsPos(pBox->FirstSelected()));
2783     aTokenWIN.SetForm(*m_pCurrentForm, nLevel);
2784     if(TOX_AUTHORITIES == m_pCurrentForm->GetTOXType())
2785 	{
2786 		//fill the types in
2787 		aAuthFieldsLB.Clear();
2788 		for( sal_uInt32 i = 0; i < AUTH_FIELD_END; i++)
2789 		{
2790 			String sTmp(SW_RES(STR_AUTH_FIELD_START + i));
2791 			sal_uInt16 nPos = aAuthFieldsLB.InsertEntry(sTmp);
2792 			aAuthFieldsLB.SetEntryData(nPos, (void*)(i));
2793 		}
2794 
2795         // #i21237#
2796         SwFormTokens aPattern = m_pCurrentForm->GetPattern(nLevel + 1);
2797         SwFormTokens::iterator aIt = aPattern.begin();;
2798 
2799 		while(aIt != aPattern.end())
2800 		{
2801 			SwFormToken aToken = *aIt; // #i21237#
2802 			if(TOKEN_AUTHORITY == aToken.eTokenType)
2803 			{
2804 				sal_uInt32 nSearch = aToken.nAuthorityField;
2805 				sal_uInt16	nLstBoxPos = aAuthFieldsLB.GetEntryPos( (void*) nSearch );
2806 				DBG_ASSERT(LISTBOX_ENTRY_NOTFOUND != nLstBoxPos, "Entry not found?");
2807 				aAuthFieldsLB.RemoveEntry(nLstBoxPos);
2808 			}
2809 
2810             aIt++; // #i21237#
2811 		}
2812 		aAuthFieldsLB.SelectEntryPos(0);
2813 	}
2814     bInLevelHdl = sal_False;
2815 	pBox->GrabFocus();
2816 	return 0;
2817 }
2818 /* -----------------20.10.99 13:16-------------------
2819 
2820  --------------------------------------------------*/
IMPL_LINK(SwTOXEntryTabPage,SortKeyHdl,RadioButton *,pButton)2821 IMPL_LINK(SwTOXEntryTabPage, SortKeyHdl, RadioButton*, pButton)
2822 {
2823 	sal_Bool bEnable = &aSortContentRB == pButton;
2824 	aFirstKeyFT.Enable(bEnable);
2825 	aFirstKeyLB.Enable(bEnable);
2826 	aSecondKeyFT.Enable(bEnable);
2827 	aSecondKeyLB.Enable(bEnable);
2828 	aThirdKeyFT.Enable(bEnable);
2829 	aThirdKeyLB.Enable(bEnable);
2830     aSortKeyFL.Enable(bEnable);
2831 	aFirstSortUpRB.Enable(bEnable);
2832 	aFirstSortDownRB.Enable(bEnable);
2833 	aSecondSortUpRB.Enable(bEnable);
2834 	aSecondSortDownRB.Enable(bEnable);
2835 	aThirdSortUpRB.Enable(bEnable);
2836 	aThirdSortDownRB.Enable(bEnable);
2837 	return 0;
2838 }
2839 /* -----------------01.07.99 12:21-------------------
2840 
2841  --------------------------------------------------*/
IMPL_LINK(SwTOXEntryTabPage,TokenSelectedHdl,SwFormToken *,pToken)2842 IMPL_LINK(SwTOXEntryTabPage, TokenSelectedHdl, SwFormToken*, pToken)
2843 {
2844 	if(pToken->sCharStyleName.Len())
2845 		aCharStyleLB.SelectEntry(pToken->sCharStyleName);
2846 	else
2847 		aCharStyleLB.SelectEntry(sNoCharStyle);
2848 	//StyleSelectHdl(&aCharStyleLB);
2849 
2850 	String sEntry = aCharStyleLB.GetSelectEntry();
2851     aEditStylePB.Enable(sEntry != sNoCharStyle);
2852 
2853 	if(pToken->eTokenType == TOKEN_CHAPTER_INFO)
2854 	{
2855 //---> i89791
2856         switch(pToken->nChapterFormat)
2857         {
2858         default:
2859             aChapterEntryLB.SetNoSelection();//to alert the user
2860             break;
2861         case CF_NUM_NOPREPST_TITLE:
2862             aChapterEntryLB.SelectEntryPos(0);
2863             break;
2864         case CF_TITLE:
2865             aChapterEntryLB.SelectEntryPos(1);
2866            break;
2867         case CF_NUMBER_NOPREPST:
2868             aChapterEntryLB.SelectEntryPos(2);
2869             break;
2870         }
2871 //<---
2872 //i53420
2873 //move into position the fixed text
2874 //         aEntryOutlineLevelFT.SetPosPixel( aEntryOutlineLevelFTPosition );
2875 // // then the entry
2876 //         Point aPoint;
2877 //         aPoint.Y() = aEntryOutlineLevelFTPosition.Y();
2878 //         aPoint.X() = aEntryOutlineLevelFTPosition.X() + nBiasToEntryPoint;
2879 //         aEntryOutlineLevelNF.SetPosPixel( aPoint );
2880 
2881         aEntryOutlineLevelNF.SetValue(pToken->nOutlineLevel);
2882 	}
2883 
2884 //i53420
2885 	if(pToken->eTokenType == TOKEN_ENTRY_NO)
2886     {
2887 //move into position the fixed text
2888 //        aEntryOutlineLevelFT.SetPosPixel( aChapterEntryFTPosition );
2889 // // then the entry
2890 //         Point aPoint;
2891 //         aPoint.Y() = aChapterEntryFTPosition.Y();
2892 //         aPoint.X() = aChapterEntryFTPosition.X() + nBiasToEntryPoint;
2893 //         aEntryOutlineLevelNF.SetPosPixel( aPoint );
2894 
2895         aEntryOutlineLevelNF.SetValue(pToken->nOutlineLevel);
2896         sal_uInt16 nFormat = 0;
2897         if( pToken->nChapterFormat == CF_NUM_NOPREPST_TITLE )
2898             nFormat = 1;
2899         aNumberFormatLB.SelectEntryPos(nFormat);
2900     }
2901 
2902     sal_Bool bTabStop = TOKEN_TAB_STOP == pToken->eTokenType;
2903     aFillCharFT.Show(bTabStop);
2904 	aFillCharCB.Show(bTabStop);
2905 	aTabPosFT.Show(bTabStop);
2906 	aTabPosMF.Show(bTabStop);
2907 	aAutoRightCB.Show(bTabStop);
2908 	aAutoRightCB.Enable(bTabStop);
2909 	if(bTabStop)
2910 	{
2911 		aTabPosMF.SetValue(aTabPosMF.Normalize(pToken->nTabStopPosition), FUNIT_TWIP);
2912 		aAutoRightCB.Check(SVX_TAB_ADJUST_END == pToken->eTabAlign);
2913 		aFillCharCB.SetText(pToken->cTabFillChar);
2914 		aTabPosFT.Enable(!aAutoRightCB.IsChecked());
2915 		aTabPosMF.Enable(!aAutoRightCB.IsChecked());
2916 	}
2917 	else
2918 	{
2919 		aTabPosMF.Enable(sal_False);
2920 	}
2921 
2922     sal_Bool bIsChapterInfo = pToken->eTokenType == TOKEN_CHAPTER_INFO;
2923     sal_Bool bIsEntryNumber = pToken->eTokenType == TOKEN_ENTRY_NO;
2924 	aChapterEntryFT.Show( bIsChapterInfo );
2925 	aChapterEntryLB.Show( bIsChapterInfo );
2926     aEntryOutlineLevelFT.Show( bIsChapterInfo || bIsEntryNumber );
2927     aEntryOutlineLevelNF.Show( bIsChapterInfo || bIsEntryNumber );
2928     aNumberFormatFT.Show( bIsEntryNumber );
2929     aNumberFormatLB.Show( bIsEntryNumber );
2930 
2931 
2932 	//now enable the visible buttons
2933 	//- inserting the same type of control is not allowed
2934 	//- some types of controls can only appear once (EntryText EntryNumber)
2935 
2936 	if(aEntryNoPB.IsVisible())
2937 	{
2938 		aEntryNoPB.Enable(TOKEN_ENTRY_NO != pToken->eTokenType );
2939 	}
2940 	if(aEntryPB.IsVisible())
2941 	{
2942 		aEntryPB.Enable(TOKEN_ENTRY_TEXT != pToken->eTokenType &&
2943 								!aTokenWIN.Contains(TOKEN_ENTRY_TEXT)
2944 								&& !aTokenWIN.Contains(TOKEN_ENTRY));
2945 	}
2946 
2947 	if(aChapterInfoPB.IsVisible())
2948 	{
2949 		aChapterInfoPB.Enable(TOKEN_CHAPTER_INFO != pToken->eTokenType);
2950 	}
2951 	if(aPageNoPB.IsVisible())
2952 	{
2953 		aPageNoPB.Enable(TOKEN_PAGE_NUMS != pToken->eTokenType &&
2954 								!aTokenWIN.Contains(TOKEN_PAGE_NUMS));
2955 	}
2956 	if(aTabPB.IsVisible())
2957 	{
2958 		aTabPB.Enable(!bTabStop);
2959 	}
2960 	if(aHyperLinkPB.IsVisible())
2961 	{
2962 		aHyperLinkPB.Enable(TOKEN_LINK_START != pToken->eTokenType &&
2963 							TOKEN_LINK_END != pToken->eTokenType);
2964 	}
2965 	//table of authorities
2966 	if(aAuthInsertPB.IsVisible())
2967 	{
2968 		sal_Bool bText = TOKEN_TEXT == pToken->eTokenType;
2969 		aAuthInsertPB.Enable(bText && aAuthFieldsLB.GetSelectEntry().Len());
2970 		aAuthRemovePB.Enable(!bText);
2971 	}
2972 
2973 	return 0;
2974 }
2975 /* -----------------01.07.99 12:36-------------------
2976 
2977  --------------------------------------------------*/
IMPL_LINK(SwTOXEntryTabPage,StyleSelectHdl,ListBox *,pBox)2978 IMPL_LINK(SwTOXEntryTabPage, StyleSelectHdl, ListBox*, pBox)
2979 {
2980 	String sEntry = pBox->GetSelectEntry();
2981 	sal_uInt16 nId = (sal_uInt16)(long)pBox->GetEntryData(pBox->GetSelectEntryPos());
2982 	aEditStylePB.Enable(sEntry != sNoCharStyle);
2983 	if(sEntry == sNoCharStyle)
2984 		sEntry.Erase();
2985 	Control* pCtrl = aTokenWIN.GetActiveControl();
2986 	DBG_ASSERT(pCtrl, "no active control?");
2987 	if(pCtrl)
2988 	{
2989 		if(WINDOW_EDIT == pCtrl->GetType())
2990 			((SwTOXEdit*)pCtrl)->SetCharStyleName(sEntry, nId);
2991 		else
2992 			((SwTOXButton*)pCtrl)->SetCharStyleName(sEntry, nId);
2993 
2994 	}
2995 	ModifyHdl(0);
2996 	return 0;
2997 }
2998 /* -----------------------------11.01.00 12:54--------------------------------
2999 
3000  ---------------------------------------------------------------------------*/
IMPL_LINK(SwTOXEntryTabPage,ChapterInfoHdl,ListBox *,pBox)3001 IMPL_LINK(SwTOXEntryTabPage, ChapterInfoHdl, ListBox*, pBox)
3002 {
3003 	sal_uInt16 nPos = pBox->GetSelectEntryPos();
3004 	if(LISTBOX_ENTRY_NOTFOUND != nPos)
3005 	{
3006 		Control* pCtrl = aTokenWIN.GetActiveControl();
3007 		DBG_ASSERT(pCtrl, "no active control?");
3008 		if(pCtrl && WINDOW_EDIT != pCtrl->GetType())
3009 			((SwTOXButton*)pCtrl)->SetChapterInfo(nPos);
3010 
3011 		ModifyHdl(0);
3012 	}
3013 	return 0;
3014 }
3015 
IMPL_LINK(SwTOXEntryTabPage,ChapterInfoOutlineHdl,NumericField *,pField)3016 IMPL_LINK(SwTOXEntryTabPage, ChapterInfoOutlineHdl, NumericField*, pField)
3017 {
3018     const sal_uInt16 nLevel = static_cast<sal_uInt8>(pField->GetValue());
3019 
3020     Control* pCtrl = aTokenWIN.GetActiveControl();
3021     DBG_ASSERT(pCtrl, "no active control?");
3022 	if(pCtrl && WINDOW_EDIT != pCtrl->GetType())
3023         ((SwTOXButton*)pCtrl)->SetOutlineLevel(nLevel);
3024 
3025     ModifyHdl(0);
3026 	return 0;
3027 }
3028 
IMPL_LINK(SwTOXEntryTabPage,NumberFormatHdl,ListBox *,pBox)3029 IMPL_LINK(SwTOXEntryTabPage, NumberFormatHdl, ListBox*, pBox)
3030 {
3031 	const sal_uInt16 nPos = pBox->GetSelectEntryPos();
3032 
3033 	if(LISTBOX_ENTRY_NOTFOUND != nPos)
3034 	{
3035 		Control* pCtrl = aTokenWIN.GetActiveControl();
3036 		DBG_ASSERT(pCtrl, "no active control?");
3037 		if(pCtrl && WINDOW_EDIT != pCtrl->GetType())
3038         {
3039            ((SwTOXButton*)pCtrl)->SetEntryNumberFormat(nPos);//i89791
3040         }
3041 		ModifyHdl(0);
3042 	}
3043 	return 0;
3044 }
3045 
3046 /* -----------------19.08.99 15:37-------------------
3047 
3048  --------------------------------------------------*/
IMPL_LINK(SwTOXEntryTabPage,TabPosHdl,MetricField *,pField)3049 IMPL_LINK(SwTOXEntryTabPage, TabPosHdl, MetricField*, pField)
3050 {
3051 	Control* pCtrl = aTokenWIN.GetActiveControl();
3052 	DBG_ASSERT(pCtrl && WINDOW_EDIT != pCtrl->GetType() &&
3053 		TOKEN_TAB_STOP == ((SwTOXButton*)pCtrl)->GetFormToken().eTokenType,
3054 				"no active style::TabStop control?");
3055 	if( pCtrl && WINDOW_EDIT != pCtrl->GetType() )
3056 	{
3057         ((SwTOXButton*)pCtrl)->SetTabPosition( static_cast< SwTwips >(
3058                 pField->Denormalize( pField->GetValue( FUNIT_TWIP ))));
3059 	}
3060 	ModifyHdl(0);
3061 	return 0;
3062 }
3063 /* -----------------09.09.99 15:37-------------------
3064 
3065  --------------------------------------------------*/
IMPL_LINK(SwTOXEntryTabPage,FillCharHdl,ComboBox *,pBox)3066 IMPL_LINK(SwTOXEntryTabPage, FillCharHdl, ComboBox*, pBox)
3067 {
3068 	Control* pCtrl = aTokenWIN.GetActiveControl();
3069 	DBG_ASSERT(pCtrl && WINDOW_EDIT != pCtrl->GetType() &&
3070 		TOKEN_TAB_STOP == ((SwTOXButton*)pCtrl)->GetFormToken().eTokenType,
3071 				"no active style::TabStop control?");
3072 	if(pCtrl && WINDOW_EDIT != pCtrl->GetType())
3073 	{
3074 		sal_Unicode cSet;
3075 		if( pBox->GetText().Len() )
3076 			cSet = pBox->GetText().GetChar(0);
3077 		else
3078 			cSet = ' ';
3079 		((SwTOXButton*)pCtrl)->SetFillChar( cSet );
3080 	}
3081 	ModifyHdl(0);
3082 	return 0;
3083 }
3084 
3085 /*-- 16.06.99 10:47:36---------------------------------------------------
3086 
3087   -----------------------------------------------------------------------*/
IMPL_LINK(SwTOXEntryTabPage,AutoRightHdl,CheckBox *,pBox)3088 IMPL_LINK(SwTOXEntryTabPage, AutoRightHdl, CheckBox*, pBox)
3089 {
3090 	//the most right style::TabStop is usually right aligned
3091 	Control* pCurCtrl = aTokenWIN.GetActiveControl();
3092 	DBG_ASSERT(WINDOW_EDIT != pCurCtrl->GetType() &&
3093 			((SwTOXButton*)pCurCtrl)->GetFormToken().eTokenType == TOKEN_TAB_STOP,
3094 			"no style::TabStop selected!");
3095 
3096 	const SwFormToken& rToken = ((SwTOXButton*)pCurCtrl)->GetFormToken();
3097 	sal_Bool bChecked = pBox->IsChecked();
3098 	if(rToken.eTokenType == TOKEN_TAB_STOP)
3099 		((SwTOXButton*)pCurCtrl)->SetTabAlign(
3100 			bChecked ? SVX_TAB_ADJUST_END : SVX_TAB_ADJUST_LEFT);
3101 	aTabPosFT.Enable(!bChecked);
3102 	aTabPosMF.Enable(!bChecked);
3103 	ModifyHdl(0);
3104 	return 0;
3105 }
3106 /* -----------------16.06.99 11:00-------------------
3107 
3108  --------------------------------------------------*/
SetWrtShell(SwWrtShell & rSh)3109 void SwTOXEntryTabPage::SetWrtShell(SwWrtShell& rSh)
3110 {
3111 	SwDocShell* pDocSh = rSh.GetView().GetDocShell();
3112     ::FillCharStyleListBox(aCharStyleLB, pDocSh, sal_True, sal_True);
3113     const String sDefault(SW_RES(STR_POOLCOLL_STANDARD));
3114     for(sal_uInt16 i = 0; i < aCharStyleLB.GetEntryCount(); i++)
3115 	{
3116         String sEntry = aCharStyleLB.GetEntry(i);
3117         if(sDefault != sEntry)
3118         {
3119             aMainEntryStyleLB.InsertEntry( sEntry );
3120             aMainEntryStyleLB.SetEntryData(i, aCharStyleLB.GetEntryData(i));
3121         }
3122 	}
3123 	aMainEntryStyleLB.SelectEntry( SwStyleNameMapper::GetUIName(
3124 								RES_POOLCHR_IDX_MAIN_ENTRY, aEmptyStr ));
3125 }
3126 /* -----------------------------23.12.99 14:23--------------------------------
3127 
3128  ---------------------------------------------------------------------------*/
GetLevelHelp(sal_uInt16 nLevel) const3129 String 	SwTOXEntryTabPage::GetLevelHelp(sal_uInt16 nLevel) const
3130 {
3131 	String sRet;
3132 	SwMultiTOXTabDialog* pTOXDlg = (SwMultiTOXTabDialog*)GetTabDialog();
3133 	const CurTOXType aCurType = pTOXDlg->GetCurrentTOXType();
3134 	if( TOX_INDEX == aCurType.eType )
3135         SwStyleNameMapper::FillUIName( static_cast< sal_uInt16 >(1 == nLevel ? RES_POOLCOLL_TOX_IDXBREAK
3136                                   : RES_POOLCOLL_TOX_IDX1 + nLevel-2), sRet );
3137 
3138 	else if( TOX_AUTHORITIES == aCurType.eType )
3139 	{
3140 		//wildcard -> show entry text
3141 		sRet = '*';
3142 	}
3143 	return sRet;
3144 }
3145 /* -----------------16.06.99 15:18-------------------
3146 
3147  --------------------------------------------------*/
3148 
SwTokenWindow(SwTOXEntryTabPage * pParent,const ResId & rResId)3149 SwTokenWindow::SwTokenWindow(SwTOXEntryTabPage* pParent, const ResId& rResId) :
3150 		Window( pParent, rResId ),
3151 		aLeftScrollWin(this, ResId(WIN_LEFT_SCROLL, *rResId.GetResMgr()	 )),
3152 		aCtrlParentWin(this, ResId(WIN_CTRL_PARENT, *rResId.GetResMgr()   )),
3153 		aRightScrollWin(this, ResId(WIN_RIGHT_SCROLL, *rResId.GetResMgr() )),
3154 		pForm(0),
3155 		nLevel(0),
3156 		bValid(sal_False),
3157         sCharStyle(ResId(STR_CHARSTYLE, *rResId.GetResMgr())),
3158 		pActiveCtrl(0),
3159         m_pParent(pParent)
3160 {
3161     SetStyle(GetStyle()|WB_TABSTOP|WB_DIALOGCONTROL);
3162     SetHelpId(HID_TOKEN_WINDOW);
3163 	for(sal_uInt16 i = 0; i < TOKEN_END; i++)
3164 	{
3165 		sal_uInt16 nTextId = STR_BUTTON_TEXT_START + i;
3166 		if( STR_TOKEN_ENTRY_TEXT == nTextId )
3167 			nTextId = STR_TOKEN_ENTRY;
3168 		aButtonTexts[i] = String(ResId(nTextId, *rResId.GetResMgr()));
3169 
3170 		sal_uInt16 nHelpId = STR_BUTTON_HELP_TEXT_START + i;
3171 		if(STR_TOKEN_HELP_ENTRY_TEXT == nHelpId)
3172 			nHelpId = STR_TOKEN_HELP_ENTRY;
3173 		aButtonHelpTexts[i] = String(ResId(nHelpId, *rResId.GetResMgr()));
3174 	}
3175 	accessibleName = String(SW_RES(STR_STRUCTURE));
3176 	sAdditionalAccnameString1 = String(SW_RES(STR_ADDITIONAL_ACCNAME_STRING1));
3177 	sAdditionalAccnameString2 = String(SW_RES(STR_ADDITIONAL_ACCNAME_STRING2));
3178 	sAdditionalAccnameString3 = String(SW_RES(STR_ADDITIONAL_ACCNAME_STRING3));
3179 	FreeResource();
3180 
3181 	Link aLink(LINK(this, SwTokenWindow, ScrollHdl));
3182 	aLeftScrollWin.SetClickHdl(aLink);
3183 	aRightScrollWin.SetClickHdl(aLink);
3184 }
3185 /* -----------------01.07.99 12:17-------------------
3186 
3187  --------------------------------------------------*/
~SwTokenWindow()3188 SwTokenWindow::~SwTokenWindow()
3189 {
3190 //	for(sal_uInt16 i = GetItemCount(); i ; i--)
3191 //		RemoveItem(i - 1);
3192 
3193     for( sal_uInt32 n = 0; n < aControlList.Count(); ++n )
3194     {
3195         Control* pControl = aControlList.GetObject( n );
3196         pControl->SetGetFocusHdl( Link() );
3197         pControl->SetLoseFocusHdl( Link() );
3198     }
3199 
3200     for( sal_uLong i = aControlList.Count(); i; )
3201 	{
3202 		Control* pControl = aControlList.Remove( --i );
3203 		delete pControl;
3204 	}
3205 }
3206 /* -----------------16.06.99 13:56-------------------
3207 
3208  --------------------------------------------------*/
SetForm(SwForm & rForm,sal_uInt16 nL)3209 void	SwTokenWindow::SetForm(SwForm& rForm, sal_uInt16 nL)
3210 {
3211 	SetActiveControl(0);
3212 	bValid = sal_True;
3213 	if(pForm)
3214 	{
3215 		//apply current level settings to the form
3216         for( sal_uLong i = aControlList.Count(); i; )
3217 		{
3218 			Control* pControl = aControlList.Remove( --i );
3219 			delete pControl;
3220 		}
3221 	}
3222 	nLevel = nL;
3223 	pForm = &rForm;
3224 	//now the display
3225 	if(nLevel < MAXLEVEL || rForm.GetTOXType() == TOX_AUTHORITIES)
3226 	{
3227 	 	Size aToolBoxSize = GetSizePixel();
3228 
3229         // #i21237#
3230         SwFormTokens aPattern = pForm->GetPattern(nLevel + 1);
3231         SwFormTokens::iterator aIt = aPattern.begin();
3232 		sal_Bool bLastWasText = sal_False; //assure alternating text - code - text
3233 
3234 		Control* pSetActiveControl = 0;
3235 		while(aIt != aPattern.end()) // #i21237#
3236 		{
3237 			SwFormToken aToken(*aIt); // #i21237#
3238 
3239 			if(TOKEN_TEXT == aToken.eTokenType)
3240 			{
3241 				DBG_ASSERT(!bLastWasText, "text following text is invalid");
3242 				Control* pCtrl = InsertItem(aToken.sText, aToken);
3243 				bLastWasText = sal_True;
3244 				if(!GetActiveControl())
3245 					SetActiveControl(pCtrl);
3246 			}
3247 			else
3248 			{
3249 				if( !bLastWasText )
3250 				{
3251 					bLastWasText = sal_True;
3252 					SwFormToken aTemp(TOKEN_TEXT);
3253 					Control* pCtrl = InsertItem(aEmptyStr, aTemp);
3254 					if(!pSetActiveControl)
3255 						pSetActiveControl = pCtrl;
3256 				}
3257 				const sal_Char* pTmp = 0;
3258 				switch( aToken.eTokenType )
3259 				{
3260 				case TOKEN_ENTRY_NO:	pTmp = SwForm::aFormEntryNum; break;
3261 				case TOKEN_ENTRY_TEXT:  pTmp = SwForm::aFormEntryTxt; break;
3262 				case TOKEN_ENTRY:       pTmp = SwForm::aFormEntry; break;
3263 				case TOKEN_TAB_STOP:    pTmp = SwForm::aFormTab; break;
3264 				case TOKEN_PAGE_NUMS:   pTmp = SwForm::aFormPageNums; break;
3265 				case TOKEN_CHAPTER_INFO:pTmp = SwForm::aFormChapterMark; break;
3266 				case TOKEN_LINK_START:  pTmp = SwForm::aFormLinkStt; break;
3267 				case TOKEN_LINK_END:    pTmp = SwForm::aFormLinkEnd; break;
3268 				case TOKEN_AUTHORITY:   pTmp = SwForm::aFormAuth; break;
3269                 default:; //prevent warning
3270 				}
3271 
3272 				InsertItem( pTmp ? String::CreateFromAscii(pTmp)
3273 								 : aEmptyStr, aToken );
3274 				bLastWasText = sal_False;
3275 			}
3276 
3277             aIt++; // #i21237#
3278 		}
3279 		if(!bLastWasText)
3280 		{
3281 			bLastWasText = sal_True;
3282 			SwFormToken aTemp(TOKEN_TEXT);
3283 			Control* pCtrl = InsertItem(aEmptyStr, aTemp);
3284 			if(!pSetActiveControl)
3285 				pSetActiveControl = pCtrl;
3286 		}
3287 		SetActiveControl(pSetActiveControl);
3288 	}
3289 	AdjustScrolling();
3290 }
3291 /* -----------------19.08.99 13:00-------------------
3292 
3293  --------------------------------------------------*/
SetActiveControl(Control * pSet)3294 void SwTokenWindow::SetActiveControl(Control* pSet)
3295 {
3296     if( pSet != pActiveCtrl )
3297 	{
3298 		pActiveCtrl = pSet;
3299 		if( pActiveCtrl )
3300 		{
3301 			pActiveCtrl->GrabFocus();
3302 			//it must be a SwTOXEdit
3303 			const SwFormToken* pFToken;
3304 			if( WINDOW_EDIT == pActiveCtrl->GetType() )
3305 				pFToken = &((SwTOXEdit*)pActiveCtrl)->GetFormToken();
3306 			else
3307 				pFToken = &((SwTOXButton*)pActiveCtrl)->GetFormToken();
3308 
3309 			SwFormToken aTemp( *pFToken );
3310 			aButtonSelectedHdl.Call( &aTemp );
3311 		}
3312 	}
3313 }
3314 
3315 /* -----------------17.06.99 09:53-------------------
3316 
3317  --------------------------------------------------*/
InsertItem(const String & rText,const SwFormToken & rToken)3318 Control*	SwTokenWindow::InsertItem(const String& rText, const SwFormToken& rToken)
3319 {
3320 	Control* pRet = 0;
3321 	Control* pLast = aControlList.Last();
3322 	Size aControlSize(GetOutputSizePixel());
3323  	Point aControlPos;
3324 	if( pLast )
3325 	{
3326 		aControlSize = pLast->GetSizePixel();
3327 		aControlPos = pLast->GetPosPixel();
3328 		aControlPos.X() += aControlSize.Width();
3329 	}
3330 	if(TOKEN_TEXT == rToken.eTokenType)
3331 	{
3332 		SwTOXEdit* pEdit = new SwTOXEdit(&aCtrlParentWin, this, rToken);
3333 		pEdit->SetPosPixel(aControlPos);
3334 		aControlList.Insert(pEdit, aControlList.Count());
3335 		pEdit->SetText(rText);
3336 		sal_uInt32 nIndex = GetControlIndex( TOKEN_TEXT, pEdit );
3337 		String s1 = String::CreateFromAscii(" (");
3338 		String s2 = String::CreateFromAscii(")");
3339 		String s3 = String::CreateFromAscii(", ");
3340 		String strName(accessibleName);
3341 		strName += String::CreateFromInt32(nIndex);
3342 		if ( nIndex == 1 )
3343 		{
3344 			/*Press left or right arrow to choose the structure controls*/
3345 			strName += s1;
3346 			strName += sAdditionalAccnameString2;
3347 			strName += s3;
3348 			/*Press Ctrl+Alt+A to move focus for more operations*/
3349 			strName += sAdditionalAccnameString1;
3350 			strName += s3;
3351 			/*Press Ctrl+Alt+B to move focus back to the current structure control*/
3352 			strName += sAdditionalAccnameString3;
3353 			strName += s2;
3354 			pEdit->SetAccessibleName(strName);
3355 		}
3356 		else
3357 		{
3358 			pEdit->SetAccessibleName(strName);
3359 		}
3360 	 	Size aEditSize(aControlSize);
3361 		aEditSize.Width() = pEdit->GetTextWidth(rText) + EDIT_MINWIDTH;
3362 		pEdit->SetSizePixel(aEditSize);
3363 		pEdit->SetModifyHdl(LINK(this, SwTokenWindow, EditResize ));
3364 		pEdit->SetPrevNextLink(LINK(this, SwTokenWindow, NextItemHdl));
3365 		pEdit->SetGetFocusHdl(LINK(this, SwTokenWindow, TbxFocusHdl));
3366 		pEdit->Show();
3367 		pRet = pEdit;
3368 	}
3369 	else
3370 	{
3371         SwTOXButton* pButton = new SwTOXButton(&aCtrlParentWin, this, rToken);
3372 		pButton->SetPosPixel(aControlPos);
3373 		aControlList.Insert(pButton, aControlList.Count());
3374 	 	Size aEditSize(aControlSize);
3375 		aEditSize.Width() = pButton->GetTextWidth(rText) + 5;
3376 //        pButton->SetControlBackground(aCtrlColor);
3377 //        pButton->SetControlForeground(aTextColor);
3378         pButton->SetSizePixel(aEditSize);
3379 		pButton->SetPrevNextLink(LINK(this, SwTokenWindow, NextItemBtnHdl));
3380 		pButton->SetGetFocusHdl(LINK(this, SwTokenWindow, TbxFocusBtnHdl));
3381 		if(TOKEN_AUTHORITY != rToken.eTokenType)
3382 			pButton->SetText(aButtonTexts[rToken.eTokenType]);
3383 		else
3384 		{
3385 			//use the first two chars as symbol
3386 			String sTmp(SwAuthorityFieldType::GetAuthFieldName(
3387 						(ToxAuthorityField)rToken.nAuthorityField));
3388 			pButton->SetText(sTmp.Copy(0, 2));
3389 		}
3390 		String sSpace = String::CreateFromAscii(" ");
3391 		sal_uInt32 nIndex = GetControlIndex( rToken.eTokenType, pButton );
3392 		String sAccName = aButtonHelpTexts[rToken.eTokenType];
3393 		if ( nIndex )
3394 		{
3395 			sAccName += sSpace;
3396 			sAccName += String::CreateFromInt32(nIndex);
3397 		}
3398 		pButton->SetAccessibleName( sAccName );
3399 		pButton->Show();
3400 		pRet = pButton;
3401 	}
3402 	return pRet;
3403 }
3404 /* -----------------16.07.99 11:50-------------------
3405 
3406  --------------------------------------------------*/
InsertAtSelection(const String & rText,const SwFormToken & rToken)3407 void	SwTokenWindow::InsertAtSelection(
3408 			const String& rText,
3409 			const SwFormToken& rToken)
3410 {
3411 	DBG_ASSERT(pActiveCtrl, "no active control!");
3412 	if(!pActiveCtrl)
3413 		return;
3414 	SwFormToken aToInsertToken(rToken);
3415 	if(TOKEN_LINK_START == aToInsertToken.eTokenType)
3416 	{
3417 		//determine if start or end of hyperlink is appropriate
3418 		//eventually change a following link start into a link end
3419 		// groups of LS LE should be ignored
3420 		// <insert>
3421 		//LS <insert>
3422 		//LE <insert>
3423 		//<insert> LS
3424 		//<insert> LE
3425 		//<insert>
3426 		sal_Bool bPreStartLinkFound = sal_False; //
3427 		sal_Bool bPreEndLinkFound = sal_False;
3428 
3429 		const Control* pControl = aControlList.First();
3430 		const Control* pExchange = 0;
3431 		while( pControl && pActiveCtrl != pControl )
3432 		{
3433 			if( WINDOW_EDIT != pControl->GetType())
3434 			{
3435 				const SwFormToken& rNewToken =
3436 								((SwTOXButton*)pControl)->GetFormToken();
3437 				if( TOKEN_LINK_START == rNewToken.eTokenType )
3438 				{
3439 					bPreStartLinkFound = sal_True;
3440 					pExchange = 0;
3441 				}
3442 				else if(TOKEN_LINK_END == rNewToken.eTokenType)
3443 				{
3444 					if( bPreStartLinkFound )
3445 						bPreStartLinkFound = sal_False;
3446 					else
3447 					{
3448 						bPreEndLinkFound = sal_False;
3449 						pExchange = pControl;
3450 					}
3451 				}
3452 			}
3453 			pControl = aControlList.Next();
3454 		}
3455 
3456 		sal_Bool bPostLinkEndFound = sal_False;
3457 		sal_Bool bPostLinkStartFound = sal_False;
3458 		if(!bPreStartLinkFound && !bPreEndLinkFound)
3459 			while(pControl)
3460 			{
3461 				if( pControl != pActiveCtrl &&
3462 					WINDOW_EDIT != pControl->GetType())
3463 				{
3464 					const SwFormToken& rNewToken =
3465 									((SwTOXButton*)pControl)->GetFormToken();
3466 					if( TOKEN_LINK_START == rNewToken.eTokenType )
3467 					{
3468 						if(bPostLinkStartFound)
3469 							break;
3470 						bPostLinkStartFound = sal_True;
3471 						pExchange = pControl;
3472 					}
3473 					else if(TOKEN_LINK_END == rNewToken.eTokenType )
3474 					{
3475 						if(bPostLinkStartFound)
3476 						{
3477 							bPostLinkStartFound = sal_False;
3478 							pExchange = 0;
3479 						}
3480 						else
3481 						{
3482 							bPostLinkEndFound = sal_True;
3483 						}
3484 						break;
3485 					}
3486 				}
3487 				pControl = aControlList.Next();
3488 			}
3489 
3490 		if(bPreStartLinkFound)
3491 		{
3492 			aToInsertToken.eTokenType = TOKEN_LINK_END;
3493 			aToInsertToken.sText = 	aButtonTexts[TOKEN_LINK_END];
3494 		}
3495 
3496 		if(bPostLinkStartFound)
3497 		{
3498 			DBG_ASSERT(pExchange, "no control to exchange?");
3499 			if(pExchange)
3500 			{
3501 				((SwTOXButton*)pExchange)->SetLinkEnd();
3502 				((SwTOXButton*)pExchange)->SetText(aButtonTexts[TOKEN_LINK_END]);
3503 			}
3504 		}
3505 
3506 		if(bPreEndLinkFound)
3507 		{
3508 			DBG_ASSERT(pExchange, "no control to exchange?");
3509 			if(pExchange)
3510 			{
3511 				((SwTOXButton*)pExchange)->SetLinkStart();
3512 				((SwTOXButton*)pExchange)->SetText(aButtonTexts[TOKEN_LINK_START]);
3513 			}
3514 		}
3515 	}
3516 
3517 	//if the active control is text then insert a new button at the selection
3518 	//else replace the button
3519 	sal_uInt32 nActivePos = aControlList.GetPos(pActiveCtrl);
3520 	sal_uInt32 nInsertPos = nActivePos;
3521 
3522     Size aControlSize(GetOutputSizePixel());
3523 	if( WINDOW_EDIT == pActiveCtrl->GetType())
3524 	{
3525 		nInsertPos++;
3526 	 	Selection aSel = ((SwTOXEdit*)pActiveCtrl)->GetSelection();
3527 		aSel.Justify();
3528 		String sEditText = ((SwTOXEdit*)pActiveCtrl)->GetText();
3529         String sLeft = sEditText.Copy( 0, static_cast< sal_uInt16 >(aSel.A()) );
3530         String sRight = sEditText.Copy( static_cast< sal_uInt16 >(aSel.B()),
3531                                         static_cast< sal_uInt16 >(sEditText.Len() - aSel.B()));
3532 
3533 		((SwTOXEdit*)pActiveCtrl)->SetText(sLeft);
3534 		((SwTOXEdit*)pActiveCtrl)->AdjustSize();
3535 
3536 		SwFormToken aTmpToken(TOKEN_TEXT);
3537 		SwTOXEdit* pEdit = new SwTOXEdit(&aCtrlParentWin, this, aTmpToken);
3538 		aControlList.Insert(pEdit, nActivePos + 1);
3539 		pEdit->SetText(sRight);
3540 		sal_uInt32 nIndex = GetControlIndex( TOKEN_TEXT, pEdit );
3541 		String s1 = String::CreateFromAscii(" (");
3542 		String s2 = String::CreateFromAscii(")");
3543 		String s3 = String::CreateFromAscii(", ");
3544 		String strName(accessibleName);
3545 		strName += String::CreateFromInt32(nIndex);
3546 		if ( nIndex == 1)
3547 		{
3548 			/*Press left or right arrow to choose the structure controls*/
3549 			strName += s1;
3550 			strName += sAdditionalAccnameString2;
3551 			strName += s3;
3552 			/*Press Ctrl+Alt+A to move focus for more operations*/
3553 			strName += sAdditionalAccnameString1;
3554 			strName += s3;
3555 			/*Press Ctrl+Alt+B to move focus back to the current structure control*/
3556 			strName += sAdditionalAccnameString3;
3557 			strName += s2;
3558 			pEdit->SetAccessibleName(strName);
3559 		}
3560 		else
3561 		{
3562 			pEdit->SetAccessibleName(strName);
3563 		}
3564 		pEdit->SetSizePixel(aControlSize);
3565 		pEdit->AdjustSize();
3566 		pEdit->SetModifyHdl(LINK(this, SwTokenWindow, EditResize ));
3567 		pEdit->SetPrevNextLink(LINK(this, SwTokenWindow, NextItemHdl));
3568 		pEdit->SetGetFocusHdl(LINK(this, SwTokenWindow, TbxFocusHdl));
3569 		pEdit->Show();
3570 	}
3571 	else
3572 	{
3573 		aControlList.Remove(pActiveCtrl);
3574 		pActiveCtrl->Hide();
3575 		delete pActiveCtrl;
3576 	}
3577 
3578     //now the new button
3579 	SwTOXButton* pButton = new SwTOXButton(&aCtrlParentWin, this, aToInsertToken);
3580 	aControlList.Insert(pButton, nInsertPos);
3581     pButton->SetPrevNextLink(LINK(this, SwTokenWindow, NextItemBtnHdl));
3582 	pButton->SetGetFocusHdl(LINK(this, SwTokenWindow, TbxFocusBtnHdl));
3583 	if(TOKEN_AUTHORITY != aToInsertToken.eTokenType)
3584 		pButton->SetText(aButtonTexts[aToInsertToken.eTokenType]);
3585 	else
3586 	{
3587 		//use the first two chars as symbol
3588 		String sTmp(SwAuthorityFieldType::GetAuthFieldName(
3589 					(ToxAuthorityField)aToInsertToken.nAuthorityField));
3590 		pButton->SetText(sTmp.Copy(0, 2));
3591 	}
3592 
3593 	String sSpace = String::CreateFromAscii(" ");
3594 	sal_uInt32 nIndex = GetControlIndex( rToken.eTokenType, pButton );
3595 	String sAccName = aButtonHelpTexts[rToken.eTokenType];
3596 	if ( nIndex )
3597 	{
3598 		sAccName += sSpace;
3599 		sAccName += String::CreateFromInt32(nIndex);
3600 	}
3601 	pButton->SetAccessibleName( sAccName );
3602  Size aEditSize(GetOutputSizePixel());
3603 	aEditSize.Width() = pButton->GetTextWidth(rText) + 5;
3604 	pButton->SetSizePixel(aEditSize);
3605 	pButton->Check(sal_True);
3606 	pButton->Show();
3607 	SetActiveControl(pButton);
3608 
3609 	AdjustPositions();
3610 }
3611 /* -----------------19.08.99 12:42-------------------
3612 
3613  --------------------------------------------------*/
RemoveControl(SwTOXButton * pDel,sal_Bool bInternalCall)3614 void SwTokenWindow::RemoveControl(SwTOXButton* pDel, sal_Bool bInternalCall )
3615 {
3616 	if(bInternalCall && TOX_AUTHORITIES == pForm->GetTOXType())
3617 		m_pParent->PreTokenButtonRemoved(pDel->GetFormToken());
3618 
3619 	sal_uInt32 nActivePos = aControlList.GetPos(pDel);
3620 	DBG_ASSERT(nActivePos != 0xffffffff, "Control does not exist!");
3621 	// the two neighbours of the box must be merged
3622 	// the properties of the right one will be lost
3623 	DBG_ASSERT(nActivePos && nActivePos < aControlList.Count() - 1,
3624 		"Button at first or last position?");
3625 	aControlList.Seek(nActivePos - 1);
3626 	Control* pLeftEdit = aControlList.GetCurObject();
3627 	aControlList.Seek(nActivePos + 1);
3628 	Control* pRightEdit = aControlList.GetCurObject();
3629 	String sTemp(((SwTOXEdit*)pLeftEdit)->GetText());
3630 	sTemp += ((SwTOXEdit*)pRightEdit)->GetText();
3631 	((SwTOXEdit*)pLeftEdit)->SetText(sTemp);
3632 	((SwTOXEdit*)pLeftEdit)->AdjustSize();
3633 
3634 	aControlList.Remove(pRightEdit);
3635 	delete pRightEdit;
3636 
3637 	aControlList.Remove(pDel);
3638 	pActiveCtrl->Hide();
3639 	delete pActiveCtrl;
3640 	SetActiveControl(pLeftEdit);
3641 	AdjustPositions();
3642 	if(aModifyHdl.IsSet())
3643 		aModifyHdl.Call(0);
3644 }
3645 
3646 /* -----------------16.07.99 12:39-------------------
3647 
3648  --------------------------------------------------*/
AdjustPositions()3649 void SwTokenWindow::AdjustPositions()
3650 {
3651 	if(aControlList.Count() > 1)
3652 	{
3653 		Control* pCtrl = aControlList.First();
3654 	 Point aNextPos = pCtrl->GetPosPixel();
3655 		aNextPos.X() += pCtrl->GetSizePixel().Width();
3656 		while(0 != (pCtrl = aControlList.Next()))
3657 		{
3658 			pCtrl->SetPosPixel(aNextPos);
3659 			aNextPos.X() += pCtrl->GetSizePixel().Width();
3660 		}
3661 		AdjustScrolling();
3662 	}
3663 };
3664 /* -----------------------------16.08.00 13:22--------------------------------
3665 
3666  ---------------------------------------------------------------------------*/
MoveControls(long nOffset)3667 void SwTokenWindow::MoveControls(long nOffset)
3668 {
3669 	// move the complete list
3670 	Control* pCtrl = aControlList.First();
3671 	do
3672 	{
3673 		Point aPos = pCtrl->GetPosPixel();
3674 		aPos.X() += nOffset;
3675 		pCtrl->SetPosPixel(aPos);
3676 	}while(0 != (pCtrl = aControlList.Next()));
3677 }
3678 /* -----------------------------14.01.00 13:03--------------------------------
3679 
3680  ---------------------------------------------------------------------------*/
AdjustScrolling()3681 void SwTokenWindow::AdjustScrolling()
3682 {
3683 	if(aControlList.Count() > 1)
3684 	{
3685 		//validate scroll buttons
3686 		Control* pLastCtrl = aControlList.Last();
3687 		Control* pFirstCtrl = aControlList.First();
3688 		long nSpace = aCtrlParentWin.GetSizePixel().Width();
3689 		long nWidth = pLastCtrl->GetPosPixel().X() - pFirstCtrl->GetPosPixel().X()
3690 													+ pLastCtrl->GetSizePixel().Width();
3691 		sal_Bool bEnable = nWidth > nSpace;
3692 		//the active control must be visible
3693 		if(bEnable && pActiveCtrl)
3694 		{
3695 		 	Point aActivePos(pActiveCtrl->GetPosPixel());
3696 			long nMove = 0;
3697 			if(aActivePos.X() < 0)
3698 				nMove = -aActivePos.X();
3699 			else if((aActivePos.X() + pActiveCtrl->GetSizePixel().Width())  > nSpace)
3700 				nMove = -(aActivePos.X() + pActiveCtrl->GetSizePixel().Width() - nSpace);
3701 			if(nMove)
3702 				MoveControls(nMove);
3703 			aLeftScrollWin.Enable(aControlList.First()->GetPosPixel().X() < 0);
3704 			Control* pCtrl = aControlList.Last();
3705 			aRightScrollWin.Enable((pCtrl->GetPosPixel().X() + pCtrl->GetSizePixel().Width()) > nSpace);
3706 		}
3707 		else
3708 		{
3709 			if(pFirstCtrl)
3710 			{
3711 				//if the control fits into the space then the first control must be at postion 0
3712 				long nFirstPos = pFirstCtrl->GetPosPixel().X();
3713 				if(nFirstPos != 0)
3714 					MoveControls(-nFirstPos);
3715 			}
3716 			aRightScrollWin.Enable(sal_False);
3717 			aLeftScrollWin.Enable(sal_False);
3718 		}
3719 	}
3720 }
3721 /* -----------------------------14.01.00 13:57--------------------------------
3722 
3723  ---------------------------------------------------------------------------*/
IMPL_LINK(SwTokenWindow,ScrollHdl,ImageButton *,pBtn)3724 IMPL_LINK(SwTokenWindow, ScrollHdl, ImageButton*, pBtn )
3725 {
3726 	if(aControlList.Count())
3727 	{
3728 		const long nSpace = aCtrlParentWin.GetSizePixel().Width();
3729 #if OSL_DEBUG_LEVEL > 1
3730 	//find all start/end positions and print it
3731 	String sMessage(String::CreateFromAscii("Space: "));
3732 	sMessage += String::CreateFromInt32(nSpace);
3733 	sMessage += String::CreateFromAscii(" | ");
3734 	Control* pDebugCtrl = aControlList.First();
3735 	do
3736 	{
3737 		long nDebugXPos = pDebugCtrl->GetPosPixel().X();
3738 		long nDebugWidth = pDebugCtrl->GetSizePixel().Width();
3739 		sMessage += String::CreateFromInt32( nDebugXPos );
3740 		sMessage += String::CreateFromAscii(" ");
3741 		sMessage += String::CreateFromInt32(nDebugXPos + nDebugWidth);
3742 		sMessage += String::CreateFromAscii(" | ");
3743 
3744 	}while(0 != (pDebugCtrl = aControlList.Next()));
3745 
3746 #endif
3747 
3748 		long nMove = 0;
3749 		if(pBtn == &aLeftScrollWin)
3750 		{
3751 			//find the first completely visible control (left edge visible)
3752 			for(sal_uInt16 i = 0; i < aControlList.Count(); i++ )
3753 			{
3754 				Control* pCtrl = aControlList.GetObject(i);
3755 				long nXPos = pCtrl->GetPosPixel().X();
3756 				if(nXPos >= 0)
3757 				{
3758 					if(!i)
3759 						//move the current control to the left edge
3760 						nMove = -nXPos;
3761 					else
3762 						//move the left neighbor to the start position
3763 						nMove = -aControlList.GetObject(i - 1)->GetPosPixel().X();
3764 					break;
3765 				}
3766 			}
3767 		}
3768 		else
3769 		{
3770 			//find the first completely visible control (left edge visible)
3771             for(sal_uLong i = aControlList.Count(); i; i-- )
3772 			{
3773 				Control* pCtrl = aControlList.GetObject(i - 1);
3774 				long nCtrlWidth = pCtrl->GetSizePixel().Width();
3775 				long nXPos = pCtrl->GetPosPixel().X() + nCtrlWidth;
3776 				if(nXPos <= nSpace)
3777 				{
3778 					if( i < aControlList.Count())
3779 					{
3780 						//move the right neighbor  to the right edge right aligned
3781 						Control* pRight = aControlList.GetObject(i);
3782 						nMove = nSpace - pRight->GetPosPixel().X() - pRight->GetSizePixel().Width();
3783 					}
3784 					break;
3785 				}
3786 			}
3787 
3788 			//move it left until it's completely visible
3789 		}
3790 		if(nMove)
3791 		{
3792 			// move the complete list
3793 			Control* pCtrl = aControlList.First();
3794 			do
3795 			{
3796 			 Point aPos = pCtrl->GetPosPixel();
3797 				aPos.X() += nMove;
3798 				pCtrl->SetPosPixel(aPos);
3799 			}while(0 != (pCtrl = aControlList.Next()));
3800 			aLeftScrollWin.Enable(aControlList.First()->GetPosPixel().X() < 0);
3801 			pCtrl = aControlList.Last();
3802 			aRightScrollWin.Enable((pCtrl->GetPosPixel().X() + pCtrl->GetSizePixel().Width()) > nSpace);
3803 
3804 #if OSL_DEBUG_LEVEL > 1
3805 			sMessage.AppendAscii("Move: ");
3806 			sMessage += String::CreateFromInt32(nMove);
3807 			GetParent()->GetParent()->GetParent()->SetText(sMessage);
3808 #endif
3809 		}
3810 	}
3811 	return 0;
3812 }
3813 /* -----------------17.06.99 11:59-------------------
3814 
3815  --------------------------------------------------*/
GetPattern() const3816 String	SwTokenWindow::GetPattern() const
3817 {
3818 	String sRet;
3819 	const Control* pControl = ((SwTokenWindow*)this)->aControlList.First();
3820 	while(pControl)
3821 	{
3822 		const SwFormToken& rNewToken = WINDOW_EDIT == pControl->GetType()
3823 					? ((SwTOXEdit*)pControl)->GetFormToken()
3824 					: ((SwTOXButton*)pControl)->GetFormToken();
3825 
3826 		//TODO: prevent input of TOX_STYLE_DELIMITER in KeyInput
3827 		sRet += rNewToken.GetString();
3828 
3829 		pControl = ((SwTokenWindow*)this)->aControlList.Next();
3830 	}
3831 	return sRet;
3832 }
3833 /* -----------------19.08.99 11:27-------------------
3834 	Description: Check if a control of the specified
3835 					TokenType is already contained in the list
3836  --------------------------------------------------*/
Contains(FormTokenType eSearchFor) const3837 sal_Bool SwTokenWindow::Contains(FormTokenType eSearchFor) const
3838 {
3839 	sal_Bool bRet = sal_False;
3840 	const Control* pControl = ((SwTokenWindow*)this)->aControlList.First();
3841 	while(pControl)
3842 	{
3843 		const SwFormToken& rNewToken = WINDOW_EDIT == pControl->GetType()
3844 					? ((SwTOXEdit*)pControl)->GetFormToken()
3845 					: ((SwTOXButton*)pControl)->GetFormToken();
3846 
3847 		if(eSearchFor == rNewToken.eTokenType)
3848 		{
3849 			bRet = sal_True;
3850 			break;
3851 		}
3852 		pControl = ((SwTokenWindow*)this)->aControlList.Next();
3853 	}
3854 	return bRet;
3855 }
3856 //---------------------------------------------------
CreateQuickHelp(Control * pCtrl,const SwFormToken & rToken,const HelpEvent & rHEvt)3857 sal_Bool SwTokenWindow::CreateQuickHelp(Control* pCtrl,
3858 			const SwFormToken& rToken,
3859 			const HelpEvent& rHEvt)
3860 {
3861 	sal_Bool bRet = sal_False;
3862 	if( rHEvt.GetMode() & HELPMODE_QUICK )
3863 	{
3864 		sal_Bool bBalloon = Help::IsBalloonHelpEnabled();
3865 		String sEntry;
3866 		if(bBalloon || rToken.eTokenType != TOKEN_AUTHORITY)
3867 			sEntry = (aButtonHelpTexts[rToken.eTokenType]);
3868 		if(rToken.eTokenType == TOKEN_AUTHORITY )
3869 		{
3870  			sEntry += SwAuthorityFieldType::GetAuthFieldName(
3871 								(ToxAuthorityField) rToken.nAuthorityField);
3872 		}
3873 
3874 	 Point aPos = OutputToScreenPixel(pCtrl->GetPosPixel());
3875 	 Rectangle aItemRect( aPos, pCtrl->GetSizePixel() );
3876 		if(rToken.eTokenType == TOKEN_TAB_STOP )
3877 		{
3878 //			sEntry += '\n';
3879 //		  	sEntry += rToken.nTabStopPosition;
3880 		}
3881 		else
3882 		{
3883 			if(rToken.sCharStyleName.Len())
3884 			{
3885 				if(bBalloon)
3886 					sEntry += '\n';
3887 				else
3888 					sEntry += ' ';
3889 				sEntry += sCharStyle;
3890 		  		sEntry += rToken.sCharStyleName;
3891 			}
3892 		}
3893 		if(bBalloon)
3894 		{
3895 			Help::ShowBalloon( this, aPos, aItemRect, sEntry );
3896 		}
3897 		else
3898 			Help::ShowQuickHelp( this, aItemRect, sEntry,
3899 				QUICKHELP_LEFT|QUICKHELP_VCENTER );
3900 		bRet = sal_True;
3901 	}
3902 	return bRet;
3903 }
3904 /* -----------------------------14.01.00 12:22--------------------------------
3905 
3906  ---------------------------------------------------------------------------*/
Resize()3907 void SwTokenWindow::Resize()
3908 {
3909  Size aCompleteSize(GetOutputSizePixel());
3910 
3911  Point aRightPos(aRightScrollWin.GetPosPixel());
3912  Size aRightSize(aRightScrollWin.GetSizePixel());
3913 
3914  Size aMiddleSize(aCtrlParentWin.GetSizePixel());
3915 
3916 	long nMove = aCompleteSize.Width() - aRightSize.Width() - aRightPos.X();
3917 
3918 	aRightPos.X() += nMove;
3919 	aRightScrollWin.SetPosPixel(aRightPos);
3920 	aMiddleSize.Width() += nMove;
3921 	aCtrlParentWin.SetSizePixel(aMiddleSize);
3922 }
3923 
3924 /* -----------------16.06.99 15:23-------------------
3925 
3926  --------------------------------------------------*/
IMPL_LINK(SwTokenWindow,EditResize,Edit *,pEdit)3927 IMPL_LINK(SwTokenWindow, EditResize, Edit*, pEdit)
3928 {
3929 	((SwTOXEdit*)pEdit)->AdjustSize();
3930 	AdjustPositions();
3931 	if(aModifyHdl.IsSet())
3932 		aModifyHdl.Call(0);
3933 	return 0;
3934 }
3935 /* -----------------16.06.99 15:56-------------------
3936 
3937  --------------------------------------------------*/
IMPL_LINK(SwTokenWindow,NextItemHdl,SwTOXEdit *,pEdit)3938 IMPL_LINK(SwTokenWindow, NextItemHdl, SwTOXEdit*,  pEdit)
3939 {
3940 	sal_uInt16 nPos = (sal_uInt16)aControlList.GetPos(pEdit);
3941 	if( (nPos && !pEdit->IsNextControl()) ||
3942 		(nPos < aControlList.Count() - 1 && pEdit->IsNextControl()))
3943 	{
3944 		aControlList.Seek(nPos);
3945 		Control* pNextPrev = pEdit->IsNextControl() ? aControlList.Next() : aControlList.Prev();
3946 		nPos += pEdit->IsNextControl() ? 1 : -1;
3947 		pNextPrev->GrabFocus();
3948 		((SwTOXButton*)pNextPrev)->Check();
3949 		AdjustScrolling();
3950 	}
3951 	return 0;
3952 }
3953 /* -----------------17.06.99 08:58-------------------
3954 
3955  --------------------------------------------------*/
IMPL_LINK(SwTokenWindow,TbxFocusHdl,SwTOXEdit *,pEdit)3956 IMPL_LINK(SwTokenWindow, TbxFocusHdl, SwTOXEdit*, pEdit)
3957 {
3958 	for(sal_uInt16 i = 0; i < aControlList.Count(); i++)
3959 	{
3960 		Control* pControl = aControlList.First();
3961 		while(pControl)
3962 		{
3963 			if(WINDOW_EDIT != pControl->GetType() )
3964 				((SwTOXButton*)pControl)->Check(sal_False);
3965 			pControl = aControlList.Next();
3966 		}
3967 	}
3968 	SetActiveControl(pEdit);
3969 	return 0;
3970 }
3971 /* -----------------17.06.99 10:05-------------------
3972 
3973  --------------------------------------------------*/
IMPL_LINK(SwTokenWindow,NextItemBtnHdl,SwTOXButton *,pBtn)3974 IMPL_LINK(SwTokenWindow, NextItemBtnHdl, SwTOXButton*, pBtn )
3975 {
3976 	sal_uInt16 nPos = (sal_uInt16)aControlList.GetPos(pBtn);
3977 	if( (nPos && !pBtn->IsNextControl()) ||
3978 		(nPos < aControlList.Count() - 1 && pBtn->IsNextControl()))
3979 	{
3980 		aControlList.Seek(nPos);
3981 		sal_Bool bNext = pBtn->IsNextControl();
3982 		Control* pNextPrev = bNext ? aControlList.Next() : aControlList.Prev();
3983 		pNextPrev->GrabFocus();
3984 	 	Selection aSel(0, 0);
3985 		if(!bNext)
3986 		{
3987 			sal_uInt16 nLen = ((SwTOXEdit*)pNextPrev)->GetText().Len();
3988 			aSel.A() = nLen;
3989 			aSel.B() = nLen;
3990 		}
3991 		((SwTOXEdit*)pNextPrev)->SetSelection(aSel);
3992 		pBtn->Check(sal_False);
3993 		AdjustScrolling();
3994 	}
3995 	return 0;
3996 }
3997 
3998 /* -----------------17.06.99 10:04-------------------
3999 
4000  --------------------------------------------------*/
IMPL_LINK(SwTokenWindow,TbxFocusBtnHdl,SwTOXButton *,pBtn)4001 IMPL_LINK(SwTokenWindow, TbxFocusBtnHdl, SwTOXButton*, pBtn )
4002 {
4003 	for(sal_uInt16 i = 0; i < aControlList.Count(); i++)
4004 	{
4005 		Control* pControl = aControlList.First();
4006 		while(pControl)
4007 		{
4008 			if(WINDOW_EDIT != pControl->GetType() )
4009 				((SwTOXButton*)pControl)->Check(pBtn == pControl);
4010 			pControl = aControlList.Next();
4011 		}
4012 	}
4013 	SetActiveControl(pBtn);
4014 	return 0;
4015 }
4016 /* -----------------------------28.01.2002 12:22------------------------------
4017 
4018  ---------------------------------------------------------------------------*/
GetFocus()4019 void SwTokenWindow::GetFocus()
4020 {
4021     if(GETFOCUS_TAB & GetGetFocusFlags())
4022     {
4023        Control* pFirst = aControlList.First();
4024        if(pFirst)
4025        {
4026             pFirst->GrabFocus();
4027             SetActiveControl(pFirst);
4028             AdjustScrolling();
4029        }
4030     }
4031 }
SetFocus2theAllBtn()4032 void SwTokenWindow::SetFocus2theAllBtn()
4033 {
4034 	if (m_pParent)
4035 	{
4036 		m_pParent->SetFocus2theAllBtn();
4037 	}
4038 }
GetControlIndex(FormTokenType eType,const Control *) const4039 sal_uInt32 SwTokenWindow::GetControlIndex(FormTokenType eType, const Control* /* pCurControl */) const
4040 {
4041 	//there are only one entry-text button and only one page-number button,
4042 	//so we need not add index for these two buttons.
4043 	if ( eType == TOKEN_ENTRY_TEXT || eType == TOKEN_PAGE_NUMS )
4044 	{
4045 		return 0;
4046 	}
4047 
4048 	sal_uInt32 nIndex = 0;
4049 	const Control* pControl = ((SwTokenWindow*)this)->aControlList.First();
4050 	while(pControl)
4051 	{
4052 		const SwFormToken& rNewToken = WINDOW_EDIT == pControl->GetType()
4053 			? ((SwTOXEdit*)pControl)->GetFormToken()
4054 			: ((SwTOXButton*)pControl)->GetFormToken();
4055 
4056 		if(eType == rNewToken.eTokenType)
4057 		{
4058 			nIndex++;
4059 		}
4060 		pControl = ((SwTokenWindow*)this)->aControlList.Next();
4061 	}
4062 
4063 	return nIndex;
4064 }
4065 /* -----------------25.03.99 15:17-------------------
4066  *
4067  * --------------------------------------------------*/
SwTOXStylesTabPage(Window * pParent,const SfxItemSet & rAttrSet)4068 SwTOXStylesTabPage::SwTOXStylesTabPage(Window* pParent, const SfxItemSet& rAttrSet ) :
4069 	SfxTabPage(pParent, SW_RES(TP_TOX_STYLES), rAttrSet),
4070     aFormatFL(this,     SW_RES(FL_FORMAT  )),
4071     aLevelFT2(this,		SW_RES(FT_LEVEL	 )),
4072 	aLevelLB(this,		SW_RES(LB_LEVEL	 )),
4073 	aAssignBT(this,		SW_RES(BT_ASSIGN  )),
4074     aTemplateFT(this,	SW_RES(FT_TEMPLATE)),
4075 	aParaLayLB(this,	SW_RES(LB_PARALAY )),
4076 	aStdBT(this,		SW_RES(BT_STD  	 )),
4077 	aEditStyleBT(this, 	SW_RES(BT_EDIT_STYLE	)),
4078     m_pCurrentForm(0)
4079 {
4080 	FreeResource();
4081 
4082 	SetExchangeSupport( sal_True );
4083 
4084 	aAssignBT.SetModeImage( Image( SW_RES( IMG_ONE_LEFT_HC ) ), BMP_COLOR_HIGHCONTRAST );
4085 
4086 	aEditStyleBT.SetClickHdl   (LINK(	this, SwTOXStylesTabPage, EditStyleHdl));
4087 	aAssignBT.SetClickHdl  	   (LINK(	this, SwTOXStylesTabPage, AssignHdl));
4088 	aStdBT.SetClickHdl	  	   (LINK(	this, SwTOXStylesTabPage, StdHdl));
4089 	aParaLayLB.SetSelectHdl	   (LINK(	this, SwTOXStylesTabPage, EnableSelectHdl));
4090 	aLevelLB.SetSelectHdl  	   (LINK(	this, SwTOXStylesTabPage, EnableSelectHdl));
4091 	aParaLayLB.SetDoubleClickHdl(LINK(	this, SwTOXStylesTabPage, DoubleClickHdl));
4092 
4093 	aStdBT.SetAccessibleRelationMemberOf(&aFormatFL);
4094 	aAssignBT.SetAccessibleRelationMemberOf(&aFormatFL);
4095 	aEditStyleBT.SetAccessibleRelationMemberOf(&aFormatFL);
4096 
4097 }
4098 /* -----------------25.03.99 15:17-------------------
4099  *
4100  * --------------------------------------------------*/
~SwTOXStylesTabPage()4101 SwTOXStylesTabPage::~SwTOXStylesTabPage()
4102 {
4103     delete m_pCurrentForm;
4104 }
4105 /* -----------------25.03.99 15:17-------------------
4106  *
4107  * --------------------------------------------------*/
FillItemSet(SfxItemSet &)4108 sal_Bool	SwTOXStylesTabPage::FillItemSet( SfxItemSet& )
4109 {
4110 	return sal_True;
4111 }
4112 /* -----------------25.03.99 15:17-------------------
4113  *
4114  * --------------------------------------------------*/
Reset(const SfxItemSet & rSet)4115 void	SwTOXStylesTabPage::Reset( const SfxItemSet& rSet )
4116 {
4117 	ActivatePage(rSet);
4118 }
4119 /* -----------------25.03.99 15:17-------------------
4120  *
4121  * --------------------------------------------------*/
ActivatePage(const SfxItemSet &)4122 void	SwTOXStylesTabPage::ActivatePage( const SfxItemSet& )
4123 {
4124     m_pCurrentForm = new SwForm(GetForm());
4125 	aParaLayLB.Clear();
4126 	aLevelLB.Clear();
4127 
4128 	// kein Hyperlink fuer Benutzerverzeichnisse
4129 
4130     sal_uInt16 i, nSize = m_pCurrentForm->GetFormMax();
4131 
4132 	// form-Pattern anzeigen ohne Titel
4133 
4134 	//1. TemplateEntry	anzeigen
4135 	String aStr( SW_RES( STR_TITLE ));
4136     if( m_pCurrentForm->GetTemplate( 0 ).Len() )
4137 	{
4138 		aStr += ' ';
4139 		aStr += aDeliStart;
4140         aStr += m_pCurrentForm->GetTemplate( 0 );
4141 		aStr += aDeliEnd;
4142 	}
4143 	aLevelLB.InsertEntry(aStr);
4144 
4145 	for( i=1; i < nSize; ++i )
4146 	{
4147         if( TOX_INDEX == m_pCurrentForm->GetTOXType() &&
4148 			FORM_ALPHA_DELIMITTER == i )
4149 			aStr = SW_RESSTR(STR_ALPHA);
4150 		else
4151 		{
4152 			aStr  = SW_RESSTR(STR_LEVEL);
4153 			aStr += String::CreateFromInt32(
4154                     TOX_INDEX == m_pCurrentForm->GetTOXType() ? i - 1 : i );
4155 		}
4156 		String aCpy( aStr );
4157 
4158         if( m_pCurrentForm->GetTemplate( i ).Len() )
4159 		{
4160 			aCpy += ' ';
4161 			aCpy += aDeliStart;
4162             aCpy += m_pCurrentForm->GetTemplate( i );
4163 			aCpy += aDeliEnd;
4164 		}
4165 		aLevelLB.InsertEntry( aCpy );
4166 	}
4167 
4168 	// Templates initialisieren
4169 	const SwTxtFmtColl *pColl;
4170 	SwWrtShell& rSh = ((SwMultiTOXTabDialog*)GetTabDialog())->GetWrtShell();
4171 	const sal_uInt16 nSz = rSh.GetTxtFmtCollCount();
4172 
4173 	for( i = 0; i < nSz; ++i )
4174 		if( !(pColl = &rSh.GetTxtFmtColl( i ))->IsDefault() )
4175 			aParaLayLB.InsertEntry( pColl->GetName() );
4176 
4177 	// Pool-Collections abfragen und fuer das Verzeichnis setzen
4178     for( i = 0; i < m_pCurrentForm->GetFormMax(); ++i )
4179 	{
4180         aStr = m_pCurrentForm->GetTemplate( i );
4181 		if( aStr.Len() &&
4182 			LISTBOX_ENTRY_NOTFOUND == aParaLayLB.GetEntryPos( aStr ))
4183 			aParaLayLB.InsertEntry( aStr );
4184 	}
4185 
4186 	EnableSelectHdl(&aParaLayLB);
4187 }
4188 /* -----------------25.03.99 15:17-------------------
4189  *
4190  * --------------------------------------------------*/
DeactivatePage(SfxItemSet *)4191 int     SwTOXStylesTabPage::DeactivatePage( SfxItemSet* /*pSet*/  )
4192 {
4193     GetForm() = *m_pCurrentForm;
4194 	return LEAVE_PAGE;
4195 }
4196 
4197 /* -----------------25.03.99 15:17-------------------
4198  *
4199  * --------------------------------------------------*/
Create(Window * pParent,const SfxItemSet & rAttrSet)4200 SfxTabPage*	SwTOXStylesTabPage::Create( Window* pParent,
4201 								const SfxItemSet& rAttrSet)
4202 {
4203 	return new SwTOXStylesTabPage(pParent, rAttrSet);
4204 }
4205 /* -----------------26.03.99 12:47-------------------
4206  *
4207  * --------------------------------------------------*/
IMPL_LINK(SwTOXStylesTabPage,EditStyleHdl,Button *,pBtn)4208 IMPL_LINK( SwTOXStylesTabPage, EditStyleHdl, Button *, pBtn )
4209 {
4210 	if( LISTBOX_ENTRY_NOTFOUND != aParaLayLB.GetSelectEntryPos())
4211 	{
4212 		SfxStringItem aStyle(SID_STYLE_EDIT, aParaLayLB.GetSelectEntry());
4213 		SfxUInt16Item aFamily(SID_STYLE_FAMILY, SFX_STYLE_FAMILY_PARA);
4214 //		SwPtrItem aShell(FN_PARAM_WRTSHELL, pWrtShell);
4215 		Window* pDefDlgParent = Application::GetDefDialogParent();
4216 		Application::SetDefDialogParent( pBtn );
4217 		SwWrtShell& rSh = ((SwMultiTOXTabDialog*)GetTabDialog())->GetWrtShell();
4218 		rSh.GetView().GetViewFrame()->GetDispatcher()->Execute(
4219 		SID_STYLE_EDIT, SFX_CALLMODE_SYNCHRON|SFX_CALLMODE_MODAL,
4220 			&aStyle, &aFamily/*, &aShell*/, 0L);
4221 		Application::SetDefDialogParent( pDefDlgParent );
4222 	}
4223 	return 0;
4224 }
4225 /*--------------------------------------------------------------------
4226 	 Beschreibung: Vorlagen zuweisen
4227  --------------------------------------------------------------------*/
IMPL_LINK(SwTOXStylesTabPage,AssignHdl,Button *,EMPTYARG)4228 IMPL_LINK( SwTOXStylesTabPage, AssignHdl, Button *, EMPTYARG )
4229 {
4230 	sal_uInt16 nLevPos 	 = aLevelLB.GetSelectEntryPos();
4231 	sal_uInt16 nTemplPos = aParaLayLB.GetSelectEntryPos();
4232 	if(nLevPos 	 != LISTBOX_ENTRY_NOTFOUND &&
4233 	   nTemplPos != LISTBOX_ENTRY_NOTFOUND)
4234 	{
4235 		String aStr(aLevelLB.GetEntry(nLevPos));
4236 		sal_uInt16 nDelPos = aStr.Search(aDeliStart);
4237 		if(nDelPos != STRING_NOTFOUND)
4238 			aStr.Erase(nDelPos-1);
4239 		aStr += ' ';
4240 		aStr += aDeliStart;
4241 		aStr += aParaLayLB.GetSelectEntry();
4242 
4243         m_pCurrentForm->SetTemplate(nLevPos, aParaLayLB.GetSelectEntry());
4244 
4245 		aStr += aDeliEnd;
4246 
4247 		aLevelLB.RemoveEntry(nLevPos);
4248 		aLevelLB.InsertEntry(aStr, nLevPos);
4249 		aLevelLB.SelectEntry(aStr);
4250 		ModifyHdl(0);
4251 	}
4252 	return 0;
4253 }
4254 /* -----------------26.03.99 09:10-------------------
4255  *
4256  * --------------------------------------------------*/
IMPL_LINK(SwTOXStylesTabPage,StdHdl,Button *,EMPTYARG)4257 IMPL_LINK( SwTOXStylesTabPage, StdHdl, Button *, EMPTYARG )
4258 {
4259 	sal_uInt16 nPos = aLevelLB.GetSelectEntryPos();
4260 	if(nPos != LISTBOX_ENTRY_NOTFOUND)
4261 	{	String aStr(aLevelLB.GetEntry(nPos));
4262 		sal_uInt16 nDelPos = aStr.Search(aDeliStart);
4263 		if(nDelPos != STRING_NOTFOUND)
4264 			aStr.Erase(nDelPos-1);
4265 		aLevelLB.RemoveEntry(nPos);
4266 		aLevelLB.InsertEntry(aStr, nPos);
4267 		aLevelLB.SelectEntry(aStr);
4268         m_pCurrentForm->SetTemplate(nPos, aEmptyStr);
4269 		ModifyHdl(0);
4270 	}
4271 	return 0;
4272 }
4273 /* -----------------26.03.99 09:11-------------------
4274  *
4275  * --------------------------------------------------*/
IMPL_LINK_INLINE_START(SwTOXStylesTabPage,DoubleClickHdl,Button *,EMPTYARG)4276 IMPL_LINK_INLINE_START( SwTOXStylesTabPage, DoubleClickHdl, Button *, EMPTYARG )
4277 {
4278 	String aTmpName( aParaLayLB.GetSelectEntry() );
4279 	SwWrtShell& rSh = ((SwMultiTOXTabDialog*)GetTabDialog())->GetWrtShell();
4280 
4281 	if(aParaLayLB.GetSelectEntryPos() != LISTBOX_ENTRY_NOTFOUND &&
4282 	   (aLevelLB.GetSelectEntryPos() == 0 || SwMultiTOXTabDialog::IsNoNum(rSh, aTmpName)))
4283 		AssignHdl(&aAssignBT);
4284 	return 0;
4285 }
IMPL_LINK_INLINE_END(SwTOXStylesTabPage,DoubleClickHdl,Button *,EMPTYARG)4286 IMPL_LINK_INLINE_END( SwTOXStylesTabPage, DoubleClickHdl, Button *, EMPTYARG )
4287 /*--------------------------------------------------------------------
4288 	 Beschreibung: nur wenn selektiert enable
4289  --------------------------------------------------------------------*/
4290 IMPL_LINK( SwTOXStylesTabPage, EnableSelectHdl, ListBox *, EMPTYARG )
4291 {
4292 	//UpdatePattern();
4293 	aStdBT.Enable(aLevelLB.GetSelectEntryPos()  != LISTBOX_ENTRY_NOTFOUND);
4294 
4295 	SwWrtShell& rSh = ((SwMultiTOXTabDialog*)GetTabDialog())->GetWrtShell();
4296 	String aTmpName(aParaLayLB.GetSelectEntry());
4297 	aAssignBT.Enable(aParaLayLB.GetSelectEntryPos() != LISTBOX_ENTRY_NOTFOUND &&
4298 					 LISTBOX_ENTRY_NOTFOUND != aLevelLB.GetSelectEntryPos() &&
4299 	   (aLevelLB.GetSelectEntryPos() == 0 || SwMultiTOXTabDialog::IsNoNum(rSh, aTmpName)));
4300 	aEditStyleBT.Enable(aParaLayLB.GetSelectEntryPos() != LISTBOX_ENTRY_NOTFOUND );
4301 	return 0;
4302 }
4303 /* -----------------------------18.01.00 16:54--------------------------------
4304 
4305  ---------------------------------------------------------------------------*/
IMPL_LINK(SwTOXStylesTabPage,ModifyHdl,void *,EMPTYARG)4306 IMPL_LINK(SwTOXStylesTabPage, ModifyHdl, void*, EMPTYARG)
4307 {
4308 	SwMultiTOXTabDialog* pTOXDlg = (SwMultiTOXTabDialog*)GetTabDialog();
4309 	if(pTOXDlg)
4310 	{
4311         GetForm() = *m_pCurrentForm;
4312 		pTOXDlg->CreateOrUpdateExample(pTOXDlg->GetCurrentTOXType().eType, TOX_PAGE_STYLES);
4313 	}
4314 	return 0;
4315 }
4316 /******************************************************************************
4317 
4318 ******************************************************************************/
4319 #define ITEM_SEARCH			1
4320 #define ITEM_ALTERNATIVE    2
4321 #define ITEM_PRIM_KEY       3
4322 #define ITEM_SEC_KEY        4
4323 #define ITEM_COMMENT        5
4324 #define ITEM_CASE			6
4325 #define ITEM_WORDONLY       7
4326 
4327 
SwEntryBrowseBox(Window * pParent,const ResId & rId,BrowserMode nMode)4328 SwEntryBrowseBox::SwEntryBrowseBox(Window* pParent, const ResId& rId,
4329 							   						BrowserMode nMode ) :
4330 			SwEntryBrowseBox_Base( pParent, rId, nMode,
4331 						   BROWSER_KEEPSELECTION |
4332 						   BROWSER_COLUMNSELECTION |
4333 						   BROWSER_MULTISELECTION |
4334 						   BROWSER_TRACKING_TIPS |
4335 						   BROWSER_HLINESFULL |
4336 						   BROWSER_VLINESFULL |
4337 						   BROWSER_AUTO_VSCROLL|
4338 						   BROWSER_HIDECURSOR	),
4339             aCellEdit(&GetDataWindow(), 0),
4340             aCellCheckBox(&GetDataWindow()),
4341 
4342             sSearch(        ResId(ST_SEARCH, *rId.GetResMgr()         )),
4343             sAlternative(   ResId(ST_ALTERNATIVE, *rId.GetResMgr()  )),
4344             sPrimKey(       ResId(ST_PRIMKEY, *rId.GetResMgr()      )),
4345             sSecKey(        ResId(ST_SECKEY, *rId.GetResMgr()           )),
4346             sComment(       ResId(ST_COMMENT, *rId.GetResMgr()      )),
4347             sCaseSensitive( ResId(ST_CASESENSITIVE, *rId.GetResMgr()    )),
4348             sWordOnly(      ResId(ST_WORDONLY, *rId.GetResMgr()     )),
4349             sYes(           ResId(ST_TRUE, *rId.GetResMgr()             )),
4350             sNo(            ResId(ST_FALSE, *rId.GetResMgr()            )),
4351 			bModified(sal_False)
4352 {
4353 	FreeResource();
4354 	aCellCheckBox.GetBox().EnableTriState(sal_False);
4355 	xController = new ::svt::EditCellController(&aCellEdit);
4356 	xCheckController = new ::svt::CheckBoxCellController(&aCellCheckBox);
4357 
4358 	//////////////////////////////////////////////////////////////////////
4359 	// HACK: BrowseBox invalidiert nicht ihre Childs, wie es eigentlich sein sollte.
4360 	// Deshalb wird WB_CLIPCHILDREN zurueckgesetzt, wodurch das Invalidieren
4361 	// der Childs erzwungen wird.
4362 	WinBits aStyle = GetStyle();
4363 	if( aStyle & WB_CLIPCHILDREN )
4364 	{
4365 		aStyle &= ~WB_CLIPCHILDREN;
4366 		SetStyle( aStyle );
4367 	}
4368 	const String* aTitles[7] =
4369 	{
4370 		&sSearch,
4371 		&sAlternative,
4372 		&sPrimKey,
4373 		&sSecKey,
4374 		&sComment,
4375 		&sCaseSensitive,
4376 		&sWordOnly
4377 	};
4378 
4379 	long nWidth = GetSizePixel().Width();
4380 	nWidth /=7;
4381 	--nWidth;
4382 	for(sal_uInt16 i = 1; i < 8; i++)
4383 		InsertDataColumn( i, *aTitles[i - 1], nWidth,
4384 						  HIB_STDSTYLE, HEADERBAR_APPEND );
4385 
4386 }
4387 /* -----------------------------19.01.00 11:29--------------------------------
4388 
4389  ---------------------------------------------------------------------------*/
SeekRow(long nRow)4390 sal_Bool    SwEntryBrowseBox::SeekRow( long nRow )
4391 {
4392 	nCurrentRow = nRow;
4393 	return sal_True;
4394 }
4395 /* -----------------------------19.01.00 15:32--------------------------------
4396 
4397  ---------------------------------------------------------------------------*/
GetCellText(long nRow,sal_uInt16 nColumn) const4398 String SwEntryBrowseBox::GetCellText(long nRow, sal_uInt16 nColumn) const
4399 {
4400 	const String* pRet = &aEmptyStr;
4401 	if(aEntryArr.Count() > nRow)
4402 	{
4403         AutoMarkEntry* pEntry = aEntryArr[ static_cast< sal_uInt16 >(nRow) ];
4404 		switch(nColumn)
4405 		{
4406 			case  ITEM_SEARCH		:pRet = &pEntry->sSearch; break;
4407 			case  ITEM_ALTERNATIVE  :pRet = &pEntry->sAlternative; break;
4408 			case  ITEM_PRIM_KEY     :pRet = &pEntry->sPrimKey	; break;
4409 			case  ITEM_SEC_KEY      :pRet = &pEntry->sSecKey	; break;
4410 			case  ITEM_COMMENT      :pRet = &pEntry->sComment	; break;
4411 			case  ITEM_CASE		    :pRet = pEntry->bCase ? &sYes : &sNo; break;
4412 			case  ITEM_WORDONLY		:pRet = pEntry->bWord ? &sYes : &sNo; break;
4413 		}
4414 	}
4415 	return *pRet;
4416 }
4417 
4418 /* -----------------------------19.01.00 11:29--------------------------------
4419 
4420  ---------------------------------------------------------------------------*/
PaintCell(OutputDevice & rDev,const Rectangle & rRect,sal_uInt16 nColumnId) const4421 void 	SwEntryBrowseBox::PaintCell(OutputDevice& rDev,
4422 								const Rectangle& rRect, sal_uInt16 nColumnId) const
4423 {
4424 	String sPaint = GetCellText( nCurrentRow, nColumnId );
4425 	sal_uInt16 nStyle = TEXT_DRAW_CLIP | TEXT_DRAW_CENTER;
4426 	rDev.DrawText( rRect, sPaint, nStyle );
4427 }
4428 /* -----------------------------19.01.00 14:51--------------------------------
4429 
4430  ---------------------------------------------------------------------------*/
GetController(long,sal_uInt16 nCol)4431 ::svt::CellController* SwEntryBrowseBox::GetController(long /*nRow*/, sal_uInt16 nCol)
4432 {
4433 	return nCol < ITEM_CASE ? xController : xCheckController;
4434 }
4435 /* -----------------------------19.01.00 15:36--------------------------------
4436 
4437  ---------------------------------------------------------------------------*/
SaveModified()4438 sal_Bool SwEntryBrowseBox::SaveModified()
4439 {
4440 	SetModified();
4441     sal_uInt16 nRow = static_cast< sal_uInt16 >(GetCurRow());
4442 	sal_uInt16 nCol = GetCurColumnId();
4443 
4444 	String sNew;
4445 	sal_Bool bVal = sal_False;
4446 	::svt::CellController* pController = 0;
4447 	if(nCol < ITEM_CASE)
4448 	{
4449 		pController = xController;
4450 		sNew = ((::svt::EditCellController*)pController)->GetEditImplementation()->GetText( LINEEND_LF );
4451 	}
4452 	else
4453 	{
4454 		pController = xCheckController;
4455 		bVal = ((::svt::CheckBoxCellController*)pController)->GetCheckBox().IsChecked();
4456 	}
4457 	AutoMarkEntry* pEntry = nRow >= aEntryArr.Count() ? new AutoMarkEntry
4458 													  : aEntryArr[nRow];
4459 	switch(nCol)
4460 	{
4461 		case  ITEM_SEARCH		: pEntry->sSearch = sNew; break;
4462 		case  ITEM_ALTERNATIVE  : pEntry->sAlternative = sNew; break;
4463 		case  ITEM_PRIM_KEY     : pEntry->sPrimKey	 = sNew; break;
4464 		case  ITEM_SEC_KEY      : pEntry->sSecKey	 = sNew; break;
4465 		case  ITEM_COMMENT      : pEntry->sComment	 = sNew; break;
4466 		case  ITEM_CASE		    : pEntry->bCase = bVal; break;
4467 		case  ITEM_WORDONLY		: pEntry->bWord = bVal; break;
4468 	}
4469 	if(nRow >= aEntryArr.Count())
4470 	{
4471 		aEntryArr.Insert( pEntry, aEntryArr.Count() );
4472 		RowInserted(nRow, 1, sal_True, sal_True);
4473 		if(nCol < ITEM_WORDONLY)
4474 		{
4475 			pController->ClearModified();
4476 			GoToRow( nRow );
4477 		}
4478 	}
4479 	return sal_True;
4480 }
4481 /* -----------------------------19.01.00 14:32--------------------------------
4482 
4483  ---------------------------------------------------------------------------*/
InitController(::svt::CellControllerRef & rController,long nRow,sal_uInt16 nCol)4484 void 	SwEntryBrowseBox::InitController(
4485 				::svt::CellControllerRef& rController, long nRow, sal_uInt16 nCol)
4486 {
4487 	String rTxt = GetCellText( nRow, nCol );
4488 	if(nCol < ITEM_CASE)
4489 	{
4490 		rController = xController;
4491 		::svt::CellController* pController = xController;
4492 		((::svt::EditCellController*)pController)->GetEditImplementation()->SetText( rTxt );
4493 	}
4494 	else
4495 	{
4496 		rController = xCheckController;
4497 		::svt::CellController* pController = xCheckController;
4498 		((::svt::CheckBoxCellController*)pController)->GetCheckBox().Check(
4499 															rTxt == sYes );
4500  	}
4501 }
4502 /* -----------------------------19.01.00 12:19--------------------------------
4503 
4504  ---------------------------------------------------------------------------*/
ReadEntries(SvStream & rInStr)4505 void	SwEntryBrowseBox::ReadEntries(SvStream& rInStr)
4506 {
4507 	AutoMarkEntry* pToInsert = 0;
4508 	const String sZero('0');
4509 	rtl_TextEncoding  eTEnc = gsl_getSystemTextEncoding();
4510 	while( !rInStr.GetError() && !rInStr.IsEof() )
4511 	{
4512 		String sLine;
4513 		rInStr.ReadByteStringLine( sLine, eTEnc );
4514 
4515 		// # -> comment
4516 		// ; -> delimiter between entries ->
4517 		// Format: TextToSearchFor;AlternativeString;PrimaryKey;SecondaryKey
4518 		// Leading and trailing blanks are ignored
4519 		if( sLine.Len() )
4520 		{
4521 			//comments are contained in separate lines but are put into the struct of the following data
4522 			//line (if available)
4523 			if( '#' != sLine.GetChar(0) )
4524 			{
4525 				if( !pToInsert )
4526 					pToInsert = new AutoMarkEntry;
4527 
4528 				sal_uInt16 nSttPos = 0;
4529 				pToInsert->sSearch 		= sLine.GetToken(0, ';', nSttPos );
4530 				pToInsert->sAlternative = sLine.GetToken(0, ';', nSttPos );
4531 				pToInsert->sPrimKey 	= sLine.GetToken(0, ';', nSttPos );
4532 				pToInsert->sSecKey 		= sLine.GetToken(0, ';', nSttPos );
4533 
4534 				String sStr = sLine.GetToken(0, ';', nSttPos );
4535 				pToInsert->bCase = sStr.Len() && sStr != sZero;
4536 
4537 				sStr = sLine.GetToken(0, ';', nSttPos );
4538 				pToInsert->bWord = sStr.Len() && sStr != sZero;
4539 
4540 				aEntryArr.Insert( pToInsert, aEntryArr.Count() );
4541 				pToInsert = 0;
4542 			}
4543 			else
4544 			{
4545 				if(pToInsert)
4546 					aEntryArr.Insert(pToInsert, aEntryArr.Count());
4547 				pToInsert = new AutoMarkEntry;
4548 				pToInsert->sComment = sLine;
4549 				pToInsert->sComment.Erase(0, 1);
4550 			}
4551 		}
4552 	}
4553 	if( pToInsert )
4554 		aEntryArr.Insert(pToInsert, aEntryArr.Count());
4555 	RowInserted(0, aEntryArr.Count() + 1, sal_True);
4556 }
4557 /* -----------------------------19.01.00 12:19--------------------------------
4558 
4559  ---------------------------------------------------------------------------*/
WriteEntries(SvStream & rOutStr)4560 void	SwEntryBrowseBox::WriteEntries(SvStream& rOutStr)
4561 {
4562 	//check if the current controller is modified
4563 	sal_uInt16 nCol = GetCurColumnId();
4564 	::svt::CellController* pController;
4565 	if(nCol < ITEM_CASE)
4566 		pController = xController;
4567 	else
4568 		pController = xCheckController;
4569 	if(pController ->IsModified())
4570 		GoToColumnId(nCol < ITEM_CASE ? ++nCol : --nCol );
4571 
4572 	rtl_TextEncoding  eTEnc = gsl_getSystemTextEncoding();
4573 	for(sal_uInt16 i = 0; i < aEntryArr.Count();i++)
4574 	{
4575 		AutoMarkEntry* pEntry = aEntryArr[i];
4576 		if(pEntry->sComment.Len())
4577 		{
4578 			String sWrite('#');
4579 			sWrite += pEntry->sComment;
4580 			rOutStr.WriteByteStringLine( sWrite, eTEnc );
4581 		}
4582 
4583 		String sWrite( pEntry->sSearch );
4584 		sWrite += ';';
4585 		sWrite += pEntry->sAlternative;
4586 		sWrite += ';';
4587 		sWrite += pEntry->sPrimKey;
4588 		sWrite += ';';
4589 		sWrite += pEntry->sSecKey;
4590 		sWrite += ';';
4591 		sWrite += pEntry->bCase ? '1' : '0';
4592 		sWrite += ';';
4593 		sWrite += pEntry->bWord ? '1' : '0';
4594 
4595 		if( sWrite.Len() > 5 )
4596 			rOutStr.WriteByteStringLine( sWrite, eTEnc );
4597 	}
4598 }
4599 /* -----------------------------21.01.00 11:49--------------------------------
4600 
4601  ---------------------------------------------------------------------------*/
IsModified() const4602 sal_Bool SwEntryBrowseBox::IsModified()const
4603 {
4604 	if(bModified)
4605 		return sal_True;
4606 
4607 
4608 	//check if the current controller is modified
4609 	sal_uInt16 nCol = GetCurColumnId();
4610 	::svt::CellController* pController;
4611 	if(nCol < ITEM_CASE)
4612 		pController = xController;
4613 	else
4614 		pController = xCheckController;
4615 	return pController ->IsModified();
4616 }
4617 /* -----------------------------19.01.00 11:29--------------------------------
4618 
4619  ---------------------------------------------------------------------------*/
SwAutoMarkDlg_Impl(Window * pParent,const String & rAutoMarkURL,const String & rAutoMarkType,sal_Bool bCreate)4620 SwAutoMarkDlg_Impl::SwAutoMarkDlg_Impl(Window* pParent, const String& rAutoMarkURL,
4621 		const String& rAutoMarkType, sal_Bool bCreate) :
4622 	ModalDialog(pParent, SW_RES(DLG_CREATE_AUTOMARK)),
4623 	aOKPB(		this, SW_RES(PB_OK		)),
4624 	aCancelPB(	this, SW_RES(PB_CANCEL	)),
4625 	aHelpPB(	this, SW_RES(PB_HELP		)),
4626 	aEntriesBB(	this, SW_RES(BB_ENTRIES	)),
4627     aEntriesFL( this, SW_RES(FL_ENTRIES  )),
4628 	sAutoMarkURL(rAutoMarkURL),
4629 	sAutoMarkType(rAutoMarkType),
4630 	bCreateMode(bCreate)
4631 {
4632 	FreeResource();
4633 	aOKPB.SetClickHdl(LINK(this, SwAutoMarkDlg_Impl, OkHdl));
4634 
4635 	String sTitle = GetText();
4636 	sTitle.AppendAscii( RTL_CONSTASCII_STRINGPARAM(": "));
4637 	sTitle += sAutoMarkURL;
4638 	SetText(sTitle);
4639 	sal_Bool bError = sal_False;
4640 	if( bCreateMode )
4641 		aEntriesBB.RowInserted(0, 1, sal_True);
4642 	else
4643 	{
4644 		SfxMedium aMed( sAutoMarkURL, STREAM_STD_READ, sal_False );
4645 		if( aMed.GetInStream() && !aMed.GetInStream()->GetError() )
4646 			aEntriesBB.ReadEntries( *aMed.GetInStream() );
4647 		else
4648 			bError = sal_True;
4649 	}
4650 
4651 	if(bError)
4652 		EndDialog(RET_CANCEL);
4653 }
4654 /* -----------------------------19.01.00 11:12--------------------------------
4655 
4656  ---------------------------------------------------------------------------*/
~SwAutoMarkDlg_Impl()4657 SwAutoMarkDlg_Impl::~SwAutoMarkDlg_Impl()
4658 {
4659 }
4660 /* -----------------------------19.01.00 16:43--------------------------------
4661 
4662  ---------------------------------------------------------------------------*/
IMPL_LINK(SwAutoMarkDlg_Impl,OkHdl,OKButton *,EMPTYARG)4663 IMPL_LINK(SwAutoMarkDlg_Impl, OkHdl, OKButton*, EMPTYARG)
4664 {
4665 	sal_Bool bError = sal_False;
4666 	if(aEntriesBB.IsModified() || bCreateMode)
4667 	{
4668 		SfxMedium aMed( sAutoMarkURL,
4669 						bCreateMode ? STREAM_WRITE
4670 									: STREAM_WRITE| STREAM_TRUNC,
4671 						sal_False );
4672 		SvStream* pStrm = aMed.GetOutStream();
4673 		pStrm->SetStreamCharSet( RTL_TEXTENCODING_MS_1253 );
4674 		if( !pStrm->GetError() )
4675 		{
4676 			aEntriesBB.WriteEntries( *pStrm );
4677 			aMed.Commit();
4678 		}
4679 		else
4680 			bError = sal_True;
4681 	}
4682 	if( !bError )
4683 		EndDialog(RET_OK);
4684 	return 0;
4685 }
4686 
4687