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