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