Update ooo320-m1
[ooovba.git] / sw / source / ui / index / cnttab.cxx
blob34312b19bcc05ebf271063b71509795a75381e3e
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: cnttab.cxx,v $
10 * $Revision: 1.79 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_sw.hxx"
33 #ifdef SW_DLLIMPLEMENTATION
34 #undef SW_DLLIMPLEMENTATION
35 #endif
38 #include <rsc/rscsfx.hxx>
39 #include <vcl/msgbox.hxx>
40 #include <vcl/help.hxx>
41 #include <svtools/stritem.hxx>
42 #include <svtools/urihelper.hxx>
43 #include <svtools/pathoptions.hxx>
44 #include <sfx2/request.hxx>
45 #include <sfx2/viewfrm.hxx>
46 #include <sfx2/dispatch.hxx>
47 #include <sfx2/docfile.hxx>
48 #include <svx/dialogs.hrc>
49 #include <svx/svxdlg.hxx>
50 #include <svx/flagsdef.hxx>
51 #include <svx/simptabl.hxx>
52 #include <com/sun/star/ui/dialogs/TemplateDescription.hpp>
53 #include <com/sun/star/ui/dialogs/XFilePicker.hpp>
54 #include <com/sun/star/ui/dialogs/XFilterManager.hpp>
55 #include <svtools/indexentryres.hxx>
56 #include <svx/unolingu.hxx>
57 #include <column.hxx>
58 #include <fmtfsize.hxx>
59 #include <shellio.hxx>
60 #include <authfld.hxx>
61 #include <swtypes.hxx>
62 #include <wrtsh.hxx>
63 #ifndef _VIEW_HXX
64 #include <view.hxx>
65 #endif
66 #ifndef _BASESH_HXX
67 #include <basesh.hxx>
68 #endif
69 #include <outline.hxx>
70 #include <cnttab.hxx>
71 #include <swuicnttab.hxx>
72 #include <formedt.hxx>
73 #include <poolfmt.hxx>
74 #ifndef _POOLFMT_HRC
75 #include <poolfmt.hrc>
76 #endif
77 #include <uitool.hxx>
78 #include <fmtcol.hxx>
79 #include <fldbas.hxx>
80 #include <expfld.hxx>
81 #include <unotools.hxx>
82 #include <unotxdoc.hxx>
83 #include <docsh.hxx>
84 #include <swmodule.hxx>
85 #include <modcfg.hxx>
87 #ifndef _CMDID_H
88 #include <cmdid.h>
89 #endif
90 #ifndef _HELPID_H
91 #include <helpid.h>
92 #endif
93 #ifndef _UTLUI_HRC
94 #include <utlui.hrc>
95 #endif
96 #ifndef _INDEX_HRC
97 #include <index.hrc>
98 #endif
99 #ifndef _CNTTAB_HRC
100 #include <cnttab.hrc>
101 #endif
102 #ifndef _GLOBALS_HRC
103 #include <globals.hrc>
104 #endif
105 #include <SwStyleNameMapper.hxx>
106 #include <sfx2/filedlghelper.hxx>
107 #ifndef _TOXHLP_HXX
108 #include <toxwrap.hxx>
109 #endif
110 #include <chpfld.hxx>
112 #ifndef _UTLUI_HRC
113 #include "utlui.hrc"
114 #endif
116 #include <sfx2/app.hxx>
118 #include <unomid.h>
119 using namespace ::com::sun::star;
120 using namespace ::com::sun::star::lang;
121 using namespace ::com::sun::star::uno;
122 using namespace com::sun::star::ui::dialogs;
123 using ::rtl::OUString;
124 using namespace ::sfx2;
125 #include <svtools/editbrowsebox.hxx>
127 static const sal_Unicode aDeliStart = '['; //fuer die form
128 static const sal_Unicode aDeliEnd = ']'; //fuer die form
130 #define POS_GRF 0
131 #define POS_OLE 1
132 #define POS_TABLE 2
133 #define POS_FRAME 3
135 #define IDX_FILE_EXTENSION String::CreateFromAscii( \
136 RTL_CONSTASCII_STRINGPARAM( "*.sdi" ))
139 /* -----------------14.06.99 13:10-------------------
141 --------------------------------------------------*/
142 String lcl_CreateAutoMarkFileDlg( const String& rURL,
143 const String& rFileString, sal_Bool bOpen )
145 String sRet;
147 FileDialogHelper aDlgHelper( bOpen ?
148 TemplateDescription::FILEOPEN_SIMPLE : TemplateDescription::FILESAVE_AUTOEXTENSION, 0 );
149 uno::Reference < XFilePicker > xFP = aDlgHelper.GetFilePicker();
151 uno::Reference<XFilterManager> xFltMgr(xFP, UNO_QUERY);
152 String sCurFltr( IDX_FILE_EXTENSION );
153 xFltMgr->appendFilter( rFileString, sCurFltr );
154 xFltMgr->setCurrentFilter( rFileString ) ;
156 String& rLastSaveDir = (String&)SFX_APP()->GetLastSaveDirectory();
157 String sSaveDir = rLastSaveDir;
159 if( rURL.Len() )
160 xFP->setDisplayDirectory( rURL );
161 else
163 SvtPathOptions aPathOpt;
164 xFP->setDisplayDirectory( aPathOpt.GetUserConfigPath() );
167 if( aDlgHelper.Execute() == ERRCODE_NONE )
169 sRet = xFP->getFiles().getConstArray()[0];
171 rLastSaveDir = sSaveDir;
172 return sRet;
174 /* -----------------------------19.01.00 11:09--------------------------------
176 ---------------------------------------------------------------------------*/
177 struct AutoMarkEntry
179 String sSearch;
180 String sAlternative;
181 String sPrimKey;
182 String sSecKey;
183 String sComment;
184 sal_Bool bCase;
185 sal_Bool bWord;
187 AutoMarkEntry() :
188 bCase(sal_False),
189 bWord(sal_False){}
191 typedef AutoMarkEntry* AutoMarkEntryPtr;
192 SV_DECL_PTRARR_DEL(AutoMarkEntryArr, AutoMarkEntryPtr, 0, 4)
193 SV_IMPL_PTRARR(AutoMarkEntryArr, AutoMarkEntryPtr);
195 typedef ::svt::EditBrowseBox SwEntryBrowseBox_Base;
196 class SwEntryBrowseBox : public SwEntryBrowseBox_Base
198 Edit aCellEdit;
199 ::svt::CheckBoxControl aCellCheckBox;
201 String sSearch;
202 String sAlternative;
203 String sPrimKey;
204 String sSecKey;
205 String sComment;
206 String sCaseSensitive;
207 String sWordOnly;
208 String sYes;
209 String sNo;
211 AutoMarkEntryArr aEntryArr;
213 ::svt::CellControllerRef xController;
214 ::svt::CellControllerRef xCheckController;
216 long nCurrentRow;
217 sal_Bool bModified;
220 void SetModified() {bModified = sal_True;}
222 protected:
223 virtual sal_Bool SeekRow( long nRow );
224 // virtual void PaintField( OutputDevice& rDev, const awt::Rectangle& rRect,
225 // sal_uInt16 nColumnId ) const;
226 virtual void PaintCell(OutputDevice& rDev, const Rectangle& rRect, sal_uInt16 nColId) const;
227 virtual void InitController(::svt::CellControllerRef& rController, long nRow, sal_uInt16 nCol);
228 virtual ::svt::CellController* GetController(long nRow, sal_uInt16 nCol);
229 virtual sal_Bool SaveModified();
231 public:
232 SwEntryBrowseBox(Window* pParent, const ResId& rId,
233 BrowserMode nMode = 0 );
234 void ReadEntries(SvStream& rInStr);
235 void WriteEntries(SvStream& rOutStr);
237 sal_Bool IsModified()const;
239 virtual String GetCellText( long nRow, USHORT nColumn ) const;
242 class SwAutoMarkDlg_Impl : public ModalDialog
244 OKButton aOKPB;
245 CancelButton aCancelPB;
246 HelpButton aHelpPB;
248 SwEntryBrowseBox aEntriesBB;
249 FixedLine aEntriesFL;
251 String sAutoMarkURL;
252 const String sAutoMarkType;
254 sal_Bool bCreateMode;
256 DECL_LINK(OkHdl, OKButton*);
257 public:
258 SwAutoMarkDlg_Impl(Window* pParent, const String& rAutoMarkURL,
259 const String& rAutoMarkType, sal_Bool bCreate);
260 ~SwAutoMarkDlg_Impl();
263 /* -----------------04.11.99 11:02-------------------
265 --------------------------------------------------*/
266 sal_uInt16 CurTOXType::GetFlatIndex() const
268 sal_uInt16 nRet = static_cast< sal_uInt16 >(eType);
269 if(eType == TOX_USER && nIndex)
271 nRet = static_cast< sal_uInt16 >(TOX_AUTHORITIES + nIndex);
273 return nRet;
275 /*************************************************************************
277 *************************************************************************/
278 #define EDIT_MINWIDTH 15
280 /* -----------------14.06.99 12:12-------------------
282 --------------------------------------------------*/
283 SwMultiTOXTabDialog::SwMultiTOXTabDialog(Window* pParent, const SfxItemSet& rSet,
284 SwWrtShell &rShell,
285 SwTOXBase* pCurTOX,
286 sal_uInt16 nToxType, sal_Bool bGlobal) :
287 SfxTabDialog( pParent, SW_RES(DLG_MULTI_TOX), &rSet),
288 aExampleContainerWIN(this, SW_RES(WIN_EXAMPLE)),
289 aExampleWIN( &aExampleContainerWIN, 0 ),
290 aShowExampleCB( this, SW_RES(CB_SHOWEXAMPLE)),
291 pMgr( new SwTOXMgr( &rShell ) ),
292 rSh(rShell),
293 pExampleFrame(0),
294 pParamTOXBase(pCurTOX),
295 sUserDefinedIndex(SW_RES(ST_USERDEFINEDINDEX)),
296 nInitialTOXType(nToxType),
298 bEditTOX(sal_False),
299 bExampleCreated(sal_False),
300 bGlobalFlag(bGlobal)
302 FreeResource();
304 aExampleWIN.SetPosSizePixel(aExampleContainerWIN.GetPosPixel(),
305 aExampleContainerWIN.GetSizePixel());
307 eCurrentTOXType.eType = TOX_CONTENT;
308 eCurrentTOXType.nIndex = 0;
310 sal_uInt16 nUserTypeCount = rSh.GetTOXTypeCount(TOX_USER);
311 nTypeCount = nUserTypeCount + 6;
312 pFormArr = new SwForm*[nTypeCount];
313 pDescArr = new SwTOXDescription*[nTypeCount];
314 pxIndexSectionsArr = new SwIndexSections_Impl*[nTypeCount];
315 //the standard user index is on position TOX_USER
316 //all user user indexes follow after position TOX_AUTHORITIES
317 if(pCurTOX)
319 bEditTOX = sal_True;
321 for(int i = nTypeCount - 1; i > -1; i--)
323 pFormArr[i] = 0;
324 pDescArr[i] = 0;
325 pxIndexSectionsArr[i] = new SwIndexSections_Impl;
326 if(pCurTOX)
328 eCurrentTOXType.eType = pCurTOX->GetType();
329 sal_uInt16 nArrayIndex = static_cast< sal_uInt16 >(eCurrentTOXType.eType);
330 if(eCurrentTOXType.eType == TOX_USER)
332 //which user type is it?
333 for(sal_uInt16 nUser = 0; nUser < nUserTypeCount; nUser++)
335 const SwTOXType* pTemp = rSh.GetTOXType(TOX_USER, nUser);
336 if(pCurTOX->GetTOXType() == pTemp)
338 eCurrentTOXType.nIndex = nUser;
339 nArrayIndex = static_cast< sal_uInt16 >(nUser > 0 ? TOX_AUTHORITIES + nUser : TOX_USER);
340 break;
344 pFormArr[nArrayIndex] = new SwForm(pCurTOX->GetTOXForm());
345 pDescArr[nArrayIndex] = CreateTOXDescFromTOXBase(pCurTOX);
346 if(TOX_AUTHORITIES == eCurrentTOXType.eType)
348 const SwAuthorityFieldType* pFType = (const SwAuthorityFieldType*)
349 rSh.GetFldType(RES_AUTHORITY, aEmptyStr);
350 if(pFType)
352 String sBrackets;
353 if(pFType->GetPrefix())
354 sBrackets += pFType->GetPrefix();
355 if(pFType->GetSuffix())
356 sBrackets += pFType->GetSuffix();
357 pDescArr[nArrayIndex]->SetAuthBrackets(sBrackets);
358 pDescArr[nArrayIndex]->SetAuthSequence(pFType->IsSequence());
360 else
362 pDescArr[nArrayIndex]->SetAuthBrackets(C2S("[]"));
367 SfxAbstractDialogFactory* pFact = SfxAbstractDialogFactory::Create();
368 DBG_ASSERT(pFact, "Dialogdiet fail!");
369 AddTabPage(TP_TOX_SELECT, SwTOXSelectTabPage::Create, 0);
370 AddTabPage(TP_TOX_STYLES, SwTOXStylesTabPage::Create, 0);
371 AddTabPage(TP_COLUMN, SwColumnPage::Create, 0);
372 AddTabPage(TP_BACKGROUND, pFact->GetTabPageCreatorFunc( RID_SVXPAGE_BACKGROUND ), 0 );
373 AddTabPage(TP_TOX_ENTRY, SwTOXEntryTabPage::Create, 0);
374 if(!pCurTOX)
375 SetCurPageId(TP_TOX_SELECT);
377 aShowExampleCB.SetClickHdl(LINK(this, SwMultiTOXTabDialog, ShowPreviewHdl));
379 aShowExampleCB.Check( SW_MOD()->GetModuleConfig()->IsShowIndexPreview());
380 SetViewAlign( WINDOWALIGN_LEFT );
381 // SetViewWindow does not work if the dialog is visible!
383 if(!aShowExampleCB.IsChecked())
384 SetViewWindow( &aExampleContainerWIN );
386 Point aOldPos = GetPosPixel();
387 ShowPreviewHdl(0);
388 Point aNewPos = GetPosPixel();
389 //72040: initial position may be left of the view - that has to be corrected
390 if(aNewPos.X() < 0)
391 SetPosPixel(aOldPos);
393 /*-- 14.06.99 13:11:40---------------------------------------------------
395 -----------------------------------------------------------------------*/
396 SwMultiTOXTabDialog::~SwMultiTOXTabDialog()
398 SW_MOD()->GetModuleConfig()->SetShowIndexPreview(aShowExampleCB.IsChecked());
400 for(sal_uInt16 i = 0; i < nTypeCount; i++)
402 delete pFormArr[i];
403 delete pDescArr[i];
404 delete pxIndexSectionsArr[i];
406 delete[] pxIndexSectionsArr;
408 delete[] pFormArr;
409 delete[] pDescArr;
410 delete pMgr;
411 delete pExampleFrame;
413 /*-- 14.06.99 13:11:40---------------------------------------------------
415 -----------------------------------------------------------------------*/
416 void SwMultiTOXTabDialog::PageCreated( sal_uInt16 nId, SfxTabPage &rPage )
418 if( TP_BACKGROUND == nId )
420 SfxAllItemSet aSet(*(GetInputSetImpl()->GetPool()));
421 aSet.Put (SfxUInt32Item(SID_FLAG_TYPE, SVX_SHOW_SELECTOR));
422 rPage.PageCreated(aSet);
424 else if(TP_COLUMN == nId )
426 const SwFmtFrmSize& rSize = (const SwFmtFrmSize&)GetInputSetImpl()->Get(RES_FRM_SIZE);
428 ((SwColumnPage&)rPage).SetPageWidth(rSize.GetWidth());
430 else if(TP_TOX_ENTRY == nId)
431 ((SwTOXEntryTabPage&)rPage).SetWrtShell(rSh);
432 if(TP_TOX_SELECT == nId)
434 ((SwTOXSelectTabPage&)rPage).SetWrtShell(rSh);
435 if(USHRT_MAX != nInitialTOXType)
436 ((SwTOXSelectTabPage&)rPage).SelectType((TOXTypes)nInitialTOXType);
439 /*-- 14.06.99 13:11:40---------------------------------------------------
441 -----------------------------------------------------------------------*/
442 short SwMultiTOXTabDialog::Ok()
444 short nRet = SfxTabDialog::Ok();
445 SwTOXDescription& rDesc = GetTOXDescription(eCurrentTOXType);
446 SwTOXBase aNewDef(*rSh.GetDefaultTOXBase( eCurrentTOXType.eType, sal_True ));
448 sal_uInt16 nIndex = static_cast< sal_uInt16 >(eCurrentTOXType.eType);
449 if(eCurrentTOXType.eType == TOX_USER && eCurrentTOXType.nIndex)
451 nIndex = static_cast< sal_uInt16 >(TOX_AUTHORITIES + eCurrentTOXType.nIndex);
454 if(pFormArr[nIndex])
456 rDesc.SetForm(*pFormArr[nIndex]);
457 aNewDef.SetTOXForm(*pFormArr[nIndex]);
459 rDesc.ApplyTo(aNewDef);
460 if(!bGlobalFlag)
461 pMgr->UpdateOrInsertTOX(
462 rDesc, 0, GetOutputItemSet());
463 else if(bEditTOX)
464 pMgr->UpdateOrInsertTOX(
465 rDesc, &pParamTOXBase, GetOutputItemSet());
467 if(!eCurrentTOXType.nIndex)
468 rSh.SetDefaultTOXBase(aNewDef);
470 return nRet;
472 /* -----------------16.06.99 11:59-------------------
474 --------------------------------------------------*/
475 SwForm* SwMultiTOXTabDialog::GetForm(CurTOXType eType)
477 sal_uInt16 nIndex = eType.GetFlatIndex();
478 if(!pFormArr[nIndex])
479 pFormArr[nIndex] = new SwForm(eType.eType);
480 return pFormArr[nIndex];
482 /* -----------------09.09.99 11:29-------------------
484 --------------------------------------------------*/
485 SwTOXDescription& SwMultiTOXTabDialog::GetTOXDescription(CurTOXType eType)
487 sal_uInt16 nIndex = eType.GetFlatIndex();
488 if(!pDescArr[nIndex])
490 const SwTOXBase* pDef = rSh.GetDefaultTOXBase( eType.eType );
491 if(pDef)
492 pDescArr[nIndex] = CreateTOXDescFromTOXBase(pDef);
493 else
495 pDescArr[nIndex] = new SwTOXDescription(eType.eType);
496 if(eType.eType == TOX_USER)
497 pDescArr[nIndex]->SetTitle(sUserDefinedIndex);
498 else
499 pDescArr[nIndex]->SetTitle(
500 rSh.GetTOXType(eType.eType, 0)->GetTypeName());
502 if(TOX_AUTHORITIES == eType.eType)
504 const SwAuthorityFieldType* pFType = (const SwAuthorityFieldType*)
505 rSh.GetFldType(RES_AUTHORITY, aEmptyStr);
506 if(pFType)
508 String sBrackets(pFType->GetPrefix());
509 sBrackets += pFType->GetSuffix();
510 pDescArr[nIndex]->SetAuthBrackets(sBrackets);
511 pDescArr[nIndex]->SetAuthSequence(pFType->IsSequence());
513 else
515 pDescArr[nIndex]->SetAuthBrackets(C2S("[]"));
518 else if(TOX_INDEX == eType.eType)
519 pDescArr[nIndex]->SetMainEntryCharStyle(SW_RESSTR(STR_POOLCHR_IDX_MAIN_ENTRY));
522 return *pDescArr[nIndex];
524 /* -----------------09.09.99 11:36-------------------
526 --------------------------------------------------*/
527 SwTOXDescription* SwMultiTOXTabDialog::CreateTOXDescFromTOXBase(
528 const SwTOXBase*pCurTOX)
530 SwTOXDescription * pDesc = new SwTOXDescription(pCurTOX->GetType());
531 for(sal_uInt16 i = 0; i < MAXLEVEL; i++)
532 pDesc->SetStyleNames(pCurTOX->GetStyleNames(i), i);
533 pDesc->SetAutoMarkURL(rSh.GetTOIAutoMarkURL());
534 pDesc->SetTitle(pCurTOX->GetTitle());
537 pDesc->SetContentOptions(pCurTOX->GetCreateType());
538 if(pDesc->GetTOXType() == TOX_INDEX)
539 pDesc->SetIndexOptions(pCurTOX->GetOptions());
540 pDesc->SetMainEntryCharStyle(pCurTOX->GetMainEntryCharStyle());
541 if(pDesc->GetTOXType() != TOX_INDEX)
542 pDesc->SetLevel((BYTE)pCurTOX->GetLevel());
543 pDesc->SetCreateFromObjectNames(pCurTOX->IsFromObjectNames());
544 pDesc->SetSequenceName(pCurTOX->GetSequenceName());
545 pDesc->SetCaptionDisplay(pCurTOX->GetCaptionDisplay());
546 pDesc->SetFromChapter(pCurTOX->IsFromChapter());
547 pDesc->SetReadonly(pCurTOX->IsProtected());
548 pDesc->SetOLEOptions(pCurTOX->GetOLEOptions());
549 pDesc->SetLevelFromChapter(pCurTOX->IsLevelFromChapter());
550 pDesc->SetLanguage(pCurTOX->GetLanguage());
551 pDesc->SetSortAlgorithm(pCurTOX->GetSortAlgorithm());
552 return pDesc;
555 /* -----------------------------29.12.99 09:53--------------------------------
557 ---------------------------------------------------------------------------*/
559 IMPL_LINK( SwMultiTOXTabDialog, ShowPreviewHdl, CheckBox *, pBox )
561 if(aShowExampleCB.IsChecked())
563 if(!pExampleFrame && !bExampleCreated)
565 bExampleCreated = sal_True;
566 String sTemplate( String::CreateFromAscii(
567 RTL_CONSTASCII_STRINGPARAM("internal")) );
568 sTemplate += INET_PATH_TOKEN;
569 sTemplate.AppendAscii( RTL_CONSTASCII_STRINGPARAM("idxexample") );
570 String sTemplateWithoutExt( sTemplate );
571 #ifndef MAC_WITHOUT_EXT
572 sTemplate.AppendAscii( RTL_CONSTASCII_STRINGPARAM(".odt") );
573 #endif
575 SvtPathOptions aOpt;
576 // 6.0 (extension .sxw)
577 BOOL bExist = aOpt.SearchFile( sTemplate, SvtPathOptions::PATH_TEMPLATE );
579 #ifndef MAC_WITHOUT_EXT
580 if( !bExist )
582 // 6.0 (extension .sxw)
583 sTemplate = sTemplateWithoutExt;
584 sTemplate.AppendAscii( RTL_CONSTASCII_STRINGPARAM(".sxw") );
585 bExist = aOpt.SearchFile( sTemplate, SvtPathOptions::PATH_TEMPLATE );
587 if( !bExist )
589 // 5.0 (extension .vor)
590 sTemplate = sTemplateWithoutExt;
591 sTemplate.AppendAscii( RTL_CONSTASCII_STRINGPARAM(".sdw") );
592 bExist = aOpt.SearchFile( sTemplate, SvtPathOptions::PATH_TEMPLATE );
594 #endif
596 if(!bExist)
598 String sInfo(SW_RES(STR_FILE_NOT_FOUND));
599 sInfo.SearchAndReplaceAscii( "%1", sTemplate );
600 sInfo.SearchAndReplaceAscii( "%2", aOpt.GetTemplatePath() );
601 InfoBox aInfo(GetParent(), sInfo);
602 aInfo.Execute();
604 else
606 Link aLink(LINK(this, SwMultiTOXTabDialog, CreateExample_Hdl));
607 pExampleFrame = new SwOneExampleFrame(
608 aExampleWIN, EX_SHOW_ONLINE_LAYOUT, &aLink, &sTemplate);
610 if(!pExampleFrame->IsServiceAvailable())
612 pExampleFrame->CreateErrorMessage(0);
615 aShowExampleCB.Show(pExampleFrame && pExampleFrame->IsServiceAvailable());
618 sal_Bool bSetViewWindow = aShowExampleCB.IsChecked()
619 && pExampleFrame && pExampleFrame->IsServiceAvailable();
621 aExampleContainerWIN.Show( bSetViewWindow );
622 SetViewWindow( bSetViewWindow ? &aExampleContainerWIN : 0 );
624 Window *pTopmostParent = this;
625 while(pTopmostParent->GetParent())
626 pTopmostParent = pTopmostParent->GetParent();
627 ::Rectangle aRect(GetClientWindowExtentsRelative(pTopmostParent));
628 ::Point aPos = aRect.TopLeft();
629 Size aSize = GetSizePixel();
630 if(pBox)
631 AdjustLayout();
632 long nDiffWidth = GetSizePixel().Width() - aSize.Width();
633 aPos.X() -= nDiffWidth;
634 SetPosPixel(aPos);
636 return 0;
640 /* -----------------05.07.99 09:49-------------------
642 --------------------------------------------------*/
643 sal_Bool SwMultiTOXTabDialog::IsNoNum(SwWrtShell& rSh, const String& rName)
645 SwTxtFmtColl* pColl = rSh.GetParaStyle(rName);
646 //if(pColl && pColl->GetOutlineLevel() == NO_NUMBERING) //#outline level,zhaojianwei
647 if(pColl && ! pColl->IsAssignedToListLevelOfOutlineStyle()) //<-end,zhaojianwei
648 return sal_True;
650 sal_uInt16 nId = SwStyleNameMapper::GetPoolIdFromUIName(rName, nsSwGetPoolIdFromName::GET_POOLID_TXTCOLL);
651 if(nId != USHRT_MAX &&
652 //rSh.GetTxtCollFromPool(nId)->GetOutlineLevel() == NO_NUMBERING) //#outline level,zhaojianwei
653 ! rSh.GetTxtCollFromPool(nId)->IsAssignedToListLevelOfOutlineStyle()) //<-end,zhaojianwei
654 return sal_True;
656 return sal_False;
658 /* -----------------14.07.99 16:01-------------------
660 --------------------------------------------------*/
661 class SwIndexTreeLB : public SvTreeListBox
663 const HeaderBar* pHeaderBar;
664 public:
665 SwIndexTreeLB(Window* pWin, const ResId& rResId) :
666 SvTreeListBox(pWin, rResId), pHeaderBar(0){}
668 virtual void KeyInput( const KeyEvent& rKEvt );
669 virtual long GetTabPos( SvLBoxEntry*, SvLBoxTab* );
670 void SetHeaderBar(const HeaderBar* pHB) {pHeaderBar = pHB;}
672 /* -----------------14.07.99 16:03-------------------
674 --------------------------------------------------*/
675 long SwIndexTreeLB::GetTabPos( SvLBoxEntry* pEntry, SvLBoxTab* pTab)
677 long nData = (long)pEntry->GetUserData();
678 if(nData != USHRT_MAX)
680 long nPos = pHeaderBar->GetItemRect( static_cast< USHORT >(101 + nData) ).TopLeft().X();
681 nData = nPos;
683 else
684 nData = 0;
685 nData += pTab->GetPos();
686 return nData;
688 /* -----------------25.08.99 11:14-------------------
690 --------------------------------------------------*/
691 void SwIndexTreeLB::KeyInput( const KeyEvent& rKEvt )
693 SvLBoxEntry* pEntry = FirstSelected();
694 KeyCode aCode = rKEvt.GetKeyCode();
695 sal_Bool bChanged = sal_False;
696 if(pEntry)
698 long nLevel = (long)pEntry->GetUserData();
699 if(aCode.GetCode() == KEY_ADD )
701 if(nLevel < MAXLEVEL - 1)
702 nLevel++;
703 else if(nLevel == USHRT_MAX)
704 nLevel = 0;
705 bChanged = sal_True;
707 else if(aCode.GetCode() == KEY_SUBTRACT)
709 if(!nLevel)
710 nLevel = USHRT_MAX;
711 else if(nLevel != USHRT_MAX)
712 nLevel--;
713 bChanged = sal_True;
715 if(bChanged)
717 pEntry->SetUserData((void*)nLevel);
718 Invalidate();
721 if(!bChanged)
722 SvTreeListBox::KeyInput(rKEvt);
725 /* -----------------16.07.99 10:01-------------------
727 --------------------------------------------------*/
728 class SwHeaderTree : public Control
730 HeaderBar aStylesHB;
731 SwIndexTreeLB aStylesTLB;
733 public:
734 SwHeaderTree(Window* pParent, const ResId rResId);
736 HeaderBar& GetHeaderBar() {return aStylesHB;}
737 SwIndexTreeLB& GetTreeListBox() { return aStylesTLB;}
739 virtual void GetFocus();
741 /* -----------------16.07.99 10:11-------------------
743 --------------------------------------------------*/
744 SwHeaderTree::SwHeaderTree(Window* pParent, const ResId rResId) :
745 Control(pParent, rResId),
746 aStylesHB( this, ResId(HB_STYLES, *rResId.GetResMgr())),
747 aStylesTLB( this, ResId(TLB_STYLES, *rResId.GetResMgr()))
749 FreeResource();
750 aStylesHB.SetStyle(aStylesHB.GetStyle()|WB_BUTTONSTYLE|WB_TABSTOP|WB_BORDER);
751 Size aHBSize(aStylesHB.GetSizePixel());
752 aHBSize.Height() = aStylesHB.CalcWindowSizePixel().Height();
753 aStylesHB.SetSizePixel(aHBSize);
754 aStylesTLB.SetPosPixel(Point(0, aHBSize.Height()));
755 Size aTLBSize(aStylesHB.GetSizePixel());
756 aTLBSize.Height() = GetOutputSizePixel().Height() - aHBSize.Height();
757 aStylesTLB.SetSizePixel(aTLBSize);
758 aStylesTLB.SetHeaderBar(&aStylesHB);
760 /* -----------------25.08.99 10:38-------------------
762 --------------------------------------------------*/
763 void SwHeaderTree::GetFocus()
765 Control::GetFocus();
766 aStylesTLB.GrabFocus();
768 /* -----------------13.07.99 15:29-------------------
770 --------------------------------------------------*/
771 class SwAddStylesDlg_Impl : public SfxModalDialog
773 OKButton aOk;
774 CancelButton aCancel;
775 HelpButton aHelp;
777 FixedLine aStylesFL;
778 SwHeaderTree aHeaderTree;
779 ImageButton aLeftPB;
780 ImageButton aRightPB;
782 String sHBFirst;
783 String* pStyleArr;
785 DECL_LINK(OkHdl, OKButton*);
786 DECL_LINK(LeftRightHdl, PushButton*);
787 DECL_LINK(HeaderDragHdl, HeaderBar*);
789 public:
790 SwAddStylesDlg_Impl(Window* pParent, SwWrtShell& rWrtSh, String rStringArr[]);
791 ~SwAddStylesDlg_Impl();
793 /* -----------------13.07.99 15:39-------------------
795 --------------------------------------------------*/
796 SwAddStylesDlg_Impl::SwAddStylesDlg_Impl(Window* pParent,
797 SwWrtShell& rWrtSh, String rStringArr[]) :
798 SfxModalDialog(pParent, SW_RES(DLG_ADD_IDX_STYLES)),
799 aOk( this, SW_RES(PB_OK )),
800 aCancel( this, SW_RES(PB_CANCEL )),
801 aHelp( this, SW_RES(PB_HELP )),
803 aStylesFL( this, SW_RES(FL_STYLES )),
804 aHeaderTree(this, SW_RES(TR_HEADER )),
805 aLeftPB( this, SW_RES(PB_LEFT )),
806 aRightPB( this, SW_RES(PB_RIGHT )),
808 sHBFirst( SW_RES(ST_HB_FIRST)),
809 pStyleArr(rStringArr)
811 FreeResource();
813 aLeftPB.SetModeImage( Image( SW_RES( IMG_ALL_LEFT_HC ) ), BMP_COLOR_HIGHCONTRAST );
814 aRightPB.SetModeImage( Image( SW_RES( IMG_ALL_RIGHT_HC ) ), BMP_COLOR_HIGHCONTRAST );
816 aOk.SetClickHdl(LINK(this, SwAddStylesDlg_Impl, OkHdl));
817 aLeftPB.SetClickHdl(LINK(this, SwAddStylesDlg_Impl, LeftRightHdl));
818 aRightPB.SetClickHdl(LINK(this, SwAddStylesDlg_Impl, LeftRightHdl));
820 HeaderBar& rHB = aHeaderTree.GetHeaderBar();
821 rHB.SetEndDragHdl(LINK(this, SwAddStylesDlg_Impl, HeaderDragHdl));
823 long nWidth = rHB.GetSizePixel().Width();
824 sal_uInt16 i;
826 nWidth /= 14;
827 nWidth--;
828 rHB.InsertItem( 100, sHBFirst, 4 * nWidth );
829 for( i = 1; i <= MAXLEVEL; i++)
830 rHB.InsertItem( 100 + i, String::CreateFromInt32(i), nWidth );
831 rHB.Show();
833 SwIndexTreeLB& rTLB = aHeaderTree.GetTreeListBox();
834 rTLB.SetWindowBits(WB_CLIPCHILDREN|WB_SORT);
835 //aStylesTLB.SetSelectHdl(LINK(this, SwAddStylesDlg_Impl, SelectHdl));
836 rTLB.GetModel()->SetSortMode(SortAscending);
837 for(i = 0; i < MAXLEVEL; ++i)
839 String sStyles(rStringArr[i]);
840 for(sal_uInt16 nToken = 0; nToken < sStyles.GetTokenCount(TOX_STYLE_DELIMITER); nToken++)
842 String sTmp(sStyles.GetToken(nToken, TOX_STYLE_DELIMITER));
843 SvLBoxEntry* pEntry = rTLB.InsertEntry(sTmp);
844 pEntry->SetUserData(reinterpret_cast<void*>(i));
847 // now the other styles
849 const SwTxtFmtColl *pColl = 0;
850 const sal_uInt16 nSz = rWrtSh.GetTxtFmtCollCount();
852 for ( sal_uInt16 j = 0;j < nSz; ++j )
854 pColl = &rWrtSh.GetTxtFmtColl(j);
855 if(pColl->IsDefault())
856 continue;
858 const String& rName = pColl->GetName();
860 if(rName.Len() > 0)
862 SvLBoxEntry* pEntry = rTLB.First();
863 sal_Bool bFound = sal_False;
864 while(pEntry && !bFound)
866 if(rTLB.GetEntryText(pEntry) == rName)
867 bFound = sal_True;
868 pEntry = rTLB.Next(pEntry);
870 if(!bFound)
872 rTLB.InsertEntry(rName)->SetUserData((void*)USHRT_MAX);
876 rTLB.GetModel()->Resort();
879 /* -----------------13.07.99 15:39-------------------
881 --------------------------------------------------*/
882 SwAddStylesDlg_Impl::~SwAddStylesDlg_Impl()
885 /* -----------------13.07.99 15:39-------------------
887 --------------------------------------------------*/
888 IMPL_LINK(SwAddStylesDlg_Impl, OkHdl, OKButton*, EMPTYARG)
890 for(sal_uInt16 i = 0; i < MAXLEVEL; i++)
891 pStyleArr[i].Erase();
893 SwIndexTreeLB& rTLB = aHeaderTree.GetTreeListBox();
894 SvLBoxEntry* pEntry = rTLB.First();
895 while(pEntry)
897 long nLevel = (long)pEntry->GetUserData();
898 if(nLevel != USHRT_MAX)
900 String sName(rTLB.GetEntryText(pEntry));
901 if(pStyleArr[nLevel].Len())
902 pStyleArr[nLevel] += TOX_STYLE_DELIMITER;
903 pStyleArr[nLevel] += sName;
905 pEntry = rTLB.Next(pEntry);
908 //TODO write back style names
909 EndDialog(RET_OK);
910 return 0;
912 /* -----------------16.07.99 09:27-------------------
914 --------------------------------------------------*/
915 IMPL_LINK(SwAddStylesDlg_Impl, HeaderDragHdl, HeaderBar*, EMPTYARG)
917 aHeaderTree.GetTreeListBox().Invalidate();
918 return 0;
920 /* -----------------13.07.99 15:39-------------------
922 --------------------------------------------------*/
923 IMPL_LINK(SwAddStylesDlg_Impl, LeftRightHdl, PushButton*, pBtn)
925 sal_Bool bLeft = pBtn == &aLeftPB;
926 SvLBoxEntry* pEntry = aHeaderTree.GetTreeListBox().FirstSelected();
927 if(pEntry)
929 long nLevel = (long)pEntry->GetUserData();
930 if(bLeft)
932 if(!nLevel)
933 nLevel = USHRT_MAX;
934 else if(nLevel != USHRT_MAX)
935 nLevel--;
937 else
939 if(nLevel < MAXLEVEL - 1)
940 nLevel++;
941 else if(nLevel == USHRT_MAX)
942 nLevel = 0;
944 pEntry->SetUserData((void*)nLevel);
945 aHeaderTree.GetTreeListBox().Invalidate();
947 return 0;
950 /*-- 14.06.99 13:11:40---------------------------------------------------
952 -----------------------------------------------------------------------*/
953 SwTOXSelectTabPage::SwTOXSelectTabPage(Window* pParent, const SfxItemSet& rAttrSet) :
954 SfxTabPage(pParent, SW_RES(TP_TOX_SELECT), rAttrSet),
956 aTypeTitleFL( this, SW_RES(FL_TYPETITLE )),
957 aTitleFT( this, SW_RES(FT_TITLE )),
958 aTitleED( this, SW_RES(ED_TITLE )),
959 aTypeFT( this, SW_RES(FT_TYPE )),
960 aTypeLB( this, SW_RES(LB_TYPE )),
961 aReadOnlyCB( this, SW_RES(CB_READONLY )),
963 aAreaFL( this, SW_RES(FL_AREA )),
964 aAreaFT( this, SW_RES(FT_AREA )),
965 aAreaLB( this, SW_RES(LB_AREA )),
966 aLevelFT( this, SW_RES(FT_LEVEL )),
967 aLevelNF( this, SW_RES(NF_LEVEL )),
969 aCreateFromFL( this, SW_RES(FL_CREATEFROM )),
970 aFromHeadingsCB( this, SW_RES(CB_FROMHEADINGS )),
971 // aChapterDlgPB( this, SW_RES(PB_CHAPTERDLG )),//#outline level,removed by zhaojianwei
972 aAddStylesCB( this, SW_RES(CB_ADDSTYLES )),
973 aAddStylesPB( this, SW_RES(PB_ADDSTYLES )),
975 aFromTablesCB( this, SW_RES(CB_FROMTABLES )),
976 aFromFramesCB( this, SW_RES(CB_FROMFRAMES )),
977 aFromGraphicsCB( this, SW_RES(CB_FROMGRAPHICS )),
978 aFromOLECB( this, SW_RES(CB_FROMOLE )),
979 aLevelFromChapterCB(this, SW_RES(CB_LEVELFROMCHAPTER )),
981 aFromCaptionsRB( this, SW_RES(RB_FROMCAPTIONS )),
982 aFromObjectNamesRB( this, SW_RES(RB_FROMOBJECTNAMES )),
984 aCaptionSequenceFT( this, SW_RES(FT_CAPTIONSEQUENCE )),
985 aCaptionSequenceLB( this, SW_RES(LB_CAPTIONSEQUENCE )),
986 aDisplayTypeFT( this, SW_RES(FT_DISPLAYTYPE )),
987 aDisplayTypeLB( this, SW_RES(LB_DISPLAYTYPE )),
989 aTOXMarksCB( this, SW_RES(CB_TOXMARKS )),
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 aIdxOptionsFL( this, SW_RES(FL_IDXOPTIONS )),
1001 aFromNames( SW_RES(RES_SRCTYPES )),
1002 aFromObjCLB( this, SW_RES(CLB_FROMOBJ )),
1003 aFromObjFL( this, SW_RES(FL_FROMOBJ )),
1005 aSequenceCB( this, SW_RES(CB_SEQUENCE )),
1006 aBracketFT( this, SW_RES(FT_BRACKET )),
1007 aBracketLB( this, SW_RES(LB_BRACKET )),
1008 aAuthorityFormatFL( this, SW_RES(FL_AUTHORITY )),
1010 aSortOptionsFL( this, SW_RES(FL_SORTOPTIONS )),
1011 aLanguageFT( this, SW_RES(FT_LANGUAGE )),
1012 aLanguageLB( this, SW_RES(LB_LANGUAGE )),
1013 aSortAlgorithmFT( this, SW_RES(FT_SORTALG )),
1014 aSortAlgorithmLB( this, SW_RES(LB_SORTALG )),
1016 pIndexRes(0),
1018 sAutoMarkType(SW_RES(ST_AUTOMARK_TYPE)),
1019 sAddStyleUser(SW_RES(ST_USER_ADDSTYLE)),
1020 bFirstCall(sal_True)
1022 aBracketLB.InsertEntry(String(SW_RES(ST_NO_BRACKET)), 0);
1023 FreeResource();
1025 pIndexEntryWrapper = new IndexEntrySupplierWrapper();
1027 aLanguageLB.SetLanguageList( LANG_LIST_ALL | LANG_LIST_ONLY_KNOWN,
1028 FALSE, FALSE, FALSE );
1030 sAddStyleContent = aAddStylesCB.GetText();
1032 aCBLeftPos1 = aFromHeadingsCB.GetPosPixel();
1033 aCBLeftPos2 = aAddStylesCB.GetPosPixel();
1034 aCBLeftPos3 = aTOXMarksCB.GetPosPixel();
1036 ResStringArray& rNames = aFromNames.GetNames();
1037 for(sal_uInt16 i = 0; i < rNames.Count(); i++)
1039 aFromObjCLB.InsertEntry(rNames.GetString(i));
1040 aFromObjCLB.SetEntryData( i, (void*)rNames.GetValue(i) );
1042 aFromObjCLB.SetHelpId(HID_OLE_CHECKLB);
1044 SetExchangeSupport();
1045 aTypeLB.SetSelectHdl(LINK(this, SwTOXSelectTabPage, TOXTypeHdl));
1047 aAddStylesPB.SetClickHdl(LINK(this, SwTOXSelectTabPage, AddStylesHdl));
1048 //aChapterDlgPB.SetClickHdl(LINK(this, SwTOXSelectTabPage, ChapterHdl));//#outline level,removed by zhaojianwei
1050 PopupMenu* pMenu = aAutoMarkPB.GetPopupMenu();
1051 pMenu->SetActivateHdl(LINK(this, SwTOXSelectTabPage, MenuEnableHdl));
1052 pMenu->SetSelectHdl(LINK(this, SwTOXSelectTabPage, MenuExecuteHdl));
1054 Link aLk = LINK(this, SwTOXSelectTabPage, CheckBoxHdl);
1055 aAddStylesCB .SetClickHdl(aLk);
1056 aFromHeadingsCB .SetClickHdl(aLk);
1057 aTOXMarksCB .SetClickHdl(aLk);
1058 aFromFileCB .SetClickHdl(aLk);
1059 aCollectSameCB .SetClickHdl(aLk);
1060 aUseFFCB .SetClickHdl(aLk);
1061 aUseDashCB .SetClickHdl(aLk);
1062 aInitialCapsCB .SetClickHdl(aLk);
1063 aKeyAsEntryCB .SetClickHdl(aLk);
1065 Link aModifyLk = LINK(this, SwTOXSelectTabPage, ModifyHdl);
1066 aTitleED.SetModifyHdl(aModifyLk);
1067 aLevelNF.SetModifyHdl(aModifyLk);
1068 aSortAlgorithmLB.SetSelectHdl(aModifyLk);
1070 aLk = LINK(this, SwTOXSelectTabPage, RadioButtonHdl);
1071 aFromCaptionsRB.SetClickHdl(aLk);
1072 aFromObjectNamesRB.SetClickHdl(aLk);
1073 RadioButtonHdl(&aFromCaptionsRB);
1075 aLanguageLB.SetSelectHdl(LINK(this, SwTOXSelectTabPage, LanguageHdl));
1076 aTypeLB.SelectEntryPos(0);
1077 aTitleED.SaveValue();
1079 /*-- 14.06.99 13:11:41---------------------------------------------------
1081 -----------------------------------------------------------------------*/
1082 SwTOXSelectTabPage::~SwTOXSelectTabPage()
1084 delete pIndexRes;
1085 delete pIndexEntryWrapper;
1087 /* -----------------21.10.99 17:03-------------------
1089 --------------------------------------------------*/
1090 void SwTOXSelectTabPage::SetWrtShell(SwWrtShell& rSh)
1092 sal_uInt16 nUserTypeCount = rSh.GetTOXTypeCount(TOX_USER);
1093 if(nUserTypeCount > 1)
1095 //insert all new user indexes names after the standard user index
1096 sal_uInt16 nPos = aTypeLB.GetEntryPos((void*)(sal_uInt32)TO_USER);
1097 nPos++;
1098 for(sal_uInt16 nUser = 1; nUser < nUserTypeCount; nUser++)
1100 nPos = aTypeLB.InsertEntry(rSh.GetTOXType(TOX_USER, nUser)->GetTypeName(), nPos);
1101 sal_uInt32 nEntryData = nUser << 8;
1102 nEntryData |= TO_USER;
1103 aTypeLB.SetEntryData(nPos, (void*)nEntryData);
1107 /* -----------------14.06.99 13:10-------------------
1109 --------------------------------------------------*/
1110 sal_Bool SwTOXSelectTabPage::FillItemSet( SfxItemSet& )
1112 return sal_True;
1114 /* -----------------25.08.99 14:31-------------------
1116 --------------------------------------------------*/
1117 long lcl_TOXTypesToUserData(CurTOXType eType)
1119 sal_uInt16 nRet = TOX_INDEX;
1120 switch(eType.eType)
1122 case TOX_INDEX : nRet = TO_INDEX; break;
1123 case TOX_USER :
1125 nRet = eType.nIndex << 8;
1126 nRet |= TO_USER;
1128 break;
1129 case TOX_CONTENT : nRet = TO_CONTENT; break;
1130 case TOX_ILLUSTRATIONS:nRet = TO_ILLUSTRATION; break;
1131 case TOX_OBJECTS : nRet = TO_OBJECT; break;
1132 case TOX_TABLES : nRet = TO_TABLE; break;
1133 case TOX_AUTHORITIES : nRet = TO_AUTHORITIES; break;
1135 return nRet;
1137 //-----------------------------------------------------------------
1138 void SwTOXSelectTabPage::SelectType(TOXTypes eSet)
1140 CurTOXType eCurType (eSet, 0);
1142 long nData = lcl_TOXTypesToUserData(eCurType);
1143 aTypeLB.SelectEntryPos(aTypeLB.GetEntryPos((void*)nData));
1144 aTypeFT.Enable(sal_False);
1145 aTypeLB.Enable(sal_False);
1146 TOXTypeHdl(&aTypeLB);
1149 /*-- 14.06.99 13:10:45---------------------------------------------------
1151 -----------------------------------------------------------------------*/
1152 //-----------------------------------------------------------------
1153 CurTOXType lcl_UserData2TOXTypes(sal_uInt16 nData)
1155 CurTOXType eRet;
1157 switch(nData&0xff)
1159 case TO_INDEX : eRet.eType = TOX_INDEX; break;
1160 case TO_USER :
1162 eRet.eType = TOX_USER;
1163 eRet.nIndex = (nData&0xff00) >> 8;
1165 break;
1166 case TO_CONTENT : eRet.eType = TOX_CONTENT; break;
1167 case TO_ILLUSTRATION: eRet.eType = TOX_ILLUSTRATIONS; break;
1168 case TO_OBJECT : eRet.eType = TOX_OBJECTS; break;
1169 case TO_TABLE : eRet.eType = TOX_TABLES; break;
1170 case TO_AUTHORITIES : eRet.eType = TOX_AUTHORITIES; break;
1171 default: DBG_ERROR("what a type?");
1173 return eRet;
1175 /* -----------------02.09.99 08:16-------------------
1177 --------------------------------------------------*/
1178 void SwTOXSelectTabPage::ApplyTOXDescription()
1180 SwMultiTOXTabDialog* pTOXDlg = (SwMultiTOXTabDialog*)GetTabDialog();
1181 const CurTOXType aCurType = pTOXDlg->GetCurrentTOXType();
1182 SwTOXDescription& rDesc = pTOXDlg->GetTOXDescription(aCurType);
1183 aReadOnlyCB.Check(rDesc.IsReadonly());
1184 if(aTitleED.GetText() == aTitleED.GetSavedValue())
1186 if(rDesc.GetTitle())
1187 aTitleED.SetText(*rDesc.GetTitle());
1188 else
1189 aTitleED.SetText(aEmptyStr);
1190 aTitleED.SaveValue();
1193 aAreaLB.SelectEntryPos(rDesc.IsFromChapter() ? 1 : 0);
1195 if(aCurType.eType != TOX_INDEX)
1196 aLevelNF.SetValue(rDesc.GetLevel()); //content, user
1198 sal_uInt16 nCreateType = rDesc.GetContentOptions();
1200 //user + content
1201 sal_Bool bHasStyleNames = sal_False;
1202 sal_uInt16 i;
1204 for( i = 0; i < MAXLEVEL; i++)
1205 if(rDesc.GetStyleNames(i).Len())
1207 bHasStyleNames = sal_True;
1208 break;
1210 aAddStylesCB.Check(bHasStyleNames && (nCreateType & nsSwTOXElement::TOX_TEMPLATE));
1212 aFromOLECB. Check( 0 != (nCreateType & nsSwTOXElement::TOX_OLE) );
1213 aFromTablesCB. Check( 0 != (nCreateType & nsSwTOXElement::TOX_TABLE) );
1214 aFromGraphicsCB.Check( 0 != (nCreateType & nsSwTOXElement::TOX_GRAPHIC) );
1215 aFromFramesCB. Check( 0 != (nCreateType & nsSwTOXElement::TOX_FRAME) );
1217 aLevelFromChapterCB.Check(rDesc.IsLevelFromChapter());
1219 //all but illustration and table
1220 aTOXMarksCB.Check( 0 != (nCreateType & nsSwTOXElement::TOX_MARK) );
1222 //content
1223 if(TOX_CONTENT == aCurType.eType)
1225 aFromHeadingsCB.Check( 0 != (nCreateType & nsSwTOXElement::TOX_OUTLINELEVEL) );
1226 //aChapterDlgPB.Enable(aFromHeadingsCB.IsChecked());//#outline level,removed by zhaojianwei
1227 aAddStylesCB.SetText(sAddStyleContent);
1228 aAddStylesPB.Enable(aAddStylesCB.IsChecked());
1230 //index only
1231 else if(TOX_INDEX == aCurType.eType)
1233 sal_uInt16 nIndexOptions = rDesc.GetIndexOptions();
1234 aCollectSameCB. Check( 0 != (nIndexOptions & nsSwTOIOptions::TOI_SAME_ENTRY) );
1235 aUseFFCB. Check( 0 != (nIndexOptions & nsSwTOIOptions::TOI_FF) );
1236 aUseDashCB. Check( 0 != (nIndexOptions & nsSwTOIOptions::TOI_DASH) );
1237 if(aUseFFCB.IsChecked())
1238 aUseDashCB.Enable(sal_False);
1239 else if(aUseDashCB.IsChecked())
1240 aUseFFCB.Enable(sal_False);
1242 aCaseSensitiveCB. Check( 0 != (nIndexOptions & nsSwTOIOptions::TOI_CASE_SENSITIVE) );
1243 aInitialCapsCB. Check( 0 != (nIndexOptions & nsSwTOIOptions::TOI_INITIAL_CAPS) );
1244 aKeyAsEntryCB. Check( 0 != (nIndexOptions & nsSwTOIOptions::TOI_KEY_AS_ENTRY) );
1246 else if(TOX_ILLUSTRATIONS == aCurType.eType ||
1247 TOX_TABLES == aCurType.eType)
1249 aFromObjectNamesRB.Check(rDesc.IsCreateFromObjectNames());
1250 aFromCaptionsRB.Check(!rDesc.IsCreateFromObjectNames());
1251 aCaptionSequenceLB.SelectEntry(rDesc.GetSequenceName());
1252 aDisplayTypeLB.SelectEntryPos( static_cast< USHORT >(rDesc.GetCaptionDisplay()) );
1253 RadioButtonHdl(&aFromCaptionsRB);
1256 else if(TOX_OBJECTS == aCurType.eType)
1258 long nOLEData = rDesc.GetOLEOptions();
1259 for(sal_uInt16 nFromObj = 0; nFromObj < aFromObjCLB.GetEntryCount(); nFromObj++)
1261 long nData = (long)aFromObjCLB.GetEntryData(nFromObj);
1262 aFromObjCLB.CheckEntryPos(nFromObj, 0 != (nData & nOLEData));
1265 else if(TOX_AUTHORITIES == aCurType.eType)
1267 String sBrackets(rDesc.GetAuthBrackets());
1268 if(!sBrackets.Len() || sBrackets.EqualsAscii(" "))
1269 aBracketLB.SelectEntryPos(0);
1270 else
1271 aBracketLB.SelectEntry(sBrackets);
1272 aSequenceCB.Check(rDesc.IsAuthSequence());
1274 aAutoMarkPB.Enable(aFromFileCB.IsChecked());
1276 for(i = 0; i < MAXLEVEL; i++)
1277 aStyleArr[i] = rDesc.GetStyleNames(i);
1279 aLanguageLB.SelectLanguage(rDesc.GetLanguage());
1280 LanguageHdl(0);
1281 for( long nCnt = 0; nCnt < aSortAlgorithmLB.GetEntryCount(); ++nCnt )
1283 const String* pEntryData = (const String*)aSortAlgorithmLB.GetEntryData( (USHORT)nCnt );
1284 DBG_ASSERT(pEntryData, "no entry data available");
1285 if( pEntryData && *pEntryData == rDesc.GetSortAlgorithm())
1287 aSortAlgorithmLB.SelectEntryPos( (USHORT)nCnt );
1288 break;
1292 /* -----------------09.09.99 11:57-------------------
1294 --------------------------------------------------*/
1295 void SwTOXSelectTabPage::FillTOXDescription()
1297 SwMultiTOXTabDialog* pTOXDlg = (SwMultiTOXTabDialog*)GetTabDialog();
1298 CurTOXType aCurType = pTOXDlg->GetCurrentTOXType();
1299 SwTOXDescription& rDesc = pTOXDlg->GetTOXDescription(aCurType);
1300 rDesc.SetTitle(aTitleED.GetText());
1301 rDesc.SetFromChapter(1 == aAreaLB.GetSelectEntryPos());
1302 sal_uInt16 nContentOptions = 0;
1303 if(aTOXMarksCB.IsVisible() && aTOXMarksCB.IsChecked())
1304 nContentOptions |= nsSwTOXElement::TOX_MARK;
1306 sal_uInt16 nIndexOptions = rDesc.GetIndexOptions()&nsSwTOIOptions::TOI_ALPHA_DELIMITTER;
1307 switch(rDesc.GetTOXType())
1309 case TOX_CONTENT:
1310 if(aFromHeadingsCB.IsChecked())
1311 nContentOptions |= nsSwTOXElement::TOX_OUTLINELEVEL;
1312 break;
1313 case TOX_USER:
1315 rDesc.SetTOUName(aTypeLB.GetSelectEntry());
1317 if(aFromOLECB.IsChecked())
1318 nContentOptions |= nsSwTOXElement::TOX_OLE;
1319 if(aFromTablesCB.IsChecked())
1320 nContentOptions |= nsSwTOXElement::TOX_TABLE;
1321 if(aFromFramesCB.IsChecked())
1322 nContentOptions |= nsSwTOXElement::TOX_FRAME;
1323 if(aFromGraphicsCB.IsChecked())
1324 nContentOptions |= nsSwTOXElement::TOX_GRAPHIC;
1326 break;
1327 case TOX_INDEX:
1329 nContentOptions = nsSwTOXElement::TOX_MARK;
1331 if(aCollectSameCB.IsChecked())
1332 nIndexOptions |= nsSwTOIOptions::TOI_SAME_ENTRY;
1333 if(aUseFFCB.IsChecked())
1334 nIndexOptions |= nsSwTOIOptions::TOI_FF;
1335 if(aUseDashCB.IsChecked())
1336 nIndexOptions |= nsSwTOIOptions::TOI_DASH;
1337 if(aCaseSensitiveCB.IsChecked())
1338 nIndexOptions |= nsSwTOIOptions::TOI_CASE_SENSITIVE;
1339 if(aInitialCapsCB.IsChecked())
1340 nIndexOptions |= nsSwTOIOptions::TOI_INITIAL_CAPS;
1341 if(aKeyAsEntryCB.IsChecked())
1342 nIndexOptions |= nsSwTOIOptions::TOI_KEY_AS_ENTRY;
1343 if(aFromFileCB.IsChecked())
1344 rDesc.SetAutoMarkURL(sAutoMarkURL);
1345 else
1346 rDesc.SetAutoMarkURL(aEmptyStr);
1348 break;
1349 case TOX_ILLUSTRATIONS:
1350 case TOX_TABLES :
1351 rDesc.SetCreateFromObjectNames(aFromObjectNamesRB.IsChecked());
1352 rDesc.SetSequenceName(aCaptionSequenceLB.GetSelectEntry());
1353 rDesc.SetCaptionDisplay((SwCaptionDisplay)aDisplayTypeLB.GetSelectEntryPos());
1354 break;
1355 case TOX_OBJECTS:
1357 long nOLEData = 0;
1358 for(sal_uInt16 i = 0; i < aFromObjCLB.GetEntryCount(); i++)
1360 if(aFromObjCLB.IsChecked(i))
1362 long nData = (long)aFromObjCLB.GetEntryData(i);
1363 nOLEData |= nData;
1366 rDesc.SetOLEOptions((USHORT)nOLEData);
1368 break;
1369 case TOX_AUTHORITIES:
1371 if(aBracketLB.GetSelectEntryPos())
1372 rDesc.SetAuthBrackets(aBracketLB.GetSelectEntry());
1373 else
1374 rDesc.SetAuthBrackets(aEmptyStr);
1375 rDesc.SetAuthSequence(aSequenceCB.IsChecked());
1377 break;
1380 rDesc.SetLevelFromChapter( aLevelFromChapterCB.IsVisible() &&
1381 aLevelFromChapterCB.IsChecked());
1382 if(aTOXMarksCB.IsChecked() && aTOXMarksCB.IsVisible())
1383 nContentOptions |= nsSwTOXElement::TOX_MARK;
1384 if(aFromHeadingsCB.IsChecked() && aFromHeadingsCB.IsVisible())
1385 nContentOptions |= nsSwTOXElement::TOX_OUTLINELEVEL;
1386 if(aAddStylesCB.IsChecked() && aAddStylesCB.IsVisible())
1387 nContentOptions |= nsSwTOXElement::TOX_TEMPLATE;
1389 rDesc.SetContentOptions(nContentOptions);
1390 rDesc.SetIndexOptions(nIndexOptions);
1391 rDesc.SetLevel( static_cast< BYTE >(aLevelNF.GetValue()) );
1393 rDesc.SetReadonly(aReadOnlyCB.IsChecked());
1395 for(sal_uInt16 i = 0; i < MAXLEVEL; i++)
1396 rDesc.SetStyleNames(aStyleArr[i], i);
1398 rDesc.SetLanguage(aLanguageLB.GetSelectLanguage());
1399 const String* pEntryData = (const String*)aSortAlgorithmLB.GetEntryData(
1400 aSortAlgorithmLB.GetSelectEntryPos() );
1401 DBG_ASSERT(pEntryData, "no entry data available");
1402 if(pEntryData)
1403 rDesc.SetSortAlgorithm(*pEntryData);
1405 /* -----------------05.07.99 15:09-------------------
1407 --------------------------------------------------*/
1408 void SwTOXSelectTabPage::Reset( const SfxItemSet& )
1410 SwMultiTOXTabDialog* pTOXDlg = (SwMultiTOXTabDialog*)GetTabDialog();
1411 SwWrtShell& rSh = pTOXDlg->GetWrtShell();
1412 const CurTOXType aCurType = pTOXDlg->GetCurrentTOXType();
1413 long nData = lcl_TOXTypesToUserData(aCurType);
1414 aTypeLB.SelectEntryPos(aTypeLB.GetEntryPos((void*)nData));
1416 sAutoMarkURL = INetURLObject::decode( rSh.GetTOIAutoMarkURL(),
1417 INET_HEX_ESCAPE,
1418 INetURLObject::DECODE_UNAMBIGUOUS,
1419 RTL_TEXTENCODING_UTF8 );
1420 aFromFileCB.Check( 0 != sAutoMarkURL.Len() );
1422 aCaptionSequenceLB.Clear();
1423 sal_uInt16 i, nCount = rSh.GetFldTypeCount(RES_SETEXPFLD);
1424 for (i = 0; i < nCount; i++)
1426 SwFieldType *pType = rSh.GetFldType( i, RES_SETEXPFLD );
1427 if( pType->Which() == RES_SETEXPFLD &&
1428 ((SwSetExpFieldType *) pType)->GetType() & nsSwGetSetExpType::GSE_SEQ )
1429 aCaptionSequenceLB.InsertEntry(pType->GetName());
1432 if(pTOXDlg->IsTOXEditMode())
1434 aTypeFT.Enable(sal_False);
1435 aTypeLB.Enable(sal_False);
1437 TOXTypeHdl(&aTypeLB);
1438 CheckBoxHdl(&aAddStylesCB);
1440 /*-- 14.06.99 13:10:52---------------------------------------------------
1442 -----------------------------------------------------------------------*/
1443 void SwTOXSelectTabPage::ActivatePage( const SfxItemSet& )
1445 //nothing to do
1447 /*-- 14.06.99 13:11:00---------------------------------------------------
1449 -----------------------------------------------------------------------*/
1450 int SwTOXSelectTabPage::DeactivatePage( SfxItemSet* _pSet )
1452 if(_pSet)
1453 _pSet->Put(SfxUInt16Item(FN_PARAM_TOX_TYPE,
1454 (sal_uInt16)(long)aTypeLB.GetEntryData( aTypeLB.GetSelectEntryPos() )));
1455 FillTOXDescription();
1456 return LEAVE_PAGE;
1458 /* -----------------14.06.99 13:10-------------------
1460 --------------------------------------------------*/
1461 SfxTabPage* SwTOXSelectTabPage::Create( Window* pParent, const SfxItemSet& rAttrSet)
1463 return new SwTOXSelectTabPage(pParent, rAttrSet);
1465 /* -----------------14.06.99 13:10-------------------
1467 --------------------------------------------------*/
1468 IMPL_LINK(SwTOXSelectTabPage, TOXTypeHdl, ListBox*, pBox)
1470 SwMultiTOXTabDialog* pTOXDlg = (SwMultiTOXTabDialog*)GetTabDialog();
1471 if(!bFirstCall)
1473 // save current values into the proper TOXDescription
1474 FillTOXDescription();
1476 bFirstCall = sal_False;
1477 const sal_uInt16 nType = sal::static_int_cast< sal_uInt16 >(reinterpret_cast< sal_uIntPtr >(
1478 pBox->GetEntryData( pBox->GetSelectEntryPos() )));
1479 CurTOXType eCurType = lcl_UserData2TOXTypes(nType);
1480 pTOXDlg->SetCurrentTOXType(eCurType);
1482 aAreaLB.Show( 0 != (nType & (TO_CONTENT|TO_ILLUSTRATION|TO_USER|TO_INDEX|TO_TABLE|TO_OBJECT)) );
1483 aLevelFT.Show( 0 != (nType & (TO_CONTENT)) );
1484 aLevelNF.Show( 0 != (nType & (TO_CONTENT)) );
1485 aLevelFromChapterCB.Show( 0 != (nType & (TO_USER)) );
1486 aAreaFT.Show( 0 != (nType & (TO_CONTENT|TO_ILLUSTRATION|TO_USER|TO_INDEX|TO_TABLE|TO_OBJECT)) );
1487 aAreaFL.Show( 0 != (nType & (TO_CONTENT|TO_ILLUSTRATION|TO_USER|TO_INDEX|TO_TABLE|TO_OBJECT)) );
1489 aFromHeadingsCB.Show( 0 != (nType & (TO_CONTENT)) );
1490 // aChapterDlgPB.Show( 0 != (nType & (TO_CONTENT)) );//#outline level,removed by zhaojianwei
1491 aAddStylesCB.Show( 0 != (nType & (TO_CONTENT|TO_USER)) );
1492 aAddStylesPB.Show( 0 != (nType & (TO_CONTENT|TO_USER)) );
1494 aFromTablesCB.Show( 0 != (nType & (TO_USER)) );
1495 aFromFramesCB.Show( 0 != (nType & (TO_USER)) );
1496 aFromGraphicsCB.Show( 0 != (nType & (TO_USER)) );
1497 aFromOLECB.Show( 0 != (nType & (TO_USER)) );
1499 aFromCaptionsRB.Show( 0 != (nType & (TO_ILLUSTRATION|TO_TABLE)) );
1500 aFromObjectNamesRB.Show( 0 != (nType & (TO_ILLUSTRATION|TO_TABLE)) );
1502 aTOXMarksCB.Show( 0 != (nType & (TO_CONTENT|TO_USER)) );
1504 aCreateFromFL.Show( 0 != (nType & (TO_CONTENT|TO_ILLUSTRATION|TO_USER|TO_TABLE)) );
1505 aCaptionSequenceFT.Show( 0 != (nType & (TO_ILLUSTRATION|TO_TABLE)) );
1506 aCaptionSequenceLB.Show( 0 != (nType & (TO_ILLUSTRATION|TO_TABLE)) );
1507 aDisplayTypeFT.Show( 0 != (nType & (TO_ILLUSTRATION|TO_TABLE)) );
1508 aDisplayTypeLB.Show( 0 != (nType & (TO_ILLUSTRATION|TO_TABLE)) );
1510 aSequenceCB.Show( 0 != (nType & TO_AUTHORITIES) );
1511 aBracketFT.Show( 0 != (nType & TO_AUTHORITIES) );
1512 aBracketLB.Show( 0 != (nType & TO_AUTHORITIES) );
1513 aAuthorityFormatFL.Show( 0 != (nType & TO_AUTHORITIES) );
1515 sal_Bool bEnableSortLanguage = 0 != (nType & (TO_INDEX|TO_AUTHORITIES));
1516 aSortOptionsFL.Show(bEnableSortLanguage);
1517 aLanguageFT.Show(bEnableSortLanguage);
1518 aLanguageLB.Show(bEnableSortLanguage);
1519 aSortAlgorithmFT.Show(bEnableSortLanguage);
1520 aSortAlgorithmLB.Show(bEnableSortLanguage);
1522 //if(nType & TO_CONTENT) //#outline level,removed by zhaojianwei
1524 //Point aPos(aAddStylesPB.GetPosPixel());
1525 //aPos.X() = aChapterDlgPB.GetPosPixel().X();
1526 //aAddStylesPB.SetPosPixel(aPos);
1528 //else if( nType & TO_ILLUSTRATION )//<-removed end.
1529 if( nType & TO_ILLUSTRATION ) //add by zhaojianwei
1530 aCaptionSequenceLB.SelectEntry( SwStyleNameMapper::GetUIName(
1531 RES_POOLCOLL_LABEL_ABB, aEmptyStr ));
1532 else if( nType & TO_TABLE )
1533 aCaptionSequenceLB.SelectEntry( SwStyleNameMapper::GetUIName(
1534 RES_POOLCOLL_LABEL_TABLE, aEmptyStr ));
1535 else if( nType & TO_USER )
1537 aAddStylesCB.SetText(sAddStyleUser);
1538 // move left!
1539 Point aPos(aAddStylesPB.GetPosPixel());
1540 // aPos.X() = aChapterDlgPB.GetPosPixel().X();
1541 aPos.X() -= 2 * aAddStylesPB.GetSizePixel().Width();
1542 aAddStylesPB.SetPosPixel(aPos);
1545 aCollectSameCB.Show( 0 != (nType & TO_INDEX) );
1546 aUseFFCB.Show( 0 != (nType & TO_INDEX) );
1547 aUseDashCB.Show( 0 != (nType & TO_INDEX) );
1548 aCaseSensitiveCB.Show( 0 != (nType & TO_INDEX) );
1549 aInitialCapsCB.Show( 0 != (nType & TO_INDEX) );
1550 aKeyAsEntryCB.Show( 0 != (nType & TO_INDEX) );
1551 aFromFileCB.Show( 0 != (nType & TO_INDEX) );
1552 aAutoMarkPB.Show( 0 != (nType & TO_INDEX) );
1553 // aCreateAutoMarkPB.Show(nType &TO_INDEX);
1554 // aEditAutoMarkPB.Show(nType & TO_INDEX);
1556 aIdxOptionsFL.Show( 0 != (nType & TO_INDEX) );
1558 //object index
1559 aFromObjCLB.Show( 0 != (nType & TO_OBJECT) );
1560 aFromObjFL.Show( 0 != (nType & TO_OBJECT) );
1562 //move controls
1563 aAddStylesCB.SetPosPixel(nType & TO_USER ? aCBLeftPos1 : aCBLeftPos2);
1564 Point aPBPos(aAddStylesPB.GetPosPixel());
1565 aPBPos.Y() = nType & TO_USER ? aCBLeftPos1.Y() : aCBLeftPos2.Y();
1566 aAddStylesPB.SetPosPixel(aPBPos);
1567 aTOXMarksCB.SetPosPixel(nType & TO_USER ? aCBLeftPos2 : aCBLeftPos3);
1568 //set control values from the proper TOXDescription
1570 ApplyTOXDescription();
1572 ModifyHdl(0);
1573 return 0;
1575 /* -----------------30.11.99 12:48-------------------
1577 --------------------------------------------------*/
1578 IMPL_LINK(SwTOXSelectTabPage, ModifyHdl, void*, EMPTYARG)
1580 SwMultiTOXTabDialog* pTOXDlg = (SwMultiTOXTabDialog*)GetTabDialog();
1581 if(pTOXDlg)
1583 FillTOXDescription();
1584 pTOXDlg->CreateOrUpdateExample(pTOXDlg->GetCurrentTOXType().eType, TOX_PAGE_SELECT);
1586 return 0;
1588 /* -----------------05.07.99 10:13-------------------
1590 --------------------------------------------------*/
1591 IMPL_LINK(SwTOXSelectTabPage, CheckBoxHdl, CheckBox*, pBox )
1593 SwMultiTOXTabDialog* pTOXDlg = (SwMultiTOXTabDialog*)GetTabDialog();
1594 const CurTOXType aCurType = pTOXDlg->GetCurrentTOXType();
1595 if(TOX_CONTENT == aCurType.eType)
1597 //at least one of the three CheckBoxes must be checked
1598 if(!aAddStylesCB.IsChecked() && !aFromHeadingsCB.IsChecked() && !aTOXMarksCB.IsChecked())
1600 //TODO: InfoBox?
1601 pBox->Check(sal_True);
1603 aAddStylesPB.Enable(aAddStylesCB.IsChecked());
1604 //aChapterDlgPB.Enable(aFromHeadingsCB.IsChecked());//#outline level,removed by zhaojianwei
1606 if(TOX_USER == aCurType.eType)
1608 aAddStylesPB.Enable(aAddStylesCB.IsChecked());
1610 else if(TOX_INDEX == aCurType.eType)
1612 aAutoMarkPB.Enable(aFromFileCB.IsChecked());
1613 aUseFFCB.Enable(aCollectSameCB.IsChecked() && !aUseDashCB.IsChecked());
1614 aUseDashCB.Enable(aCollectSameCB.IsChecked() && !aUseFFCB.IsChecked());
1615 aCaseSensitiveCB.Enable(aCollectSameCB.IsChecked());
1617 ModifyHdl(0);
1618 return 0;
1620 /* -----------------14.07.99 14:21-------------------
1622 --------------------------------------------------*/
1623 IMPL_LINK(SwTOXSelectTabPage, RadioButtonHdl, RadioButton*, EMPTYARG )
1625 sal_Bool bEnable = aFromCaptionsRB.IsChecked();
1626 aCaptionSequenceFT.Enable(bEnable);
1627 aCaptionSequenceLB.Enable(bEnable);
1628 aDisplayTypeFT.Enable(bEnable);
1629 aDisplayTypeLB.Enable(bEnable);
1630 ModifyHdl(0);
1631 return 0;
1633 /* -----------------------------06.06.01 09:33--------------------------------
1635 ---------------------------------------------------------------------------*/
1636 IMPL_LINK(SwTOXSelectTabPage, LanguageHdl, ListBox*, pBox)
1638 Locale aLcl( SvxCreateLocale( aLanguageLB.GetSelectLanguage() ) );
1639 Sequence< OUString > aSeq = pIndexEntryWrapper->GetAlgorithmList( aLcl );
1641 if( !pIndexRes )
1642 pIndexRes = new IndexEntryRessource();
1644 String sOldString;
1645 void* pUserData;
1646 if( 0 != (pUserData = aSortAlgorithmLB.GetEntryData( aSortAlgorithmLB.GetSelectEntryPos())) )
1647 sOldString = *(String*)pUserData;
1648 void* pDel;
1649 USHORT nEnd = aSortAlgorithmLB.GetEntryCount();
1650 for( USHORT n = 0; n < nEnd; ++n )
1651 if( 0 != ( pDel = aSortAlgorithmLB.GetEntryData( n )) )
1652 delete (String*)pDel;
1653 aSortAlgorithmLB.Clear();
1655 USHORT nInsPos;
1656 String sAlg, sUINm;
1657 nEnd = static_cast< USHORT >(aSeq.getLength());
1658 for( USHORT nCnt = 0; nCnt < nEnd; ++nCnt )
1660 sUINm = pIndexRes->GetTranslation( sAlg = aSeq[ nCnt ] );
1661 nInsPos = aSortAlgorithmLB.InsertEntry( sUINm );
1662 aSortAlgorithmLB.SetEntryData( nInsPos, new String( sAlg ));
1663 if( sAlg == sOldString )
1664 aSortAlgorithmLB.SelectEntryPos( nInsPos );
1667 if( LISTBOX_ENTRY_NOTFOUND == aSortAlgorithmLB.GetSelectEntryPos() )
1668 aSortAlgorithmLB.SelectEntryPos( 0 );
1670 if(pBox)
1671 ModifyHdl(0);
1672 return 0;
1674 /* -----------------14.06.99 13:10-------------------
1676 --------------------------------------------------*/
1677 IMPL_LINK(SwTOXSelectTabPage, TOXAreaHdl, ListBox*, pBox)
1679 DBG_WARNING("not implemented");
1680 switch((long)pBox->GetEntryData( pBox->GetSelectEntryPos() ))
1682 case AREA_DOCUMENT : break;
1683 case AREA_CHAPTER : break;
1685 return 0;
1688 //#outline level, removed by zhaojianwei
1689 //It is no longer used!
1690 ///* -----------------14.06.99 13:10-------------------
1692 // --------------------------------------------------*/
1693 //IMPL_LINK(SwTOXSelectTabPage, ChapterHdl, PushButton*, pButton)
1695 // SwMultiTOXTabDialog* pTOXDlg = (SwMultiTOXTabDialog*)GetTabDialog();
1696 // SwWrtShell& rSh = pTOXDlg->GetWrtShell();
1698 // SfxItemSet aTmp(rSh.GetView().GetPool(), FN_PARAM_1, FN_PARAM_1);
1699 // SwOutlineTabDialog* pDlg = new SwOutlineTabDialog(pButton, &aTmp, rSh);
1701 // if(RET_OK == pDlg->Execute())
1702 // {
1703 // CurTOXType aCurType = pTOXDlg->GetCurrentTOXType();
1704 // SwForm* pForm = ((SwMultiTOXTabDialog*)GetTabDialog())->GetForm(aCurType);
1705 // // jetzt muss ueberprueft werden, ob dem sdbcx::Index Ueberschriftenvorlagen
1706 // // zugewiesen wurden
1707 // String sStr;
1708 // for(sal_uInt16 i = 0; i < MAXLEVEL; i++)
1709 // {
1710 // sal_Bool bNum = !SwMultiTOXTabDialog::IsNoNum(rSh, pForm->GetTemplate( i + 1 ));
1711 // if(bNum)
1712 // {
1713 // //es gibt getrennte Resourcebereiche fuer die Inhaltsverzeichnisse
1714 // if(i < 5)
1715 // SwStyleNameMapper::FillUIName( static_cast< sal_uInt16 >(RES_POOLCOLL_TOX_CNTNT1 + i), sStr );
1716 // else
1717 // SwStyleNameMapper::FillUIName( static_cast< sal_uInt16 >(RES_POOLCOLL_TOX_CNTNT6 + i - 5), sStr );
1718 // pForm->SetTemplate( i + 1, sStr );
1719 // }
1720 // }
1722 // }
1723 // delete pDlg;
1724 // return 0;
1726 /* -----------------14.06.99 13:10-------------------
1728 --------------------------------------------------*/
1729 IMPL_LINK(SwTOXSelectTabPage, AddStylesHdl, PushButton*, pButton)
1731 SwAddStylesDlg_Impl* pDlg = new SwAddStylesDlg_Impl(pButton,
1732 ((SwMultiTOXTabDialog*)GetTabDialog())->GetWrtShell(),
1733 aStyleArr);
1734 pDlg->Execute();
1735 delete pDlg;
1736 ModifyHdl(0);
1737 return 0;
1739 /* -----------------------------19.01.00 10:59--------------------------------
1741 ---------------------------------------------------------------------------*/
1743 IMPL_LINK(SwTOXSelectTabPage, MenuEnableHdl, Menu*, pMenu)
1745 pMenu->EnableItem(MN_AUTOMARK_EDIT, sAutoMarkURL.Len() > 0);
1746 return 0;
1749 IMPL_LINK(SwTOXSelectTabPage, MenuExecuteHdl, Menu*, pMenu)
1751 const String sSaveAutoMarkURL = sAutoMarkURL;
1752 switch(pMenu->GetCurItemId())
1754 case MN_AUTOMARK_OPEN:
1755 sAutoMarkURL = lcl_CreateAutoMarkFileDlg(
1756 sAutoMarkURL, sAutoMarkType, sal_True);
1757 break;
1758 case MN_AUTOMARK_NEW :
1759 sAutoMarkURL = lcl_CreateAutoMarkFileDlg(
1760 sAutoMarkURL, sAutoMarkType, sal_False);
1761 if( !sAutoMarkURL.Len() )
1762 break;
1763 //no break
1764 case MN_AUTOMARK_EDIT:
1766 sal_Bool bNew = pMenu->GetCurItemId()== MN_AUTOMARK_NEW;
1767 SwAutoMarkDlg_Impl* pAutoMarkDlg = new SwAutoMarkDlg_Impl(
1768 &aAutoMarkPB, sAutoMarkURL, sAutoMarkType, bNew );
1770 if( RET_OK != pAutoMarkDlg->Execute() && bNew )
1771 sAutoMarkURL = sSaveAutoMarkURL;
1772 delete pAutoMarkDlg;
1775 break;
1777 return 0;
1780 /* -----------------16.06.99 10:46-------------------
1782 --------------------------------------------------*/
1783 class SwTOXEdit : public Edit
1785 SwFormToken aFormToken;
1786 Link aPrevNextControlLink;
1787 sal_Bool bNextControl;
1788 SwTokenWindow* m_pParent;
1789 public:
1790 SwTOXEdit( Window* pParent, SwTokenWindow* pTokenWin,
1791 const SwFormToken& aToken)
1792 : Edit( pParent, WB_BORDER|WB_TABSTOP|WB_CENTER),
1793 aFormToken(aToken),
1794 bNextControl(sal_False),
1795 m_pParent( pTokenWin )
1797 SetHelpId( HID_TOX_ENTRY_EDIT );
1800 virtual void KeyInput( const KeyEvent& rKEvt );
1801 virtual void RequestHelp( const HelpEvent& rHEvt );
1803 sal_Bool IsNextControl() const {return bNextControl;}
1804 void SetPrevNextLink( const Link& rLink ) {aPrevNextControlLink = rLink;}
1806 const SwFormToken& GetFormToken()
1808 aFormToken.sText = GetText();
1809 return aFormToken;
1812 void SetCharStyleName(const String& rSet, sal_uInt16 nPoolId)
1814 aFormToken.sCharStyleName = rSet;
1815 aFormToken.nPoolId = nPoolId;
1818 void AdjustSize();
1821 //---------------------------------------------------
1822 void SwTOXEdit::RequestHelp( const HelpEvent& rHEvt )
1824 if(!m_pParent->CreateQuickHelp(this, aFormToken, rHEvt))
1825 Edit::RequestHelp(rHEvt);
1827 //---------------------------------------------------
1828 void SwTOXEdit::KeyInput( const KeyEvent& rKEvt )
1830 const Selection& rSel = GetSelection();
1831 sal_uInt16 nTextLen = GetText().Len();
1832 if(rSel.A() == rSel.B() &&
1833 !rSel.A() || rSel.A() == nTextLen )
1835 sal_Bool bCall = sal_False;
1836 KeyCode aCode = rKEvt.GetKeyCode();
1837 if(aCode.GetCode() == KEY_RIGHT && rSel.A() == nTextLen)
1839 bNextControl = sal_True;
1840 bCall = sal_True;
1842 else if(aCode.GetCode() == KEY_LEFT && !rSel.A() )
1844 bNextControl = sal_False;
1845 bCall = sal_True;
1848 if(bCall && aPrevNextControlLink.IsSet())
1849 aPrevNextControlLink.Call(this);
1852 Edit::KeyInput(rKEvt);
1854 /* -----------------16.07.99 12:41-------------------
1856 --------------------------------------------------*/
1857 void SwTOXEdit::AdjustSize()
1859 Size aSize(GetSizePixel());
1860 Size aTextSize(GetTextWidth(GetText()), GetTextHeight());
1861 aTextSize = LogicToPixel(aTextSize);
1862 aSize.Width() = aTextSize.Width() + EDIT_MINWIDTH;
1863 SetSizePixel(aSize);
1866 //---------------------------------------------------
1867 //---------------------------------------------------
1868 class SwTOXButton : public PushButton
1870 SwFormToken aFormToken;
1871 Link aPrevNextControlLink;
1872 sal_Bool bNextControl;
1873 SwTokenWindow* m_pParent;
1874 public:
1875 SwTOXButton( Window* pParent, SwTokenWindow* pTokenWin,
1876 const SwFormToken& rToken)
1877 : PushButton(pParent, WB_BORDER|WB_TABSTOP),
1878 aFormToken(rToken),
1879 bNextControl(sal_False),
1880 m_pParent(pTokenWin)
1882 SetHelpId(HID_TOX_ENTRY_BUTTON);
1885 virtual void KeyInput( const KeyEvent& rKEvt );
1886 virtual void RequestHelp( const HelpEvent& rHEvt );
1888 sal_Bool IsNextControl() const {return bNextControl;}
1889 void SetPrevNextLink(const Link& rLink) {aPrevNextControlLink = rLink;}
1890 const SwFormToken& GetFormToken() const {return aFormToken;}
1892 void SetCharStyleName(const String& rSet, sal_uInt16 nPoolId)
1894 aFormToken.sCharStyleName = rSet;
1895 aFormToken.nPoolId = nPoolId;
1898 void SetTabPosition(SwTwips nSet)
1899 { aFormToken.nTabStopPosition = nSet; }
1901 void SetFillChar( sal_Unicode cSet )
1902 { aFormToken.cTabFillChar = cSet; }
1904 void SetTabAlign(SvxTabAdjust eAlign)
1905 { aFormToken.eTabAlign = eAlign;}
1907 //---> i89791
1908 //used for entry number format, in TOC only
1909 //needed for different UI dialog position
1910 void SetEntryNumberFormat(sal_uInt16 nSet) {
1911 switch(nSet)
1913 default:
1914 case 0:
1915 aFormToken.nChapterFormat = CF_NUMBER;
1916 break;
1917 case 1:
1918 aFormToken.nChapterFormat = CF_NUM_NOPREPST_TITLE;
1919 break;
1923 void SetChapterInfo(sal_uInt16 nSet) {
1924 switch(nSet)
1926 default:
1927 case 0:
1928 aFormToken.nChapterFormat = CF_NUM_NOPREPST_TITLE;
1929 break;
1930 case 1:
1931 aFormToken.nChapterFormat = CF_TITLE;
1932 break;
1933 case 2:
1934 aFormToken.nChapterFormat = CF_NUMBER_NOPREPST;
1935 break;
1938 //<---
1939 sal_uInt16 GetChapterInfo() const{ return aFormToken.nChapterFormat;}
1941 void SetOutlineLevel( sal_uInt16 nSet ) { aFormToken.nOutlineLevel = nSet;}//i53420
1942 sal_uInt16 GetOutlineLevel() const{ return aFormToken.nOutlineLevel;}
1944 void SetLinkEnd()
1946 DBG_ASSERT(TOKEN_LINK_START == aFormToken.eTokenType,
1947 "call SetLinkEnd for link start only!");
1948 aFormToken.eTokenType = TOKEN_LINK_END;
1949 aFormToken.sText.AssignAscii(SwForm::aFormLinkEnd);
1950 SetText(aFormToken.sText);
1952 void SetLinkStart()
1954 DBG_ASSERT(TOKEN_LINK_END == aFormToken.eTokenType,
1955 "call SetLinkStart for link start only!");
1956 aFormToken.eTokenType = TOKEN_LINK_START;
1957 aFormToken.sText.AssignAscii(SwForm::aFormLinkStt);
1958 SetText(aFormToken.sText);
1962 //---------------------------------------------------
1963 void SwTOXButton::KeyInput( const KeyEvent& rKEvt )
1965 sal_Bool bCall = sal_False;
1966 KeyCode aCode = rKEvt.GetKeyCode();
1967 if(aCode.GetCode() == KEY_RIGHT)
1969 bNextControl = sal_True;
1970 bCall = sal_True;
1972 else if(aCode.GetCode() == KEY_LEFT )
1974 bNextControl = sal_False;
1975 bCall = sal_True;
1977 else if(aCode.GetCode() == KEY_DELETE)
1979 m_pParent->RemoveControl(this, sal_True);
1980 //this is invalid here
1981 return;
1983 if(bCall && aPrevNextControlLink.IsSet())
1984 aPrevNextControlLink.Call(this);
1985 else
1986 PushButton::KeyInput(rKEvt);
1988 //---------------------------------------------------
1989 void SwTOXButton::RequestHelp( const HelpEvent& rHEvt )
1991 if(!m_pParent->CreateQuickHelp(this, aFormToken, rHEvt))
1992 Button::RequestHelp(rHEvt);
1994 /* -----------------------------23.12.99 14:28--------------------------------
1996 ---------------------------------------------------------------------------*/
1997 SwIdxTreeListBox::SwIdxTreeListBox(SwTOXEntryTabPage* pPar, const ResId& rResId) :
1998 SvTreeListBox(pPar, rResId),
1999 pParent(pPar)
2002 /* -----------------------------23.12.99 14:19--------------------------------
2004 ---------------------------------------------------------------------------*/
2005 void SwIdxTreeListBox::RequestHelp( const HelpEvent& rHEvt )
2007 if( rHEvt.GetMode() & HELPMODE_QUICK )
2009 Point aPos( ScreenToOutputPixel( rHEvt.GetMousePosPixel() ));
2010 SvLBoxEntry* pEntry = GetEntry( aPos );
2011 if( pEntry )
2013 USHORT nLevel = static_cast< USHORT >(GetModel()->GetAbsPos(pEntry));
2014 String sEntry = pParent->GetLevelHelp(++nLevel);
2015 if('*' == sEntry)
2016 sEntry = GetEntryText(pEntry);
2017 if(sEntry.Len())
2019 SvLBoxTab* pTab;
2020 SvLBoxItem* pItem = GetItem( pEntry, aPos.X(), &pTab );
2021 if( pItem && SV_ITEM_ID_LBOXSTRING == pItem->IsA())
2023 aPos = GetEntryPosition( pEntry );
2025 aPos.X() = GetTabPos( pEntry, pTab );
2026 Size aSize( pItem->GetSize( this, pEntry ) );
2028 if((aPos.X() + aSize.Width()) > GetSizePixel().Width())
2029 aSize.Width() = GetSizePixel().Width() - aPos.X();
2031 aPos = OutputToScreenPixel(aPos);
2032 Rectangle aItemRect( aPos, aSize );
2033 Help::ShowQuickHelp( this, aItemRect, sEntry,
2034 QUICKHELP_LEFT|QUICKHELP_VCENTER );
2039 else
2040 SvTreeListBox::RequestHelp(rHEvt);
2042 //---------------------------------------------------
2043 SwTOXEntryTabPage::SwTOXEntryTabPage(Window* pParent, const SfxItemSet& rAttrSet) :
2044 SfxTabPage(pParent, SW_RES(TP_TOX_ENTRY), rAttrSet),
2045 aLevelFT(this, SW_RES(FT_LEVEL )),
2046 aLevelLB(this, SW_RES(LB_LEVEL )),
2048 aTokenFT(this, SW_RES(FT_TOKEN )),
2049 aTokenWIN(this, SW_RES(WIN_TOKEN )),
2050 aAllLevelsPB(this, SW_RES(PB_ALL_LEVELS )),
2052 aEntryNoPB(this, SW_RES(PB_ENTRYNO )),
2053 aEntryPB(this, SW_RES(PB_ENTRY )),
2054 aTabPB(this, SW_RES(PB_TAB )),
2055 aChapterInfoPB(this, SW_RES(PB_CHAPTERINFO )),
2056 aPageNoPB(this, SW_RES(PB_PAGENO )),
2057 aHyperLinkPB(this, SW_RES(PB_HYPERLINK )),
2059 aAuthFieldsLB(this, SW_RES(LB_AUTHFIELD )),
2060 aAuthInsertPB(this, SW_RES(PB_AUTHINSERT )),
2061 aAuthRemovePB(this, SW_RES(PB_AUTHREMOVE )),
2063 aCharStyleFT(this, SW_RES(FT_CHARSTYLE )),
2064 aCharStyleLB(this, SW_RES(LB_CHARSTYLE )),
2065 aEditStylePB(this, SW_RES(PB_EDITSTYLE )),
2067 aChapterEntryFT(this, SW_RES(FT_CHAPTERENTRY )),
2068 aChapterEntryLB(this, SW_RES(LB_CHAPTERENTRY )),
2070 aNumberFormatFT(this, SW_RES(FT_ENTRY_NO )),//i53420
2071 aNumberFormatLB(this, SW_RES(LB_ENTRY_NO )),
2072 aEntryOutlineLevelFT(this, SW_RES(FT_LEVEL_OL )),//i53420
2073 aEntryOutlineLevelNF(this, SW_RES(NF_LEVEL_OL )),
2075 aFillCharFT(this, SW_RES(FT_FILLCHAR )),
2076 aFillCharCB(this, SW_RES(CB_FILLCHAR )),
2077 aTabPosFT(this, SW_RES(FT_TABPOS )),
2078 aTabPosMF(this, SW_RES(MF_TABPOS )),
2079 aAutoRightCB(this, SW_RES(CB_AUTORIGHT )),
2080 aEntryFL(this, SW_RES(FL_ENTRY )),
2082 aRelToStyleCB(this, SW_RES(CB_RELTOSTYLE )),
2083 aMainEntryStyleFT(this, SW_RES(FT_MAIN_ENTRY_STYLE)),
2084 aMainEntryStyleLB(this, SW_RES(LB_MAIN_ENTRY_STYLE)),
2085 aAlphaDelimCB(this, SW_RES(CB_ALPHADELIM )),
2086 aCommaSeparatedCB(this, SW_RES(CB_COMMASEPARATED )),
2087 aFormatFL(this, SW_RES(FL_FORMAT )),
2089 aSortDocPosRB(this, SW_RES(RB_DOCPOS )),
2090 aSortContentRB(this, SW_RES(RB_SORTCONTENT )),
2091 aSortingFL(this, SW_RES(FL_SORTING )),
2093 aFirstKeyFT(this, SW_RES(FT_FIRSTKEY )),
2094 aFirstKeyLB(this, SW_RES(LB_FIRSTKEY )),
2095 aFirstSortUpRB(this, SW_RES(RB_SORTUP1 )),
2096 aFirstSortDownRB(this, SW_RES(RB_SORTDOWN1 )),
2098 aSecondKeyFT(this, SW_RES(FT_SECONDKEY )),
2099 aSecondKeyLB(this, SW_RES(LB_SECONDKEY )),
2100 aSecondSortUpRB(this, SW_RES(RB_SORTUP2 )),
2101 aSecondSortDownRB(this, SW_RES(RB_SORTDOWN2 )),
2103 aThirdKeyFT(this, SW_RES(FT_THIRDDKEY )),
2104 aThirdKeyLB(this, SW_RES(LB_THIRDKEY )),
2105 aThirdSortUpRB(this, SW_RES(RB_SORTUP3 )),
2106 aThirdSortDownRB(this, SW_RES(RB_SORTDOWN3 )),
2108 aSortKeyFL(this, SW_RES(FL_SORTKEY )),
2110 sDelimStr( SW_RES(STR_DELIM)),
2111 sAuthTypeStr( SW_RES(ST_AUTHTYPE)),
2113 sNoCharStyle( SW_RES(STR_NO_CHAR_STYLE)),
2114 sNoCharSortKey( SW_RES(STR_NOSORTKEY )),
2115 m_pCurrentForm(0),
2116 bInLevelHdl(sal_False)
2118 Image aSortUpHC(SW_RES(IMG_SORTUP_HC ));
2119 aFirstSortUpRB.SetModeRadioImage(aSortUpHC,BMP_COLOR_HIGHCONTRAST);
2120 aSecondSortUpRB.SetModeRadioImage(aSortUpHC,BMP_COLOR_HIGHCONTRAST);
2121 aThirdSortUpRB.SetModeRadioImage(aSortUpHC,BMP_COLOR_HIGHCONTRAST);
2123 Image aSortDownHC(SW_RES(IMG_SORTDOWN_HC ));
2124 aFirstSortDownRB.SetModeRadioImage(aSortDownHC,BMP_COLOR_HIGHCONTRAST);
2125 aSecondSortDownRB.SetModeRadioImage(aSortDownHC,BMP_COLOR_HIGHCONTRAST);
2126 aThirdSortDownRB.SetModeRadioImage(aSortDownHC,BMP_COLOR_HIGHCONTRAST);
2127 FreeResource();
2129 sLevelStr = aLevelFT.GetText();
2130 aLevelLB.SetWindowBits( WB_HSCROLL );
2131 aLevelLB.SetSpaceBetweenEntries(0);
2132 aLevelLB.SetSelectionMode( SINGLE_SELECTION );
2133 aLevelLB.SetHighlightRange(); // select full width
2134 aLevelLB.SetHelpId(HID_INSERT_INDEX_ENTRY_LEVEL_LB);
2135 aLevelLB.Show();
2137 aLastTOXType.eType = (TOXTypes)USHRT_MAX;
2138 aLastTOXType.nIndex = 0;
2139 //aLevelGBSize = aLevelGB.GetSizePixel();
2140 aLevelFLSize = aLevelFT.GetSizePixel();
2142 SetExchangeSupport();
2143 aEntryNoPB.SetClickHdl(LINK(this, SwTOXEntryTabPage, InsertTokenHdl));
2144 aEntryPB.SetClickHdl(LINK(this, SwTOXEntryTabPage, InsertTokenHdl));
2145 aChapterInfoPB.SetClickHdl(LINK(this, SwTOXEntryTabPage, InsertTokenHdl));
2146 aPageNoPB.SetClickHdl(LINK(this, SwTOXEntryTabPage, InsertTokenHdl));
2147 aTabPB.SetClickHdl(LINK(this, SwTOXEntryTabPage, InsertTokenHdl));
2148 aHyperLinkPB.SetClickHdl(LINK(this, SwTOXEntryTabPage, InsertTokenHdl));
2149 aEditStylePB.SetClickHdl(LINK(this, SwTOXEntryTabPage, EditStyleHdl));
2150 aLevelLB.SetSelectHdl(LINK(this, SwTOXEntryTabPage, LevelHdl));
2151 aTokenWIN.SetButtonSelectedHdl(LINK(this, SwTOXEntryTabPage, TokenSelectedHdl));
2152 aTokenWIN.SetModifyHdl(LINK(this, SwTOXEntryTabPage, ModifyHdl));
2153 aCharStyleLB.SetSelectHdl(LINK(this, SwTOXEntryTabPage, StyleSelectHdl));
2154 aCharStyleLB.InsertEntry(sNoCharStyle);
2155 aChapterEntryLB.SetSelectHdl(LINK(this, SwTOXEntryTabPage, ChapterInfoHdl));
2156 aEntryOutlineLevelNF.SetModifyHdl(LINK(this, SwTOXEntryTabPage, ChapterInfoOutlineHdl));
2157 aNumberFormatLB.SetSelectHdl(LINK(this, SwTOXEntryTabPage, NumberFormatHdl));
2159 aTabPosMF.SetModifyHdl(LINK(this, SwTOXEntryTabPage, TabPosHdl));
2160 aFillCharCB.SetModifyHdl(LINK(this, SwTOXEntryTabPage, FillCharHdl));
2161 aAutoRightCB.SetClickHdl(LINK(this, SwTOXEntryTabPage, AutoRightHdl));
2162 aAuthInsertPB.SetClickHdl(LINK(this, SwTOXEntryTabPage, RemoveInsertAuthHdl));
2163 aAuthRemovePB.SetClickHdl(LINK(this, SwTOXEntryTabPage, RemoveInsertAuthHdl));
2164 aSortDocPosRB.SetClickHdl(LINK(this, SwTOXEntryTabPage, SortKeyHdl));
2165 aSortContentRB.SetClickHdl(LINK(this, SwTOXEntryTabPage, SortKeyHdl));
2166 aAllLevelsPB.SetClickHdl(LINK(this, SwTOXEntryTabPage, AllLevelsHdl));
2168 aAlphaDelimCB.SetClickHdl(LINK(this, SwTOXEntryTabPage, ModifyHdl));
2169 aCommaSeparatedCB.SetClickHdl(LINK(this, SwTOXEntryTabPage, ModifyHdl));
2170 aRelToStyleCB.SetClickHdl(LINK(this, SwTOXEntryTabPage, ModifyHdl));
2172 FieldUnit aMetric = ::GetDfltMetric(FALSE);
2173 SetMetric(aTabPosMF, aMetric);
2175 aSortDocPosRB.Check();
2177 aFillCharCB.SetMaxTextLen(1);
2178 aFillCharCB.InsertEntry(' ');
2179 aFillCharCB.InsertEntry('.');
2180 aFillCharCB.InsertEntry('-');
2181 aFillCharCB.InsertEntry('_');
2183 aButtonPositions[0] = aEntryNoPB.GetPosPixel();
2184 aButtonPositions[1] = aEntryPB.GetPosPixel();
2185 aButtonPositions[2] = aChapterInfoPB.GetPosPixel();
2186 aButtonPositions[3] = aPageNoPB.GetPosPixel();
2187 aButtonPositions[4] = aTabPB.GetPosPixel();
2189 aRelToStylePos = aRelToStyleCB.GetPosPixel();
2190 aRelToStyleIdxPos = aCommaSeparatedCB.GetPosPixel();
2191 aRelToStyleIdxPos.Y() +=
2192 (aRelToStyleIdxPos.Y() - aAlphaDelimCB.GetPosPixel().Y());
2193 aEditStylePB.Enable(sal_False);
2195 //get position for Numbering and other stuff
2196 aChapterEntryFTPosition = aChapterEntryFT.GetPosPixel();
2197 aEntryOutlineLevelFTPosition = aEntryOutlineLevelFT.GetPosPixel();
2198 nBiasToEntryPoint = aEntryOutlineLevelNF.GetPosPixel().X() -
2199 aEntryOutlineLevelFT.GetPosPixel().X();
2201 //fill the types in
2202 USHORT i;
2203 for( i = 0; i < AUTH_FIELD_END; i++)
2205 String sTmp(SW_RES(STR_AUTH_FIELD_START + i));
2206 sal_uInt16 nPos = aAuthFieldsLB.InsertEntry(sTmp);
2207 aAuthFieldsLB.SetEntryData(nPos, reinterpret_cast< void * >(sal::static_int_cast< sal_uIntPtr >(i)));
2209 sal_uInt16 nPos = aFirstKeyLB.InsertEntry(sNoCharSortKey);
2210 aFirstKeyLB.SetEntryData(nPos, reinterpret_cast< void * >(sal::static_int_cast< sal_uIntPtr >(USHRT_MAX)));
2211 nPos = aSecondKeyLB.InsertEntry(sNoCharSortKey);
2212 aSecondKeyLB.SetEntryData(nPos, reinterpret_cast< void * >(sal::static_int_cast< sal_uIntPtr >(USHRT_MAX)));
2213 nPos = aThirdKeyLB.InsertEntry(sNoCharSortKey);
2214 aThirdKeyLB.SetEntryData(nPos, reinterpret_cast< void * >(sal::static_int_cast< sal_uIntPtr >(USHRT_MAX)));
2216 for( i = 0; i < AUTH_FIELD_END; i++)
2218 String sTmp(aAuthFieldsLB.GetEntry(i));
2219 void* pEntryData = aAuthFieldsLB.GetEntryData(i);
2220 nPos = aFirstKeyLB.InsertEntry(sTmp);
2221 aFirstKeyLB.SetEntryData(nPos, pEntryData);
2222 nPos = aSecondKeyLB.InsertEntry(sTmp);
2223 aSecondKeyLB.SetEntryData(nPos, pEntryData);
2224 nPos = aThirdKeyLB.InsertEntry(sTmp);
2225 aThirdKeyLB.SetEntryData(nPos, pEntryData);
2227 aFirstKeyLB.SelectEntryPos(0);
2228 aSecondKeyLB.SelectEntryPos(0);
2229 aThirdKeyLB.SelectEntryPos(0);
2231 /* -----------------30.11.99 13:37-------------------
2232 pVoid is used as signal to change all levels of the example
2233 --------------------------------------------------*/
2234 IMPL_LINK(SwTOXEntryTabPage, ModifyHdl, void*, pVoid)
2236 UpdateDescriptor();
2237 SwMultiTOXTabDialog* pTOXDlg = (SwMultiTOXTabDialog*)GetTabDialog();
2239 if(pTOXDlg)
2241 sal_uInt16 nCurLevel = static_cast< sal_uInt16 >(aLevelLB.GetModel()->GetAbsPos(aLevelLB.FirstSelected()) + 1);
2242 if(aLastTOXType.eType == TOX_CONTENT && pVoid)
2243 nCurLevel = USHRT_MAX;
2244 pTOXDlg->CreateOrUpdateExample(
2245 pTOXDlg->GetCurrentTOXType().eType, TOX_PAGE_ENTRY, nCurLevel);
2247 return 0;
2250 /*-- 16.06.99 10:47:33---------------------------------------------------
2252 -----------------------------------------------------------------------*/
2253 SwTOXEntryTabPage::~SwTOXEntryTabPage()
2256 /*-- 16.06.99 10:47:33---------------------------------------------------
2258 -----------------------------------------------------------------------*/
2259 sal_Bool SwTOXEntryTabPage::FillItemSet( SfxItemSet& )
2261 // nothing to do
2262 return sal_True;
2264 /*-- 16.06.99 10:47:34---------------------------------------------------
2266 -----------------------------------------------------------------------*/
2267 void SwTOXEntryTabPage::Reset( const SfxItemSet& )
2269 SwMultiTOXTabDialog* pTOXDlg = (SwMultiTOXTabDialog*)GetTabDialog();
2270 const CurTOXType aCurType = pTOXDlg->GetCurrentTOXType();
2271 m_pCurrentForm = pTOXDlg->GetForm(aCurType);
2272 if(TOX_INDEX == aCurType.eType)
2274 SwTOXDescription& rDesc = pTOXDlg->GetTOXDescription(aCurType);
2275 String sMainEntryCharStyle = rDesc.GetMainEntryCharStyle();
2276 if(sMainEntryCharStyle.Len())
2278 if( LISTBOX_ENTRY_NOTFOUND ==
2279 aMainEntryStyleLB.GetEntryPos(sMainEntryCharStyle))
2280 aMainEntryStyleLB.InsertEntry(
2281 sMainEntryCharStyle);
2282 aMainEntryStyleLB.SelectEntry(sMainEntryCharStyle);
2284 else
2285 aMainEntryStyleLB.SelectEntry(sNoCharStyle);
2286 aAlphaDelimCB.Check( 0 != (rDesc.GetIndexOptions() & nsSwTOIOptions::TOI_ALPHA_DELIMITTER) );
2288 aRelToStyleCB.Check(m_pCurrentForm->IsRelTabPos());
2289 aCommaSeparatedCB.Check(m_pCurrentForm->IsCommaSeparated());
2291 /*-- 16.06.99 10:47:34---------------------------------------------------
2293 -----------------------------------------------------------------------*/
2294 void lcl_ChgWidth(Window& rWin, long nDiff)
2296 Size aTempSz(rWin.GetSizePixel());
2297 aTempSz.Width() += nDiff;
2298 rWin.SetSizePixel(aTempSz);
2300 /* ----------------------------------------------------------------------
2302 -----------------------------------------------------------------------*/
2303 void lcl_ChgXPos(Window& rWin, long nDiff)
2305 Point aTempPos(rWin.GetPosPixel());
2306 aTempPos.X() += nDiff;
2307 rWin.SetPosPixel(aTempPos);
2309 /* ----------------------------------------------------------------------
2311 -----------------------------------------------------------------------*/
2312 void SwTOXEntryTabPage::ActivatePage( const SfxItemSet& /*rSet*/)
2314 SwMultiTOXTabDialog* pTOXDlg = (SwMultiTOXTabDialog*)GetTabDialog();
2315 const CurTOXType aCurType = pTOXDlg->GetCurrentTOXType();
2317 m_pCurrentForm = pTOXDlg->GetForm(aCurType);
2318 if( !( aLastTOXType == aCurType ))
2320 BOOL bToxIsAuthorities = TOX_AUTHORITIES == aCurType.eType;
2321 BOOL bToxIsIndex = TOX_INDEX == aCurType.eType;
2322 BOOL bToxIsContent = TOX_CONTENT == aCurType.eType;
2324 aLevelLB.Clear();
2325 for(sal_uInt16 i = 1; i < m_pCurrentForm->GetFormMax(); i++)
2327 if(bToxIsAuthorities)
2328 aLevelLB.InsertEntry( SwAuthorityFieldType::GetAuthTypeName(
2329 (ToxAuthorityType) (i - 1)) );
2330 else if( bToxIsIndex )
2332 if(i == 1)
2333 aLevelLB.InsertEntry( sDelimStr );
2334 else
2335 aLevelLB.InsertEntry( String::CreateFromInt32(i - 1) );
2337 else
2338 aLevelLB.InsertEntry(String::CreateFromInt32(i));
2340 if(bToxIsAuthorities)
2343 SwWrtShell& rSh = pTOXDlg->GetWrtShell();
2344 const SwAuthorityFieldType* pFType = (const SwAuthorityFieldType*)
2345 rSh.GetFldType(RES_AUTHORITY, aEmptyStr);
2346 if(pFType)
2348 if(pFType->IsSortByDocument())
2349 aSortDocPosRB.Check();
2350 else
2352 aSortContentRB.Check();
2353 sal_uInt16 nKeyCount = pFType->GetSortKeyCount();
2354 if(0 < nKeyCount)
2356 const SwTOXSortKey* pKey = pFType->GetSortKey(0);
2357 aFirstKeyLB.SelectEntryPos(
2358 aFirstKeyLB.GetEntryPos((void*)(sal_uInt32)pKey->eField));
2359 aFirstSortUpRB.Check(pKey->bSortAscending);
2360 aFirstSortDownRB.Check(!pKey->bSortAscending);
2362 if(1 < nKeyCount)
2364 const SwTOXSortKey* pKey = pFType->GetSortKey(1);
2365 aSecondKeyLB.SelectEntryPos(
2366 aSecondKeyLB.GetEntryPos((void*)(sal_uInt32)pKey->eField));
2367 aSecondSortUpRB.Check(pKey->bSortAscending);
2368 aSecondSortDownRB.Check(!pKey->bSortAscending);
2370 if(2 < nKeyCount)
2372 const SwTOXSortKey* pKey = pFType->GetSortKey(2);
2373 aThirdKeyLB.SelectEntryPos(
2374 aThirdKeyLB.GetEntryPos((void*)(sal_uInt32)pKey->eField));
2375 aThirdSortUpRB.Check(pKey->bSortAscending);
2376 aThirdSortDownRB.Check(!pKey->bSortAscending);
2380 SortKeyHdl(aSortDocPosRB.IsChecked() ? &aSortDocPosRB : &aSortContentRB);
2381 aLevelFT.SetText(sAuthTypeStr);
2383 else
2384 aLevelFT.SetText(sLevelStr);
2386 long nDiff = 0;
2387 if( bToxIsAuthorities ? aLevelFT.GetSizePixel() == aLevelFLSize
2388 : aLevelFT.GetSizePixel() != aLevelFLSize )
2390 nDiff = aLevelFLSize.Width();
2391 if( !bToxIsAuthorities )
2392 nDiff *= -1;
2395 if(nDiff)
2397 // lcl_ChgWidth(aLevelFL, nDiff);
2398 lcl_ChgWidth(aLevelFT, nDiff);
2399 lcl_ChgWidth(aLevelLB, nDiff);
2400 lcl_ChgXPos(aCharStyleFT, nDiff);
2401 lcl_ChgXPos(aCharStyleLB, nDiff);
2402 lcl_ChgWidth(aCharStyleLB, -nDiff);
2403 // lcl_ChgXPos(aEditStylePB, -nDiff);
2404 lcl_ChgXPos(aFillCharFT, nDiff);
2405 lcl_ChgXPos(aFillCharCB, nDiff);
2406 lcl_ChgXPos(aTabPosFT, nDiff);
2407 lcl_ChgXPos(aTabPosMF, nDiff);
2408 lcl_ChgXPos(aAutoRightCB, nDiff);
2409 lcl_ChgXPos(aAuthFieldsLB, nDiff);
2410 lcl_ChgXPos(aAuthInsertPB, nDiff);
2411 lcl_ChgXPos(aAuthRemovePB, nDiff);
2412 lcl_ChgXPos(aTokenFT, nDiff);
2413 lcl_ChgXPos(aTokenWIN, nDiff);
2414 lcl_ChgWidth(aTokenWIN, -nDiff);
2415 lcl_ChgXPos(aSortDocPosRB, nDiff);
2416 lcl_ChgXPos(aSortContentRB, nDiff);
2417 lcl_ChgXPos(aFormatFL, nDiff);
2418 lcl_ChgWidth(aFormatFL, -nDiff);
2419 lcl_ChgXPos(aSortingFL, nDiff);
2420 lcl_ChgWidth(aSortingFL, -nDiff);
2421 lcl_ChgXPos(aEntryFL, nDiff);
2422 lcl_ChgWidth(aEntryFL, -nDiff);
2424 lcl_ChgXPos(aFirstKeyFT, nDiff);
2425 lcl_ChgXPos(aFirstKeyLB, nDiff);
2426 lcl_ChgXPos(aSecondKeyFT, nDiff);
2427 lcl_ChgXPos(aSecondKeyLB, nDiff);
2428 lcl_ChgXPos(aThirdKeyFT, nDiff);
2429 lcl_ChgXPos(aThirdKeyLB, nDiff);
2430 lcl_ChgXPos(aSortKeyFL, nDiff);
2432 lcl_ChgWidth(aFirstKeyLB, -nDiff);
2433 lcl_ChgWidth(aSecondKeyLB, -nDiff);
2434 lcl_ChgWidth(aThirdKeyLB, -nDiff);
2435 lcl_ChgWidth(aSortKeyFL, -nDiff);
2437 Link aLink = aLevelLB.GetSelectHdl();
2438 aLevelLB.SetSelectHdl(Link());
2439 aLevelLB.Select( aLevelLB.GetEntry( bToxIsIndex ? 1 : 0 ) );
2440 aLevelLB.SetSelectHdl(aLink);
2442 // sort token buttons
2443 aEntryNoPB.SetPosPixel(aButtonPositions[0]);
2444 aEntryPB.SetPosPixel(aButtonPositions[ bToxIsContent ? 1 : 0]);
2445 aChapterInfoPB.SetPosPixel(aButtonPositions[2]);
2446 aPageNoPB.SetPosPixel(aButtonPositions[3]);
2447 sal_uInt16 nBtPos = 1;
2448 if( bToxIsContent )
2449 nBtPos = 2;
2450 else if( bToxIsAuthorities )
2451 nBtPos = 4;
2452 aTabPB.SetPosPixel(aButtonPositions[nBtPos]);
2453 aHyperLinkPB.SetPosPixel(aButtonPositions[4]);
2455 //show or hide controls
2456 aEntryNoPB.Show( bToxIsContent );
2457 aHyperLinkPB.Show( bToxIsContent );
2458 aRelToStyleCB.Show( !bToxIsAuthorities );
2459 aChapterInfoPB.Show( !bToxIsContent && !bToxIsAuthorities);
2460 aEntryPB.Show( !bToxIsAuthorities );
2461 aPageNoPB.Show( !bToxIsAuthorities );
2462 aAuthFieldsLB.Show( bToxIsAuthorities );
2463 aAuthInsertPB.Show( bToxIsAuthorities );
2464 aAuthRemovePB.Show( bToxIsAuthorities );
2465 aFormatFL.Show( !bToxIsAuthorities );
2466 aSortDocPosRB.Show( bToxIsAuthorities );
2467 aSortContentRB.Show( bToxIsAuthorities );
2468 aSortingFL.Show( bToxIsAuthorities );
2469 aFirstKeyFT.Show( bToxIsAuthorities );
2470 aFirstKeyLB.Show( bToxIsAuthorities );
2471 aSecondKeyFT.Show( bToxIsAuthorities );
2472 aSecondKeyLB.Show( bToxIsAuthorities );
2473 aThirdKeyFT.Show( bToxIsAuthorities );
2474 aThirdKeyLB.Show( bToxIsAuthorities );
2475 aSortKeyFL.Show( bToxIsAuthorities );
2476 aFirstSortUpRB.Show( bToxIsAuthorities );
2477 aFirstSortDownRB.Show( bToxIsAuthorities );
2478 aSecondSortUpRB.Show( bToxIsAuthorities );
2479 aSecondSortDownRB.Show( bToxIsAuthorities );
2480 aThirdSortUpRB.Show( bToxIsAuthorities );
2481 aThirdSortDownRB.Show( bToxIsAuthorities );
2483 aRelToStyleCB.SetPosPixel( bToxIsIndex ? aRelToStyleIdxPos
2484 : aRelToStylePos );
2486 // aRecalcTabCB.Show( aCurType.eType == TOX_CONTENT);
2488 aMainEntryStyleFT.Show( bToxIsIndex );
2489 aMainEntryStyleLB.Show( bToxIsIndex );
2490 aAlphaDelimCB.Show( bToxIsIndex );
2491 aCommaSeparatedCB.Show( bToxIsIndex );
2493 aLastTOXType = aCurType;
2495 //invalidate PatternWindow
2496 aTokenWIN.SetInvalid();
2497 LevelHdl(&aLevelLB);
2499 /* -----------------30.11.99 15:04-------------------
2501 --------------------------------------------------*/
2502 void SwTOXEntryTabPage::UpdateDescriptor()
2504 WriteBackLevel();
2505 SwMultiTOXTabDialog* pTOXDlg = (SwMultiTOXTabDialog*)GetTabDialog();
2506 SwTOXDescription& rDesc = pTOXDlg->GetTOXDescription(aLastTOXType);
2507 if(TOX_INDEX == aLastTOXType.eType)
2509 String sTemp(aMainEntryStyleLB.GetSelectEntry());
2510 rDesc.SetMainEntryCharStyle(sNoCharStyle == sTemp ? aEmptyStr : sTemp);
2511 sal_uInt16 nIdxOptions = rDesc.GetIndexOptions() & ~nsSwTOIOptions::TOI_ALPHA_DELIMITTER;
2512 if(aAlphaDelimCB.IsChecked())
2513 nIdxOptions |= nsSwTOIOptions::TOI_ALPHA_DELIMITTER;
2514 rDesc.SetIndexOptions(nIdxOptions);
2516 else if(TOX_AUTHORITIES == aLastTOXType.eType)
2518 rDesc.SetSortByDocument(aSortDocPosRB.IsChecked());
2519 SwTOXSortKey aKey1, aKey2, aKey3;
2520 aKey1.eField = (ToxAuthorityField)(sal_uIntPtr)aFirstKeyLB.GetEntryData(
2521 aFirstKeyLB.GetSelectEntryPos());
2522 aKey1.bSortAscending = aFirstSortUpRB.IsChecked();
2523 aKey2.eField = (ToxAuthorityField)(sal_uIntPtr)aSecondKeyLB.GetEntryData(
2524 aSecondKeyLB.GetSelectEntryPos());
2525 aKey2.bSortAscending = aSecondSortUpRB.IsChecked();
2526 aKey3.eField = (ToxAuthorityField)(sal_uIntPtr)aThirdKeyLB.GetEntryData(
2527 aThirdKeyLB.GetSelectEntryPos());
2528 aKey3.bSortAscending = aThirdSortUpRB.IsChecked();
2531 rDesc.SetSortKeys(aKey1, aKey2, aKey3);
2533 SwForm* pCurrentForm = pTOXDlg->GetForm(aLastTOXType);
2534 if(aRelToStyleCB.IsVisible())
2536 pCurrentForm->SetRelTabPos(aRelToStyleCB.IsChecked());
2538 if(aCommaSeparatedCB.IsVisible())
2539 pCurrentForm->SetCommaSeparated(aCommaSeparatedCB.IsChecked());
2541 /*-- 16.06.99 10:47:34---------------------------------------------------
2543 -----------------------------------------------------------------------*/
2544 int SwTOXEntryTabPage::DeactivatePage( SfxItemSet* /*pSet*/)
2546 UpdateDescriptor();
2547 return LEAVE_PAGE;
2549 /*-- 16.06.99 10:47:34---------------------------------------------------
2551 -----------------------------------------------------------------------*/
2552 SfxTabPage* SwTOXEntryTabPage::Create( Window* pParent, const SfxItemSet& rAttrSet)
2554 return new SwTOXEntryTabPage(pParent, rAttrSet);
2556 /*-- 16.06.99 10:47:35---------------------------------------------------
2558 -----------------------------------------------------------------------*/
2559 IMPL_LINK(SwTOXEntryTabPage, EditStyleHdl, PushButton*, pBtn)
2561 if( LISTBOX_ENTRY_NOTFOUND != aCharStyleLB.GetSelectEntryPos())
2563 SfxStringItem aStyle(SID_STYLE_EDIT, aCharStyleLB.GetSelectEntry());
2564 SfxUInt16Item aFamily(SID_STYLE_FAMILY, SFX_STYLE_FAMILY_CHAR);
2565 // TODO: WrtShell?
2566 // SwPtrItem aShell(FN_PARAM_WRTSHELL, pWrtShell);
2567 Window* pDefDlgParent = Application::GetDefDialogParent();
2568 Application::SetDefDialogParent( pBtn );
2569 ((SwMultiTOXTabDialog*)GetTabDialog())->GetWrtShell().
2570 GetView().GetViewFrame()->GetDispatcher()->Execute(
2571 SID_STYLE_EDIT, SFX_CALLMODE_SYNCHRON|SFX_CALLMODE_MODAL,
2572 &aStyle, &aFamily/*, &aShell*/, 0L);
2573 Application::SetDefDialogParent( pDefDlgParent );
2575 return 0;
2577 /* -----------------04.10.99 11:34-------------------
2579 --------------------------------------------------*/
2580 IMPL_LINK(SwTOXEntryTabPage, RemoveInsertAuthHdl, PushButton*, pButton)
2582 sal_Bool bInsert = pButton == &aAuthInsertPB;
2583 if(bInsert)
2585 sal_uInt16 nSelPos = aAuthFieldsLB.GetSelectEntryPos();
2586 String sToInsert(aAuthFieldsLB.GetSelectEntry());
2587 SwFormToken aInsert(TOKEN_AUTHORITY);
2588 aInsert.nAuthorityField = (sal_uInt16)(sal_uIntPtr)aAuthFieldsLB.GetEntryData(nSelPos);
2589 aTokenWIN.InsertAtSelection(String::CreateFromAscii(
2590 SwForm::aFormAuth), aInsert);
2591 aAuthFieldsLB.RemoveEntry(sToInsert);
2592 aAuthFieldsLB.SelectEntryPos( nSelPos ? nSelPos - 1 : 0);
2594 else
2596 Control* pCtrl = aTokenWIN.GetActiveControl();
2597 DBG_ASSERT(WINDOW_EDIT != pCtrl->GetType(), "Remove should be disabled");
2598 if( WINDOW_EDIT != pCtrl->GetType() )
2600 //fill it into the ListBox
2601 const SwFormToken& rToken = ((SwTOXButton*)pCtrl)->GetFormToken();
2602 PreTokenButtonRemoved(rToken);
2603 aTokenWIN.RemoveControl((SwTOXButton*)pCtrl);
2606 ModifyHdl(0);
2607 return 0;
2609 /* -----------------------------17.01.00 13:44--------------------------------
2611 ---------------------------------------------------------------------------*/
2612 void SwTOXEntryTabPage::PreTokenButtonRemoved(const SwFormToken& rToken)
2614 //fill it into the ListBox
2615 sal_uInt32 nData = rToken.nAuthorityField;
2616 String sTemp(SW_RES(STR_AUTH_FIELD_START + nData));
2617 sal_uInt16 nPos = aAuthFieldsLB.InsertEntry(sTemp);
2618 aAuthFieldsLB.SetEntryData(nPos, (void*)(nData));
2620 /*-- 16.06.99 10:47:35---------------------------------------------------
2622 This function inizializes the default value in the Token
2623 put here the UI dependent initializations
2624 -----------------------------------------------------------------------*/
2625 IMPL_LINK(SwTOXEntryTabPage, InsertTokenHdl, PushButton*, pBtn)
2627 String sText;
2628 FormTokenType eTokenType = TOKEN_ENTRY_NO;
2629 String sCharStyle;
2630 USHORT nChapterFormat = CF_NUMBER; // i89791
2631 if(pBtn == &aEntryNoPB)
2633 sText.AssignAscii(SwForm::aFormEntryNum);
2634 eTokenType = TOKEN_ENTRY_NO;
2636 else if(pBtn == &aEntryPB)
2638 if( TOX_CONTENT == m_pCurrentForm->GetTOXType() )
2640 sText.AssignAscii( SwForm::aFormEntryTxt );
2641 eTokenType = TOKEN_ENTRY_TEXT;
2643 else
2645 sText.AssignAscii( SwForm::aFormEntry);
2646 eTokenType = TOKEN_ENTRY;
2649 else if(pBtn == &aChapterInfoPB)
2651 sText.AssignAscii( SwForm::aFormChapterMark);
2652 eTokenType = TOKEN_CHAPTER_INFO;
2653 nChapterFormat = CF_NUM_NOPREPST_TITLE; // i89791
2655 else if(pBtn == &aPageNoPB)
2657 sText.AssignAscii(SwForm::aFormPageNums);
2658 eTokenType = TOKEN_PAGE_NUMS;
2660 else if(pBtn == &aHyperLinkPB)
2662 sText.AssignAscii(SwForm::aFormLinkStt);
2663 eTokenType = TOKEN_LINK_START;
2664 sCharStyle = String(SW_RES(STR_POOLCHR_INET_NORMAL));
2666 else if(pBtn == &aTabPB)
2668 sText.AssignAscii(SwForm::aFormTab);
2669 eTokenType = TOKEN_TAB_STOP;
2671 SwFormToken aInsert(eTokenType);
2672 aInsert.sCharStyleName = sCharStyle;
2673 aInsert.nTabStopPosition = 0;
2674 aInsert.nChapterFormat = nChapterFormat; // i89791
2675 aTokenWIN.InsertAtSelection(sText, aInsert);
2676 ModifyHdl(0);
2677 return 0;
2679 /* -----------------------------14.01.00 11:53--------------------------------
2681 ---------------------------------------------------------------------------*/
2682 IMPL_LINK(SwTOXEntryTabPage, AllLevelsHdl, PushButton*, EMPTYARG)
2684 //get current level
2685 //write it into all levels
2686 if(aTokenWIN.IsValid())
2688 String sNewToken = aTokenWIN.GetPattern();
2689 for(sal_uInt16 i = 1; i < m_pCurrentForm->GetFormMax(); i++)
2690 m_pCurrentForm->SetPattern(i, sNewToken);
2692 ModifyHdl(this);
2694 return 0;
2697 /* -----------------02.12.99 12:40-------------------
2699 --------------------------------------------------*/
2700 void SwTOXEntryTabPage::WriteBackLevel()
2702 if(aTokenWIN.IsValid())
2704 String sNewToken = aTokenWIN.GetPattern();
2705 sal_uInt16 nLastLevel = aTokenWIN.GetLastLevel();
2706 if(nLastLevel != USHRT_MAX)
2707 m_pCurrentForm->SetPattern(nLastLevel + 1, sNewToken );
2710 /*-- 16.06.99 10:47:35---------------------------------------------------
2712 -----------------------------------------------------------------------*/
2713 IMPL_LINK(SwTOXEntryTabPage, LevelHdl, SvTreeListBox*, pBox)
2715 if(bInLevelHdl)
2716 return 0;
2717 bInLevelHdl = sal_True;
2718 WriteBackLevel();
2720 sal_uInt16 nLevel = static_cast< sal_uInt16 >(pBox->GetModel()->GetAbsPos(pBox->FirstSelected()));
2721 aTokenWIN.SetForm(*m_pCurrentForm, nLevel);
2722 if(TOX_AUTHORITIES == m_pCurrentForm->GetTOXType())
2724 //fill the types in
2725 aAuthFieldsLB.Clear();
2726 for( sal_uInt32 i = 0; i < AUTH_FIELD_END; i++)
2728 String sTmp(SW_RES(STR_AUTH_FIELD_START + i));
2729 sal_uInt16 nPos = aAuthFieldsLB.InsertEntry(sTmp);
2730 aAuthFieldsLB.SetEntryData(nPos, (void*)(i));
2733 // #i21237#
2734 SwFormTokens aPattern = m_pCurrentForm->GetPattern(nLevel + 1);
2735 SwFormTokens::iterator aIt = aPattern.begin();;
2737 while(aIt != aPattern.end())
2739 SwFormToken aToken = *aIt; // #i21237#
2740 if(TOKEN_AUTHORITY == aToken.eTokenType)
2742 sal_uInt32 nSearch = aToken.nAuthorityField;
2743 sal_uInt16 nLstBoxPos = aAuthFieldsLB.GetEntryPos( (void*) nSearch );
2744 DBG_ASSERT(LISTBOX_ENTRY_NOTFOUND != nLstBoxPos, "Entry not found?");
2745 aAuthFieldsLB.RemoveEntry(nLstBoxPos);
2748 aIt++; // #i21237#
2750 aAuthFieldsLB.SelectEntryPos(0);
2752 bInLevelHdl = sal_False;
2753 pBox->GrabFocus();
2754 return 0;
2756 /* -----------------20.10.99 13:16-------------------
2758 --------------------------------------------------*/
2759 IMPL_LINK(SwTOXEntryTabPage, SortKeyHdl, RadioButton*, pButton)
2761 sal_Bool bEnable = &aSortContentRB == pButton;
2762 aFirstKeyFT.Enable(bEnable);
2763 aFirstKeyLB.Enable(bEnable);
2764 aSecondKeyFT.Enable(bEnable);
2765 aSecondKeyLB.Enable(bEnable);
2766 aThirdKeyFT.Enable(bEnable);
2767 aThirdKeyLB.Enable(bEnable);
2768 aSortKeyFL.Enable(bEnable);
2769 aFirstSortUpRB.Enable(bEnable);
2770 aFirstSortDownRB.Enable(bEnable);
2771 aSecondSortUpRB.Enable(bEnable);
2772 aSecondSortDownRB.Enable(bEnable);
2773 aThirdSortUpRB.Enable(bEnable);
2774 aThirdSortDownRB.Enable(bEnable);
2775 return 0;
2777 /* -----------------01.07.99 12:21-------------------
2779 --------------------------------------------------*/
2780 IMPL_LINK(SwTOXEntryTabPage, TokenSelectedHdl, SwFormToken*, pToken)
2782 if(pToken->sCharStyleName.Len())
2783 aCharStyleLB.SelectEntry(pToken->sCharStyleName);
2784 else
2785 aCharStyleLB.SelectEntry(sNoCharStyle);
2786 //StyleSelectHdl(&aCharStyleLB);
2788 String sEntry = aCharStyleLB.GetSelectEntry();
2789 aEditStylePB.Enable(sEntry != sNoCharStyle);
2791 if(pToken->eTokenType == TOKEN_CHAPTER_INFO)
2793 //---> i89791
2794 switch(pToken->nChapterFormat)
2796 default:
2797 aChapterEntryLB.SetNoSelection();//to alert the user
2798 break;
2799 case CF_NUM_NOPREPST_TITLE:
2800 aChapterEntryLB.SelectEntryPos(0);
2801 break;
2802 case CF_TITLE:
2803 aChapterEntryLB.SelectEntryPos(1);
2804 break;
2805 case CF_NUMBER_NOPREPST:
2806 aChapterEntryLB.SelectEntryPos(2);
2807 break;
2809 //<---
2810 //i53420
2811 //move into position the fixed text
2812 // aEntryOutlineLevelFT.SetPosPixel( aEntryOutlineLevelFTPosition );
2813 // // then the entry
2814 // Point aPoint;
2815 // aPoint.Y() = aEntryOutlineLevelFTPosition.Y();
2816 // aPoint.X() = aEntryOutlineLevelFTPosition.X() + nBiasToEntryPoint;
2817 // aEntryOutlineLevelNF.SetPosPixel( aPoint );
2819 aEntryOutlineLevelNF.SetValue(pToken->nOutlineLevel);
2822 //i53420
2823 if(pToken->eTokenType == TOKEN_ENTRY_NO)
2825 //move into position the fixed text
2826 // aEntryOutlineLevelFT.SetPosPixel( aChapterEntryFTPosition );
2827 // // then the entry
2828 // Point aPoint;
2829 // aPoint.Y() = aChapterEntryFTPosition.Y();
2830 // aPoint.X() = aChapterEntryFTPosition.X() + nBiasToEntryPoint;
2831 // aEntryOutlineLevelNF.SetPosPixel( aPoint );
2833 aEntryOutlineLevelNF.SetValue(pToken->nOutlineLevel);
2834 sal_uInt16 nFormat = 0;
2835 if( pToken->nChapterFormat == CF_NUM_NOPREPST_TITLE )
2836 nFormat = 1;
2837 aNumberFormatLB.SelectEntryPos(nFormat);
2840 sal_Bool bTabStop = TOKEN_TAB_STOP == pToken->eTokenType;
2841 aFillCharFT.Show(bTabStop);
2842 aFillCharCB.Show(bTabStop);
2843 aTabPosFT.Show(bTabStop);
2844 aTabPosMF.Show(bTabStop);
2845 aAutoRightCB.Show(bTabStop);
2846 aAutoRightCB.Enable(bTabStop);
2847 if(bTabStop)
2849 aTabPosMF.SetValue(aTabPosMF.Normalize(pToken->nTabStopPosition), FUNIT_TWIP);
2850 aAutoRightCB.Check(SVX_TAB_ADJUST_END == pToken->eTabAlign);
2851 aFillCharCB.SetText(pToken->cTabFillChar);
2852 aTabPosFT.Enable(!aAutoRightCB.IsChecked());
2853 aTabPosMF.Enable(!aAutoRightCB.IsChecked());
2855 else
2857 aTabPosMF.Enable(sal_False);
2860 sal_Bool bIsChapterInfo = pToken->eTokenType == TOKEN_CHAPTER_INFO;
2861 sal_Bool bIsEntryNumber = pToken->eTokenType == TOKEN_ENTRY_NO;
2862 aChapterEntryFT.Show( bIsChapterInfo );
2863 aChapterEntryLB.Show( bIsChapterInfo );
2864 aEntryOutlineLevelFT.Show( bIsChapterInfo || bIsEntryNumber );
2865 aEntryOutlineLevelNF.Show( bIsChapterInfo || bIsEntryNumber );
2866 aNumberFormatFT.Show( bIsEntryNumber );
2867 aNumberFormatLB.Show( bIsEntryNumber );
2870 //now enable the visible buttons
2871 //- inserting the same type of control is not allowed
2872 //- some types of controls can only appear once (EntryText EntryNumber)
2874 if(aEntryNoPB.IsVisible())
2876 aEntryNoPB.Enable(TOKEN_ENTRY_NO != pToken->eTokenType );
2878 if(aEntryPB.IsVisible())
2880 aEntryPB.Enable(TOKEN_ENTRY_TEXT != pToken->eTokenType &&
2881 !aTokenWIN.Contains(TOKEN_ENTRY_TEXT)
2882 && !aTokenWIN.Contains(TOKEN_ENTRY));
2885 if(aChapterInfoPB.IsVisible())
2887 aChapterInfoPB.Enable(TOKEN_CHAPTER_INFO != pToken->eTokenType);
2889 if(aPageNoPB.IsVisible())
2891 aPageNoPB.Enable(TOKEN_PAGE_NUMS != pToken->eTokenType &&
2892 !aTokenWIN.Contains(TOKEN_PAGE_NUMS));
2894 if(aTabPB.IsVisible())
2896 aTabPB.Enable(!bTabStop);
2898 if(aHyperLinkPB.IsVisible())
2900 aHyperLinkPB.Enable(TOKEN_LINK_START != pToken->eTokenType &&
2901 TOKEN_LINK_END != pToken->eTokenType);
2903 //table of authorities
2904 if(aAuthInsertPB.IsVisible())
2906 sal_Bool bText = TOKEN_TEXT == pToken->eTokenType;
2907 aAuthInsertPB.Enable(bText && aAuthFieldsLB.GetSelectEntry().Len());
2908 aAuthRemovePB.Enable(!bText);
2911 return 0;
2913 /* -----------------01.07.99 12:36-------------------
2915 --------------------------------------------------*/
2916 IMPL_LINK(SwTOXEntryTabPage, StyleSelectHdl, ListBox*, pBox)
2918 String sEntry = pBox->GetSelectEntry();
2919 sal_uInt16 nId = (sal_uInt16)(long)pBox->GetEntryData(pBox->GetSelectEntryPos());
2920 aEditStylePB.Enable(sEntry != sNoCharStyle);
2921 if(sEntry == sNoCharStyle)
2922 sEntry.Erase();
2923 Control* pCtrl = aTokenWIN.GetActiveControl();
2924 DBG_ASSERT(pCtrl, "no active control?");
2925 if(pCtrl)
2927 if(WINDOW_EDIT == pCtrl->GetType())
2928 ((SwTOXEdit*)pCtrl)->SetCharStyleName(sEntry, nId);
2929 else
2930 ((SwTOXButton*)pCtrl)->SetCharStyleName(sEntry, nId);
2933 ModifyHdl(0);
2934 return 0;
2936 /* -----------------------------11.01.00 12:54--------------------------------
2938 ---------------------------------------------------------------------------*/
2939 IMPL_LINK(SwTOXEntryTabPage, ChapterInfoHdl, ListBox*, pBox)
2941 sal_uInt16 nPos = pBox->GetSelectEntryPos();
2942 if(LISTBOX_ENTRY_NOTFOUND != nPos)
2944 Control* pCtrl = aTokenWIN.GetActiveControl();
2945 DBG_ASSERT(pCtrl, "no active control?");
2946 if(pCtrl && WINDOW_EDIT != pCtrl->GetType())
2947 ((SwTOXButton*)pCtrl)->SetChapterInfo(nPos);
2949 ModifyHdl(0);
2951 return 0;
2954 IMPL_LINK(SwTOXEntryTabPage, ChapterInfoOutlineHdl, NumericField*, pField)
2956 const sal_uInt16 nLevel = static_cast<BYTE>(pField->GetValue());
2958 Control* pCtrl = aTokenWIN.GetActiveControl();
2959 DBG_ASSERT(pCtrl, "no active control?");
2960 if(pCtrl && WINDOW_EDIT != pCtrl->GetType())
2961 ((SwTOXButton*)pCtrl)->SetOutlineLevel(nLevel);
2963 ModifyHdl(0);
2964 return 0;
2967 IMPL_LINK(SwTOXEntryTabPage, NumberFormatHdl, ListBox*, pBox)
2969 const sal_uInt16 nPos = pBox->GetSelectEntryPos();
2971 if(LISTBOX_ENTRY_NOTFOUND != nPos)
2973 Control* pCtrl = aTokenWIN.GetActiveControl();
2974 DBG_ASSERT(pCtrl, "no active control?");
2975 if(pCtrl && WINDOW_EDIT != pCtrl->GetType())
2977 ((SwTOXButton*)pCtrl)->SetEntryNumberFormat(nPos);//i89791
2979 ModifyHdl(0);
2981 return 0;
2984 /* -----------------19.08.99 15:37-------------------
2986 --------------------------------------------------*/
2987 IMPL_LINK(SwTOXEntryTabPage, TabPosHdl, MetricField*, pField)
2989 Control* pCtrl = aTokenWIN.GetActiveControl();
2990 DBG_ASSERT(pCtrl && WINDOW_EDIT != pCtrl->GetType() &&
2991 TOKEN_TAB_STOP == ((SwTOXButton*)pCtrl)->GetFormToken().eTokenType,
2992 "no active style::TabStop control?");
2993 if( pCtrl && WINDOW_EDIT != pCtrl->GetType() )
2995 ((SwTOXButton*)pCtrl)->SetTabPosition( static_cast< SwTwips >(
2996 pField->Denormalize( pField->GetValue( FUNIT_TWIP ))));
2998 ModifyHdl(0);
2999 return 0;
3001 /* -----------------09.09.99 15:37-------------------
3003 --------------------------------------------------*/
3004 IMPL_LINK(SwTOXEntryTabPage, FillCharHdl, ComboBox*, pBox)
3006 Control* pCtrl = aTokenWIN.GetActiveControl();
3007 DBG_ASSERT(pCtrl && WINDOW_EDIT != pCtrl->GetType() &&
3008 TOKEN_TAB_STOP == ((SwTOXButton*)pCtrl)->GetFormToken().eTokenType,
3009 "no active style::TabStop control?");
3010 if(pCtrl && WINDOW_EDIT != pCtrl->GetType())
3012 sal_Unicode cSet;
3013 if( pBox->GetText().Len() )
3014 cSet = pBox->GetText().GetChar(0);
3015 else
3016 cSet = ' ';
3017 ((SwTOXButton*)pCtrl)->SetFillChar( cSet );
3019 ModifyHdl(0);
3020 return 0;
3023 /*-- 16.06.99 10:47:36---------------------------------------------------
3025 -----------------------------------------------------------------------*/
3026 IMPL_LINK(SwTOXEntryTabPage, AutoRightHdl, CheckBox*, pBox)
3028 //the most right style::TabStop is usually right aligned
3029 Control* pCurCtrl = aTokenWIN.GetActiveControl();
3030 DBG_ASSERT(WINDOW_EDIT != pCurCtrl->GetType() &&
3031 ((SwTOXButton*)pCurCtrl)->GetFormToken().eTokenType == TOKEN_TAB_STOP,
3032 "no style::TabStop selected!");
3034 const SwFormToken& rToken = ((SwTOXButton*)pCurCtrl)->GetFormToken();
3035 sal_Bool bChecked = pBox->IsChecked();
3036 if(rToken.eTokenType == TOKEN_TAB_STOP)
3037 ((SwTOXButton*)pCurCtrl)->SetTabAlign(
3038 bChecked ? SVX_TAB_ADJUST_END : SVX_TAB_ADJUST_LEFT);
3039 aTabPosFT.Enable(!bChecked);
3040 aTabPosMF.Enable(!bChecked);
3041 ModifyHdl(0);
3042 return 0;
3044 /* -----------------16.06.99 11:00-------------------
3046 --------------------------------------------------*/
3047 void SwTOXEntryTabPage::SetWrtShell(SwWrtShell& rSh)
3049 SwDocShell* pDocSh = rSh.GetView().GetDocShell();
3050 ::FillCharStyleListBox(aCharStyleLB, pDocSh, TRUE, TRUE);
3051 const String sDefault(SW_RES(STR_POOLCOLL_STANDARD));
3052 for(sal_uInt16 i = 0; i < aCharStyleLB.GetEntryCount(); i++)
3054 String sEntry = aCharStyleLB.GetEntry(i);
3055 if(sDefault != sEntry)
3057 aMainEntryStyleLB.InsertEntry( sEntry );
3058 aMainEntryStyleLB.SetEntryData(i, aCharStyleLB.GetEntryData(i));
3061 aMainEntryStyleLB.SelectEntry( SwStyleNameMapper::GetUIName(
3062 RES_POOLCHR_IDX_MAIN_ENTRY, aEmptyStr ));
3064 /* -----------------------------23.12.99 14:23--------------------------------
3066 ---------------------------------------------------------------------------*/
3067 String SwTOXEntryTabPage::GetLevelHelp(sal_uInt16 nLevel) const
3069 String sRet;
3070 SwMultiTOXTabDialog* pTOXDlg = (SwMultiTOXTabDialog*)GetTabDialog();
3071 const CurTOXType aCurType = pTOXDlg->GetCurrentTOXType();
3072 if( TOX_INDEX == aCurType.eType )
3073 SwStyleNameMapper::FillUIName( static_cast< sal_uInt16 >(1 == nLevel ? RES_POOLCOLL_TOX_IDXBREAK
3074 : RES_POOLCOLL_TOX_IDX1 + nLevel-2), sRet );
3076 else if( TOX_AUTHORITIES == aCurType.eType )
3078 //wildcard -> show entry text
3079 sRet = '*';
3081 return sRet;
3083 /* -----------------16.06.99 15:18-------------------
3085 --------------------------------------------------*/
3087 SwTokenWindow::SwTokenWindow(SwTOXEntryTabPage* pParent, const ResId& rResId) :
3088 Window( pParent, rResId ),
3089 aLeftScrollWin(this, ResId(WIN_LEFT_SCROLL, *rResId.GetResMgr() )),
3090 aCtrlParentWin(this, ResId(WIN_CTRL_PARENT, *rResId.GetResMgr() )),
3091 aRightScrollWin(this, ResId(WIN_RIGHT_SCROLL, *rResId.GetResMgr() )),
3092 pForm(0),
3093 nLevel(0),
3094 bValid(sal_False),
3095 sCharStyle(ResId(STR_CHARSTYLE, *rResId.GetResMgr())),
3096 pActiveCtrl(0),
3097 m_pParent(pParent)
3099 SetStyle(GetStyle()|WB_TABSTOP|WB_DIALOGCONTROL);
3100 SetHelpId(HID_TOKEN_WINDOW);
3101 for(sal_uInt16 i = 0; i < TOKEN_END; i++)
3103 sal_uInt16 nTextId = STR_BUTTON_TEXT_START + i;
3104 if( STR_TOKEN_ENTRY_TEXT == nTextId )
3105 nTextId = STR_TOKEN_ENTRY;
3106 aButtonTexts[i] = String(ResId(nTextId, *rResId.GetResMgr()));
3108 sal_uInt16 nHelpId = STR_BUTTON_HELP_TEXT_START + i;
3109 if(STR_TOKEN_HELP_ENTRY_TEXT == nHelpId)
3110 nHelpId = STR_TOKEN_HELP_ENTRY;
3111 aButtonHelpTexts[i] = String(ResId(nHelpId, *rResId.GetResMgr()));
3114 FreeResource();
3116 Link aLink(LINK(this, SwTokenWindow, ScrollHdl));
3117 aLeftScrollWin.SetClickHdl(aLink);
3118 aRightScrollWin.SetClickHdl(aLink);
3120 /* -----------------01.07.99 12:17-------------------
3122 --------------------------------------------------*/
3123 SwTokenWindow::~SwTokenWindow()
3125 // for(sal_uInt16 i = GetItemCount(); i ; i--)
3126 // RemoveItem(i - 1);
3128 for( sal_uInt32 n = 0; n < aControlList.Count(); ++n )
3130 Control* pControl = aControlList.GetObject( n );
3131 pControl->SetGetFocusHdl( Link() );
3132 pControl->SetLoseFocusHdl( Link() );
3135 for( ULONG i = aControlList.Count(); i; )
3137 Control* pControl = aControlList.Remove( --i );
3138 delete pControl;
3141 /* -----------------16.06.99 13:56-------------------
3143 --------------------------------------------------*/
3144 void SwTokenWindow::SetForm(SwForm& rForm, sal_uInt16 nL)
3146 SetActiveControl(0);
3147 bValid = sal_True;
3148 if(pForm)
3150 //apply current level settings to the form
3151 for( ULONG i = aControlList.Count(); i; )
3153 Control* pControl = aControlList.Remove( --i );
3154 delete pControl;
3157 nLevel = nL;
3158 pForm = &rForm;
3159 //now the display
3160 if(nLevel < MAXLEVEL || rForm.GetTOXType() == TOX_AUTHORITIES)
3162 Size aToolBoxSize = GetSizePixel();
3164 // #i21237#
3165 SwFormTokens aPattern = pForm->GetPattern(nLevel + 1);
3166 SwFormTokens::iterator aIt = aPattern.begin();
3167 sal_Bool bLastWasText = sal_False; //assure alternating text - code - text
3169 Control* pSetActiveControl = 0;
3170 while(aIt != aPattern.end()) // #i21237#
3172 SwFormToken aToken(*aIt); // #i21237#
3174 if(TOKEN_TEXT == aToken.eTokenType)
3176 DBG_ASSERT(!bLastWasText, "text following text is invalid");
3177 Control* pCtrl = InsertItem(aToken.sText, aToken);
3178 bLastWasText = sal_True;
3179 if(!GetActiveControl())
3180 SetActiveControl(pCtrl);
3182 else
3184 if( !bLastWasText )
3186 bLastWasText = sal_True;
3187 SwFormToken aTemp(TOKEN_TEXT);
3188 Control* pCtrl = InsertItem(aEmptyStr, aTemp);
3189 if(!pSetActiveControl)
3190 pSetActiveControl = pCtrl;
3192 const sal_Char* pTmp = 0;
3193 switch( aToken.eTokenType )
3195 case TOKEN_ENTRY_NO: pTmp = SwForm::aFormEntryNum; break;
3196 case TOKEN_ENTRY_TEXT: pTmp = SwForm::aFormEntryTxt; break;
3197 case TOKEN_ENTRY: pTmp = SwForm::aFormEntry; break;
3198 case TOKEN_TAB_STOP: pTmp = SwForm::aFormTab; break;
3199 case TOKEN_PAGE_NUMS: pTmp = SwForm::aFormPageNums; break;
3200 case TOKEN_CHAPTER_INFO:pTmp = SwForm::aFormChapterMark; break;
3201 case TOKEN_LINK_START: pTmp = SwForm::aFormLinkStt; break;
3202 case TOKEN_LINK_END: pTmp = SwForm::aFormLinkEnd; break;
3203 case TOKEN_AUTHORITY: pTmp = SwForm::aFormAuth; break;
3204 default:; //prevent warning
3207 InsertItem( pTmp ? String::CreateFromAscii(pTmp)
3208 : aEmptyStr, aToken );
3209 bLastWasText = sal_False;
3212 aIt++; // #i21237#
3214 if(!bLastWasText)
3216 bLastWasText = sal_True;
3217 SwFormToken aTemp(TOKEN_TEXT);
3218 Control* pCtrl = InsertItem(aEmptyStr, aTemp);
3219 if(!pSetActiveControl)
3220 pSetActiveControl = pCtrl;
3222 SetActiveControl(pSetActiveControl);
3224 AdjustScrolling();
3226 /* -----------------19.08.99 13:00-------------------
3228 --------------------------------------------------*/
3229 void SwTokenWindow::SetActiveControl(Control* pSet)
3231 if( pSet != pActiveCtrl )
3233 pActiveCtrl = pSet;
3234 if( pActiveCtrl )
3236 pActiveCtrl->GrabFocus();
3237 //it must be a SwTOXEdit
3238 const SwFormToken* pFToken;
3239 if( WINDOW_EDIT == pActiveCtrl->GetType() )
3240 pFToken = &((SwTOXEdit*)pActiveCtrl)->GetFormToken();
3241 else
3242 pFToken = &((SwTOXButton*)pActiveCtrl)->GetFormToken();
3244 SwFormToken aTemp( *pFToken );
3245 aButtonSelectedHdl.Call( &aTemp );
3250 /* -----------------17.06.99 09:53-------------------
3252 --------------------------------------------------*/
3253 Control* SwTokenWindow::InsertItem(const String& rText, const SwFormToken& rToken)
3255 Control* pRet = 0;
3256 Control* pLast = aControlList.Last();
3257 Size aControlSize(GetOutputSizePixel());
3258 Point aControlPos;
3259 if( pLast )
3261 aControlSize = pLast->GetSizePixel();
3262 aControlPos = pLast->GetPosPixel();
3263 aControlPos.X() += aControlSize.Width();
3265 if(TOKEN_TEXT == rToken.eTokenType)
3267 SwTOXEdit* pEdit = new SwTOXEdit(&aCtrlParentWin, this, rToken);
3268 pEdit->SetPosPixel(aControlPos);
3269 aControlList.Insert(pEdit, aControlList.Count());
3270 pEdit->SetText(rText);
3271 Size aEditSize(aControlSize);
3272 aEditSize.Width() = pEdit->GetTextWidth(rText) + EDIT_MINWIDTH;
3273 pEdit->SetSizePixel(aEditSize);
3274 pEdit->SetModifyHdl(LINK(this, SwTokenWindow, EditResize ));
3275 pEdit->SetPrevNextLink(LINK(this, SwTokenWindow, NextItemHdl));
3276 pEdit->SetGetFocusHdl(LINK(this, SwTokenWindow, TbxFocusHdl));
3277 pEdit->Show();
3278 pRet = pEdit;
3280 else
3282 SwTOXButton* pButton = new SwTOXButton(&aCtrlParentWin, this, rToken);
3283 pButton->SetPosPixel(aControlPos);
3284 aControlList.Insert(pButton, aControlList.Count());
3285 Size aEditSize(aControlSize);
3286 aEditSize.Width() = pButton->GetTextWidth(rText) + 5;
3287 // pButton->SetControlBackground(aCtrlColor);
3288 // pButton->SetControlForeground(aTextColor);
3289 pButton->SetSizePixel(aEditSize);
3290 pButton->SetPrevNextLink(LINK(this, SwTokenWindow, NextItemBtnHdl));
3291 pButton->SetGetFocusHdl(LINK(this, SwTokenWindow, TbxFocusBtnHdl));
3292 if(TOKEN_AUTHORITY != rToken.eTokenType)
3293 pButton->SetText(aButtonTexts[rToken.eTokenType]);
3294 else
3296 //use the first two chars as symbol
3297 String sTmp(SwAuthorityFieldType::GetAuthFieldName(
3298 (ToxAuthorityField)rToken.nAuthorityField));
3299 pButton->SetText(sTmp.Copy(0, 2));
3301 pButton->Show();
3302 pRet = pButton;
3304 return pRet;
3306 /* -----------------16.07.99 11:50-------------------
3308 --------------------------------------------------*/
3309 void SwTokenWindow::InsertAtSelection(
3310 const String& rText,
3311 const SwFormToken& rToken)
3313 DBG_ASSERT(pActiveCtrl, "no active control!");
3314 if(!pActiveCtrl)
3315 return;
3316 SwFormToken aToInsertToken(rToken);
3317 if(TOKEN_LINK_START == aToInsertToken.eTokenType)
3319 //determine if start or end of hyperlink is appropriate
3320 //eventually change a following link start into a link end
3321 // groups of LS LE should be ignored
3322 // <insert>
3323 //LS <insert>
3324 //LE <insert>
3325 //<insert> LS
3326 //<insert> LE
3327 //<insert>
3328 sal_Bool bPreStartLinkFound = sal_False; //
3329 sal_Bool bPreEndLinkFound = sal_False;
3331 const Control* pControl = aControlList.First();
3332 const Control* pExchange = 0;
3333 while( pControl && pActiveCtrl != pControl )
3335 if( WINDOW_EDIT != pControl->GetType())
3337 const SwFormToken& rNewToken =
3338 ((SwTOXButton*)pControl)->GetFormToken();
3339 if( TOKEN_LINK_START == rNewToken.eTokenType )
3341 bPreStartLinkFound = sal_True;
3342 pExchange = 0;
3344 else if(TOKEN_LINK_END == rNewToken.eTokenType)
3346 if( bPreStartLinkFound )
3347 bPreStartLinkFound = sal_False;
3348 else
3350 bPreEndLinkFound = sal_False;
3351 pExchange = pControl;
3355 pControl = aControlList.Next();
3358 sal_Bool bPostLinkEndFound = sal_False;
3359 sal_Bool bPostLinkStartFound = sal_False;
3360 if(!bPreStartLinkFound && !bPreEndLinkFound)
3361 while(pControl)
3363 if( pControl != pActiveCtrl &&
3364 WINDOW_EDIT != pControl->GetType())
3366 const SwFormToken& rNewToken =
3367 ((SwTOXButton*)pControl)->GetFormToken();
3368 if( TOKEN_LINK_START == rNewToken.eTokenType )
3370 if(bPostLinkStartFound)
3371 break;
3372 bPostLinkStartFound = sal_True;
3373 pExchange = pControl;
3375 else if(TOKEN_LINK_END == rNewToken.eTokenType )
3377 if(bPostLinkStartFound)
3379 bPostLinkStartFound = sal_False;
3380 pExchange = 0;
3382 else
3384 bPostLinkEndFound = sal_True;
3386 break;
3389 pControl = aControlList.Next();
3392 if(bPreStartLinkFound)
3394 aToInsertToken.eTokenType = TOKEN_LINK_END;
3395 aToInsertToken.sText = aButtonTexts[TOKEN_LINK_END];
3398 if(bPostLinkStartFound)
3400 DBG_ASSERT(pExchange, "no control to exchange?");
3401 if(pExchange)
3403 ((SwTOXButton*)pExchange)->SetLinkEnd();
3404 ((SwTOXButton*)pExchange)->SetText(aButtonTexts[TOKEN_LINK_END]);
3408 if(bPreEndLinkFound)
3410 DBG_ASSERT(pExchange, "no control to exchange?");
3411 if(pExchange)
3413 ((SwTOXButton*)pExchange)->SetLinkStart();
3414 ((SwTOXButton*)pExchange)->SetText(aButtonTexts[TOKEN_LINK_START]);
3419 //if the active control is text then insert a new button at the selection
3420 //else replace the button
3421 sal_uInt32 nActivePos = aControlList.GetPos(pActiveCtrl);
3422 sal_uInt32 nInsertPos = nActivePos;
3424 Size aControlSize(GetOutputSizePixel());
3425 if( WINDOW_EDIT == pActiveCtrl->GetType())
3427 nInsertPos++;
3428 Selection aSel = ((SwTOXEdit*)pActiveCtrl)->GetSelection();
3429 aSel.Justify();
3430 String sEditText = ((SwTOXEdit*)pActiveCtrl)->GetText();
3431 String sLeft = sEditText.Copy( 0, static_cast< USHORT >(aSel.A()) );
3432 String sRight = sEditText.Copy( static_cast< USHORT >(aSel.B()),
3433 static_cast< USHORT >(sEditText.Len() - aSel.B()));
3435 ((SwTOXEdit*)pActiveCtrl)->SetText(sLeft);
3436 ((SwTOXEdit*)pActiveCtrl)->AdjustSize();
3438 SwFormToken aTmpToken(TOKEN_TEXT);
3439 SwTOXEdit* pEdit = new SwTOXEdit(&aCtrlParentWin, this, aTmpToken);
3440 aControlList.Insert(pEdit, nActivePos + 1);
3441 pEdit->SetText(sRight);
3442 pEdit->SetSizePixel(aControlSize);
3443 pEdit->AdjustSize();
3444 pEdit->SetModifyHdl(LINK(this, SwTokenWindow, EditResize ));
3445 pEdit->SetPrevNextLink(LINK(this, SwTokenWindow, NextItemHdl));
3446 pEdit->SetGetFocusHdl(LINK(this, SwTokenWindow, TbxFocusHdl));
3447 pEdit->Show();
3449 else
3451 aControlList.Remove(pActiveCtrl);
3452 pActiveCtrl->Hide();
3453 delete pActiveCtrl;
3456 //now the new button
3457 SwTOXButton* pButton = new SwTOXButton(&aCtrlParentWin, this, aToInsertToken);
3458 aControlList.Insert(pButton, nInsertPos);
3459 pButton->SetPrevNextLink(LINK(this, SwTokenWindow, NextItemBtnHdl));
3460 pButton->SetGetFocusHdl(LINK(this, SwTokenWindow, TbxFocusBtnHdl));
3461 if(TOKEN_AUTHORITY != aToInsertToken.eTokenType)
3462 pButton->SetText(aButtonTexts[aToInsertToken.eTokenType]);
3463 else
3465 //use the first two chars as symbol
3466 String sTmp(SwAuthorityFieldType::GetAuthFieldName(
3467 (ToxAuthorityField)aToInsertToken.nAuthorityField));
3468 pButton->SetText(sTmp.Copy(0, 2));
3471 Size aEditSize(GetOutputSizePixel());
3472 aEditSize.Width() = pButton->GetTextWidth(rText) + 5;
3473 pButton->SetSizePixel(aEditSize);
3474 pButton->Check(sal_True);
3475 pButton->Show();
3476 SetActiveControl(pButton);
3478 AdjustPositions();
3480 /* -----------------19.08.99 12:42-------------------
3482 --------------------------------------------------*/
3483 void SwTokenWindow::RemoveControl(SwTOXButton* pDel, sal_Bool bInternalCall )
3485 if(bInternalCall && TOX_AUTHORITIES == pForm->GetTOXType())
3486 m_pParent->PreTokenButtonRemoved(pDel->GetFormToken());
3488 sal_uInt32 nActivePos = aControlList.GetPos(pDel);
3489 DBG_ASSERT(nActivePos != 0xffffffff, "Control does not exist!");
3490 // the two neighbours of the box must be merged
3491 // the properties of the right one will be lost
3492 DBG_ASSERT(nActivePos && nActivePos < aControlList.Count() - 1,
3493 "Button at first or last position?");
3494 aControlList.Seek(nActivePos - 1);
3495 Control* pLeftEdit = aControlList.GetCurObject();
3496 aControlList.Seek(nActivePos + 1);
3497 Control* pRightEdit = aControlList.GetCurObject();
3498 String sTemp(((SwTOXEdit*)pLeftEdit)->GetText());
3499 sTemp += ((SwTOXEdit*)pRightEdit)->GetText();
3500 ((SwTOXEdit*)pLeftEdit)->SetText(sTemp);
3501 ((SwTOXEdit*)pLeftEdit)->AdjustSize();
3503 aControlList.Remove(pRightEdit);
3504 delete pRightEdit;
3506 aControlList.Remove(pDel);
3507 pActiveCtrl->Hide();
3508 delete pActiveCtrl;
3509 SetActiveControl(pLeftEdit);
3510 AdjustPositions();
3511 if(aModifyHdl.IsSet())
3512 aModifyHdl.Call(0);
3515 /* -----------------16.07.99 12:39-------------------
3517 --------------------------------------------------*/
3518 void SwTokenWindow::AdjustPositions()
3520 if(aControlList.Count() > 1)
3522 Control* pCtrl = aControlList.First();
3523 Point aNextPos = pCtrl->GetPosPixel();
3524 aNextPos.X() += pCtrl->GetSizePixel().Width();
3525 while(0 != (pCtrl = aControlList.Next()))
3527 pCtrl->SetPosPixel(aNextPos);
3528 aNextPos.X() += pCtrl->GetSizePixel().Width();
3530 AdjustScrolling();
3533 /* -----------------------------16.08.00 13:22--------------------------------
3535 ---------------------------------------------------------------------------*/
3536 void SwTokenWindow::MoveControls(long nOffset)
3538 // move the complete list
3539 Control* pCtrl = aControlList.First();
3542 Point aPos = pCtrl->GetPosPixel();
3543 aPos.X() += nOffset;
3544 pCtrl->SetPosPixel(aPos);
3545 }while(0 != (pCtrl = aControlList.Next()));
3547 /* -----------------------------14.01.00 13:03--------------------------------
3549 ---------------------------------------------------------------------------*/
3550 void SwTokenWindow::AdjustScrolling()
3552 if(aControlList.Count() > 1)
3554 //validate scroll buttons
3555 Control* pLastCtrl = aControlList.Last();
3556 Control* pFirstCtrl = aControlList.First();
3557 long nSpace = aCtrlParentWin.GetSizePixel().Width();
3558 long nWidth = pLastCtrl->GetPosPixel().X() - pFirstCtrl->GetPosPixel().X()
3559 + pLastCtrl->GetSizePixel().Width();
3560 sal_Bool bEnable = nWidth > nSpace;
3561 //the active control must be visible
3562 if(bEnable && pActiveCtrl)
3564 Point aActivePos(pActiveCtrl->GetPosPixel());
3565 long nMove = 0;
3566 if(aActivePos.X() < 0)
3567 nMove = -aActivePos.X();
3568 else if((aActivePos.X() + pActiveCtrl->GetSizePixel().Width()) > nSpace)
3569 nMove = -(aActivePos.X() + pActiveCtrl->GetSizePixel().Width() - nSpace);
3570 if(nMove)
3571 MoveControls(nMove);
3572 aLeftScrollWin.Enable(aControlList.First()->GetPosPixel().X() < 0);
3573 Control* pCtrl = aControlList.Last();
3574 aRightScrollWin.Enable((pCtrl->GetPosPixel().X() + pCtrl->GetSizePixel().Width()) > nSpace);
3576 else
3578 if(pFirstCtrl)
3580 //if the control fits into the space then the first control must be at postion 0
3581 long nFirstPos = pFirstCtrl->GetPosPixel().X();
3582 if(nFirstPos != 0)
3583 MoveControls(-nFirstPos);
3585 aRightScrollWin.Enable(sal_False);
3586 aLeftScrollWin.Enable(sal_False);
3590 /* -----------------------------14.01.00 13:57--------------------------------
3592 ---------------------------------------------------------------------------*/
3593 IMPL_LINK(SwTokenWindow, ScrollHdl, ImageButton*, pBtn )
3595 if(aControlList.Count())
3597 const long nSpace = aCtrlParentWin.GetSizePixel().Width();
3598 #if OSL_DEBUG_LEVEL > 1
3599 //find all start/end positions and print it
3600 String sMessage(String::CreateFromAscii("Space: "));
3601 sMessage += String::CreateFromInt32(nSpace);
3602 sMessage += String::CreateFromAscii(" | ");
3603 Control* pDebugCtrl = aControlList.First();
3606 long nDebugXPos = pDebugCtrl->GetPosPixel().X();
3607 long nDebugWidth = pDebugCtrl->GetSizePixel().Width();
3608 sMessage += String::CreateFromInt32( nDebugXPos );
3609 sMessage += String::CreateFromAscii(" ");
3610 sMessage += String::CreateFromInt32(nDebugXPos + nDebugWidth);
3611 sMessage += String::CreateFromAscii(" | ");
3613 }while(0 != (pDebugCtrl = aControlList.Next()));
3615 #endif
3617 long nMove = 0;
3618 if(pBtn == &aLeftScrollWin)
3620 //find the first completely visible control (left edge visible)
3621 for(sal_uInt16 i = 0; i < aControlList.Count(); i++ )
3623 Control* pCtrl = aControlList.GetObject(i);
3624 long nXPos = pCtrl->GetPosPixel().X();
3625 if(nXPos >= 0)
3627 if(!i)
3628 //move the current control to the left edge
3629 nMove = -nXPos;
3630 else
3631 //move the left neighbor to the start position
3632 nMove = -aControlList.GetObject(i - 1)->GetPosPixel().X();
3633 break;
3637 else
3639 //find the first completely visible control (left edge visible)
3640 for(ULONG i = aControlList.Count(); i; i-- )
3642 Control* pCtrl = aControlList.GetObject(i - 1);
3643 long nCtrlWidth = pCtrl->GetSizePixel().Width();
3644 long nXPos = pCtrl->GetPosPixel().X() + nCtrlWidth;
3645 if(nXPos <= nSpace)
3647 if( i < aControlList.Count())
3649 //move the right neighbor to the right edge right aligned
3650 Control* pRight = aControlList.GetObject(i);
3651 nMove = nSpace - pRight->GetPosPixel().X() - pRight->GetSizePixel().Width();
3653 break;
3657 //move it left until it's completely visible
3659 if(nMove)
3661 // move the complete list
3662 Control* pCtrl = aControlList.First();
3665 Point aPos = pCtrl->GetPosPixel();
3666 aPos.X() += nMove;
3667 pCtrl->SetPosPixel(aPos);
3668 }while(0 != (pCtrl = aControlList.Next()));
3669 aLeftScrollWin.Enable(aControlList.First()->GetPosPixel().X() < 0);
3670 pCtrl = aControlList.Last();
3671 aRightScrollWin.Enable((pCtrl->GetPosPixel().X() + pCtrl->GetSizePixel().Width()) > nSpace);
3673 #if OSL_DEBUG_LEVEL > 1
3674 sMessage.AppendAscii("Move: ");
3675 sMessage += String::CreateFromInt32(nMove);
3676 GetParent()->GetParent()->GetParent()->SetText(sMessage);
3677 #endif
3680 return 0;
3682 /* -----------------17.06.99 11:59-------------------
3684 --------------------------------------------------*/
3685 String SwTokenWindow::GetPattern() const
3687 String sRet;
3688 const Control* pControl = ((SwTokenWindow*)this)->aControlList.First();
3689 while(pControl)
3691 const SwFormToken& rNewToken = WINDOW_EDIT == pControl->GetType()
3692 ? ((SwTOXEdit*)pControl)->GetFormToken()
3693 : ((SwTOXButton*)pControl)->GetFormToken();
3695 //TODO: prevent input of TOX_STYLE_DELIMITER in KeyInput
3696 sRet += rNewToken.GetString();
3698 pControl = ((SwTokenWindow*)this)->aControlList.Next();
3700 return sRet;
3702 /* -----------------19.08.99 11:27-------------------
3703 Description: Check if a control of the specified
3704 TokenType is already contained in the list
3705 --------------------------------------------------*/
3706 sal_Bool SwTokenWindow::Contains(FormTokenType eSearchFor) const
3708 sal_Bool bRet = sal_False;
3709 const Control* pControl = ((SwTokenWindow*)this)->aControlList.First();
3710 while(pControl)
3712 const SwFormToken& rNewToken = WINDOW_EDIT == pControl->GetType()
3713 ? ((SwTOXEdit*)pControl)->GetFormToken()
3714 : ((SwTOXButton*)pControl)->GetFormToken();
3716 if(eSearchFor == rNewToken.eTokenType)
3718 bRet = sal_True;
3719 break;
3721 pControl = ((SwTokenWindow*)this)->aControlList.Next();
3723 return bRet;
3725 //---------------------------------------------------
3726 BOOL SwTokenWindow::CreateQuickHelp(Control* pCtrl,
3727 const SwFormToken& rToken,
3728 const HelpEvent& rHEvt)
3730 BOOL bRet = FALSE;
3731 if( rHEvt.GetMode() & HELPMODE_QUICK )
3733 sal_Bool bBalloon = Help::IsBalloonHelpEnabled();
3734 String sEntry;
3735 if(bBalloon || rToken.eTokenType != TOKEN_AUTHORITY)
3736 sEntry = (aButtonHelpTexts[rToken.eTokenType]);
3737 if(rToken.eTokenType == TOKEN_AUTHORITY )
3739 sEntry += SwAuthorityFieldType::GetAuthFieldName(
3740 (ToxAuthorityField) rToken.nAuthorityField);
3743 Point aPos = OutputToScreenPixel(pCtrl->GetPosPixel());
3744 Rectangle aItemRect( aPos, pCtrl->GetSizePixel() );
3745 if(rToken.eTokenType == TOKEN_TAB_STOP )
3747 // sEntry += '\n';
3748 // sEntry += rToken.nTabStopPosition;
3750 else
3752 if(rToken.sCharStyleName.Len())
3754 if(bBalloon)
3755 sEntry += '\n';
3756 else
3757 sEntry += ' ';
3758 sEntry += sCharStyle;
3759 sEntry += rToken.sCharStyleName;
3762 if(bBalloon)
3764 Help::ShowBalloon( this, aPos, aItemRect, sEntry );
3766 else
3767 Help::ShowQuickHelp( this, aItemRect, sEntry,
3768 QUICKHELP_LEFT|QUICKHELP_VCENTER );
3769 bRet = TRUE;
3771 return bRet;
3773 /* -----------------------------14.01.00 12:22--------------------------------
3775 ---------------------------------------------------------------------------*/
3776 void SwTokenWindow::Resize()
3778 Size aCompleteSize(GetOutputSizePixel());
3780 Point aRightPos(aRightScrollWin.GetPosPixel());
3781 Size aRightSize(aRightScrollWin.GetSizePixel());
3783 Size aMiddleSize(aCtrlParentWin.GetSizePixel());
3785 long nMove = aCompleteSize.Width() - aRightSize.Width() - aRightPos.X();
3787 aRightPos.X() += nMove;
3788 aRightScrollWin.SetPosPixel(aRightPos);
3789 aMiddleSize.Width() += nMove;
3790 aCtrlParentWin.SetSizePixel(aMiddleSize);
3793 /* -----------------16.06.99 15:23-------------------
3795 --------------------------------------------------*/
3796 IMPL_LINK(SwTokenWindow, EditResize, Edit*, pEdit)
3798 ((SwTOXEdit*)pEdit)->AdjustSize();
3799 AdjustPositions();
3800 if(aModifyHdl.IsSet())
3801 aModifyHdl.Call(0);
3802 return 0;
3804 /* -----------------16.06.99 15:56-------------------
3806 --------------------------------------------------*/
3807 IMPL_LINK(SwTokenWindow, NextItemHdl, SwTOXEdit*, pEdit)
3809 sal_uInt16 nPos = (sal_uInt16)aControlList.GetPos(pEdit);
3810 if(nPos && !pEdit->IsNextControl() ||
3811 nPos < aControlList.Count() - 1 && pEdit->IsNextControl())
3813 aControlList.Seek(nPos);
3814 Control* pNextPrev = pEdit->IsNextControl() ? aControlList.Next() : aControlList.Prev();
3815 nPos += pEdit->IsNextControl() ? 1 : -1;
3816 pNextPrev->GrabFocus();
3817 ((SwTOXButton*)pNextPrev)->Check();
3818 AdjustScrolling();
3820 return 0;
3822 /* -----------------17.06.99 08:58-------------------
3824 --------------------------------------------------*/
3825 IMPL_LINK(SwTokenWindow, TbxFocusHdl, SwTOXEdit*, pEdit)
3827 for(sal_uInt16 i = 0; i < aControlList.Count(); i++)
3829 Control* pControl = aControlList.First();
3830 while(pControl)
3832 if(WINDOW_EDIT != pControl->GetType() )
3833 ((SwTOXButton*)pControl)->Check(sal_False);
3834 pControl = aControlList.Next();
3837 SetActiveControl(pEdit);
3838 return 0;
3840 /* -----------------17.06.99 10:05-------------------
3842 --------------------------------------------------*/
3843 IMPL_LINK(SwTokenWindow, NextItemBtnHdl, SwTOXButton*, pBtn )
3845 sal_uInt16 nPos = (sal_uInt16)aControlList.GetPos(pBtn);
3846 if(nPos && !pBtn->IsNextControl() ||
3847 nPos < aControlList.Count() - 1 && pBtn->IsNextControl())
3849 aControlList.Seek(nPos);
3850 sal_Bool bNext = pBtn->IsNextControl();
3851 Control* pNextPrev = bNext ? aControlList.Next() : aControlList.Prev();
3852 pNextPrev->GrabFocus();
3853 Selection aSel(0, 0);
3854 if(!bNext)
3856 sal_uInt16 nLen = ((SwTOXEdit*)pNextPrev)->GetText().Len();
3857 aSel.A() = nLen;
3858 aSel.B() = nLen;
3860 ((SwTOXEdit*)pNextPrev)->SetSelection(aSel);
3861 pBtn->Check(sal_False);
3862 AdjustScrolling();
3864 return 0;
3867 /* -----------------17.06.99 10:04-------------------
3869 --------------------------------------------------*/
3870 IMPL_LINK(SwTokenWindow, TbxFocusBtnHdl, SwTOXButton*, pBtn )
3872 for(sal_uInt16 i = 0; i < aControlList.Count(); i++)
3874 Control* pControl = aControlList.First();
3875 while(pControl)
3877 if(WINDOW_EDIT != pControl->GetType() )
3878 ((SwTOXButton*)pControl)->Check(pBtn == pControl);
3879 pControl = aControlList.Next();
3882 SetActiveControl(pBtn);
3883 return 0;
3885 /* -----------------------------28.01.2002 12:22------------------------------
3887 ---------------------------------------------------------------------------*/
3888 void SwTokenWindow::GetFocus()
3890 if(GETFOCUS_TAB & GetGetFocusFlags())
3892 Control* pFirst = aControlList.First();
3893 if(pFirst)
3895 pFirst->GrabFocus();
3896 SetActiveControl(pFirst);
3897 AdjustScrolling();
3901 /* -----------------25.03.99 15:17-------------------
3903 * --------------------------------------------------*/
3904 SwTOXStylesTabPage::SwTOXStylesTabPage(Window* pParent, const SfxItemSet& rAttrSet ) :
3905 SfxTabPage(pParent, SW_RES(TP_TOX_STYLES), rAttrSet),
3906 aLevelFT2(this, SW_RES(FT_LEVEL )),
3907 aLevelLB(this, SW_RES(LB_LEVEL )),
3908 aTemplateFT(this, SW_RES(FT_TEMPLATE)),
3909 aParaLayLB(this, SW_RES(LB_PARALAY )),
3910 aStdBT(this, SW_RES(BT_STD )),
3911 aAssignBT(this, SW_RES(BT_ASSIGN )),
3912 aEditStyleBT(this, SW_RES(BT_EDIT_STYLE )),
3913 aFormatFL(this, SW_RES(FL_FORMAT )),
3914 m_pCurrentForm(0)
3916 FreeResource();
3917 SetExchangeSupport( sal_True );
3919 aAssignBT.SetModeImage( Image( SW_RES( IMG_ONE_LEFT_HC ) ), BMP_COLOR_HIGHCONTRAST );
3921 aEditStyleBT.SetClickHdl (LINK( this, SwTOXStylesTabPage, EditStyleHdl));
3922 aAssignBT.SetClickHdl (LINK( this, SwTOXStylesTabPage, AssignHdl));
3923 aStdBT.SetClickHdl (LINK( this, SwTOXStylesTabPage, StdHdl));
3924 aParaLayLB.SetSelectHdl (LINK( this, SwTOXStylesTabPage, EnableSelectHdl));
3925 aLevelLB.SetSelectHdl (LINK( this, SwTOXStylesTabPage, EnableSelectHdl));
3926 aParaLayLB.SetDoubleClickHdl(LINK( this, SwTOXStylesTabPage, DoubleClickHdl));
3928 /* -----------------25.03.99 15:17-------------------
3930 * --------------------------------------------------*/
3931 SwTOXStylesTabPage::~SwTOXStylesTabPage()
3933 delete m_pCurrentForm;
3935 /* -----------------25.03.99 15:17-------------------
3937 * --------------------------------------------------*/
3938 sal_Bool SwTOXStylesTabPage::FillItemSet( SfxItemSet& )
3940 return sal_True;
3942 /* -----------------25.03.99 15:17-------------------
3944 * --------------------------------------------------*/
3945 void SwTOXStylesTabPage::Reset( const SfxItemSet& rSet )
3947 ActivatePage(rSet);
3949 /* -----------------25.03.99 15:17-------------------
3951 * --------------------------------------------------*/
3952 void SwTOXStylesTabPage::ActivatePage( const SfxItemSet& )
3954 m_pCurrentForm = new SwForm(GetForm());
3955 aParaLayLB.Clear();
3956 aLevelLB.Clear();
3958 // kein Hyperlink fuer Benutzerverzeichnisse
3960 sal_uInt16 i, nSize = m_pCurrentForm->GetFormMax();
3962 // form-Pattern anzeigen ohne Titel
3964 //1. TemplateEntry anzeigen
3965 String aStr( SW_RES( STR_TITLE ));
3966 if( m_pCurrentForm->GetTemplate( 0 ).Len() )
3968 aStr += ' ';
3969 aStr += aDeliStart;
3970 aStr += m_pCurrentForm->GetTemplate( 0 );
3971 aStr += aDeliEnd;
3973 aLevelLB.InsertEntry(aStr);
3975 for( i=1; i < nSize; ++i )
3977 if( TOX_INDEX == m_pCurrentForm->GetTOXType() &&
3978 FORM_ALPHA_DELIMITTER == i )
3979 aStr = SW_RESSTR(STR_ALPHA);
3980 else
3982 aStr = SW_RESSTR(STR_LEVEL);
3983 aStr += String::CreateFromInt32(
3984 TOX_INDEX == m_pCurrentForm->GetTOXType() ? i - 1 : i );
3986 String aCpy( aStr );
3988 if( m_pCurrentForm->GetTemplate( i ).Len() )
3990 aCpy += ' ';
3991 aCpy += aDeliStart;
3992 aCpy += m_pCurrentForm->GetTemplate( i );
3993 aCpy += aDeliEnd;
3995 aLevelLB.InsertEntry( aCpy );
3998 // Templates initialisieren
3999 const SwTxtFmtColl *pColl;
4000 SwWrtShell& rSh = ((SwMultiTOXTabDialog*)GetTabDialog())->GetWrtShell();
4001 const sal_uInt16 nSz = rSh.GetTxtFmtCollCount();
4003 for( i = 0; i < nSz; ++i )
4004 if( !(pColl = &rSh.GetTxtFmtColl( i ))->IsDefault() )
4005 aParaLayLB.InsertEntry( pColl->GetName() );
4007 // Pool-Collections abfragen und fuer das Verzeichnis setzen
4008 for( i = 0; i < m_pCurrentForm->GetFormMax(); ++i )
4010 aStr = m_pCurrentForm->GetTemplate( i );
4011 if( aStr.Len() &&
4012 LISTBOX_ENTRY_NOTFOUND == aParaLayLB.GetEntryPos( aStr ))
4013 aParaLayLB.InsertEntry( aStr );
4016 EnableSelectHdl(&aParaLayLB);
4018 /* -----------------25.03.99 15:17-------------------
4020 * --------------------------------------------------*/
4021 int SwTOXStylesTabPage::DeactivatePage( SfxItemSet* /*pSet*/ )
4023 GetForm() = *m_pCurrentForm;
4024 return LEAVE_PAGE;
4027 /* -----------------25.03.99 15:17-------------------
4029 * --------------------------------------------------*/
4030 SfxTabPage* SwTOXStylesTabPage::Create( Window* pParent,
4031 const SfxItemSet& rAttrSet)
4033 return new SwTOXStylesTabPage(pParent, rAttrSet);
4035 /* -----------------26.03.99 12:47-------------------
4037 * --------------------------------------------------*/
4038 IMPL_LINK( SwTOXStylesTabPage, EditStyleHdl, Button *, pBtn )
4040 if( LISTBOX_ENTRY_NOTFOUND != aParaLayLB.GetSelectEntryPos())
4042 SfxStringItem aStyle(SID_STYLE_EDIT, aParaLayLB.GetSelectEntry());
4043 SfxUInt16Item aFamily(SID_STYLE_FAMILY, SFX_STYLE_FAMILY_PARA);
4044 // SwPtrItem aShell(FN_PARAM_WRTSHELL, pWrtShell);
4045 Window* pDefDlgParent = Application::GetDefDialogParent();
4046 Application::SetDefDialogParent( pBtn );
4047 SwWrtShell& rSh = ((SwMultiTOXTabDialog*)GetTabDialog())->GetWrtShell();
4048 rSh.GetView().GetViewFrame()->GetDispatcher()->Execute(
4049 SID_STYLE_EDIT, SFX_CALLMODE_SYNCHRON|SFX_CALLMODE_MODAL,
4050 &aStyle, &aFamily/*, &aShell*/, 0L);
4051 Application::SetDefDialogParent( pDefDlgParent );
4053 return 0;
4055 /*--------------------------------------------------------------------
4056 Beschreibung: Vorlagen zuweisen
4057 --------------------------------------------------------------------*/
4058 IMPL_LINK( SwTOXStylesTabPage, AssignHdl, Button *, EMPTYARG )
4060 sal_uInt16 nLevPos = aLevelLB.GetSelectEntryPos();
4061 sal_uInt16 nTemplPos = aParaLayLB.GetSelectEntryPos();
4062 if(nLevPos != LISTBOX_ENTRY_NOTFOUND &&
4063 nTemplPos != LISTBOX_ENTRY_NOTFOUND)
4065 String aStr(aLevelLB.GetEntry(nLevPos));
4066 sal_uInt16 nDelPos = aStr.Search(aDeliStart);
4067 if(nDelPos != STRING_NOTFOUND)
4068 aStr.Erase(nDelPos-1);
4069 aStr += ' ';
4070 aStr += aDeliStart;
4071 aStr += aParaLayLB.GetSelectEntry();
4073 m_pCurrentForm->SetTemplate(nLevPos, aParaLayLB.GetSelectEntry());
4075 aStr += aDeliEnd;
4077 aLevelLB.RemoveEntry(nLevPos);
4078 aLevelLB.InsertEntry(aStr, nLevPos);
4079 aLevelLB.SelectEntry(aStr);
4080 ModifyHdl(0);
4082 return 0;
4084 /* -----------------26.03.99 09:10-------------------
4086 * --------------------------------------------------*/
4087 IMPL_LINK( SwTOXStylesTabPage, StdHdl, Button *, EMPTYARG )
4089 sal_uInt16 nPos = aLevelLB.GetSelectEntryPos();
4090 if(nPos != LISTBOX_ENTRY_NOTFOUND)
4091 { String aStr(aLevelLB.GetEntry(nPos));
4092 sal_uInt16 nDelPos = aStr.Search(aDeliStart);
4093 if(nDelPos != STRING_NOTFOUND)
4094 aStr.Erase(nDelPos-1);
4095 aLevelLB.RemoveEntry(nPos);
4096 aLevelLB.InsertEntry(aStr, nPos);
4097 aLevelLB.SelectEntry(aStr);
4098 m_pCurrentForm->SetTemplate(nPos, aEmptyStr);
4099 ModifyHdl(0);
4101 return 0;
4103 /* -----------------26.03.99 09:11-------------------
4105 * --------------------------------------------------*/
4106 IMPL_LINK_INLINE_START( SwTOXStylesTabPage, DoubleClickHdl, Button *, EMPTYARG )
4108 String aTmpName( aParaLayLB.GetSelectEntry() );
4109 SwWrtShell& rSh = ((SwMultiTOXTabDialog*)GetTabDialog())->GetWrtShell();
4111 if(aParaLayLB.GetSelectEntryPos() != LISTBOX_ENTRY_NOTFOUND &&
4112 (aLevelLB.GetSelectEntryPos() == 0 || SwMultiTOXTabDialog::IsNoNum(rSh, aTmpName)))
4113 AssignHdl(&aAssignBT);
4114 return 0;
4116 IMPL_LINK_INLINE_END( SwTOXStylesTabPage, DoubleClickHdl, Button *, EMPTYARG )
4117 /*--------------------------------------------------------------------
4118 Beschreibung: nur wenn selektiert enable
4119 --------------------------------------------------------------------*/
4120 IMPL_LINK( SwTOXStylesTabPage, EnableSelectHdl, ListBox *, EMPTYARG )
4122 //UpdatePattern();
4123 aStdBT.Enable(aLevelLB.GetSelectEntryPos() != LISTBOX_ENTRY_NOTFOUND);
4125 SwWrtShell& rSh = ((SwMultiTOXTabDialog*)GetTabDialog())->GetWrtShell();
4126 String aTmpName(aParaLayLB.GetSelectEntry());
4127 aAssignBT.Enable(aParaLayLB.GetSelectEntryPos() != LISTBOX_ENTRY_NOTFOUND &&
4128 LISTBOX_ENTRY_NOTFOUND != aLevelLB.GetSelectEntryPos() &&
4129 (aLevelLB.GetSelectEntryPos() == 0 || SwMultiTOXTabDialog::IsNoNum(rSh, aTmpName)));
4130 aEditStyleBT.Enable(aParaLayLB.GetSelectEntryPos() != LISTBOX_ENTRY_NOTFOUND );
4131 return 0;
4133 /* -----------------------------18.01.00 16:54--------------------------------
4135 ---------------------------------------------------------------------------*/
4136 IMPL_LINK(SwTOXStylesTabPage, ModifyHdl, void*, EMPTYARG)
4138 SwMultiTOXTabDialog* pTOXDlg = (SwMultiTOXTabDialog*)GetTabDialog();
4139 if(pTOXDlg)
4141 GetForm() = *m_pCurrentForm;
4142 pTOXDlg->CreateOrUpdateExample(pTOXDlg->GetCurrentTOXType().eType, TOX_PAGE_STYLES);
4144 return 0;
4146 /******************************************************************************
4148 ******************************************************************************/
4149 #define ITEM_SEARCH 1
4150 #define ITEM_ALTERNATIVE 2
4151 #define ITEM_PRIM_KEY 3
4152 #define ITEM_SEC_KEY 4
4153 #define ITEM_COMMENT 5
4154 #define ITEM_CASE 6
4155 #define ITEM_WORDONLY 7
4158 SwEntryBrowseBox::SwEntryBrowseBox(Window* pParent, const ResId& rId,
4159 BrowserMode nMode ) :
4160 SwEntryBrowseBox_Base( pParent, rId, nMode,
4161 BROWSER_KEEPSELECTION |
4162 BROWSER_COLUMNSELECTION |
4163 BROWSER_MULTISELECTION |
4164 BROWSER_TRACKING_TIPS |
4165 BROWSER_HLINESFULL |
4166 BROWSER_VLINESFULL |
4167 BROWSER_AUTO_VSCROLL|
4168 BROWSER_HIDECURSOR ),
4169 aCellEdit(&GetDataWindow(), 0),
4170 aCellCheckBox(&GetDataWindow()),
4172 sSearch( ResId(ST_SEARCH, *rId.GetResMgr() )),
4173 sAlternative( ResId(ST_ALTERNATIVE, *rId.GetResMgr() )),
4174 sPrimKey( ResId(ST_PRIMKEY, *rId.GetResMgr() )),
4175 sSecKey( ResId(ST_SECKEY, *rId.GetResMgr() )),
4176 sComment( ResId(ST_COMMENT, *rId.GetResMgr() )),
4177 sCaseSensitive( ResId(ST_CASESENSITIVE, *rId.GetResMgr() )),
4178 sWordOnly( ResId(ST_WORDONLY, *rId.GetResMgr() )),
4179 sYes( ResId(ST_TRUE, *rId.GetResMgr() )),
4180 sNo( ResId(ST_FALSE, *rId.GetResMgr() )),
4181 bModified(sal_False)
4183 FreeResource();
4184 aCellCheckBox.GetBox().EnableTriState(sal_False);
4185 xController = new ::svt::EditCellController(&aCellEdit);
4186 xCheckController = new ::svt::CheckBoxCellController(&aCellCheckBox);
4188 //////////////////////////////////////////////////////////////////////
4189 // HACK: BrowseBox invalidiert nicht ihre Childs, wie es eigentlich sein sollte.
4190 // Deshalb wird WB_CLIPCHILDREN zurueckgesetzt, wodurch das Invalidieren
4191 // der Childs erzwungen wird.
4192 WinBits aStyle = GetStyle();
4193 if( aStyle & WB_CLIPCHILDREN )
4195 aStyle &= ~WB_CLIPCHILDREN;
4196 SetStyle( aStyle );
4198 const String* aTitles[7] =
4200 &sSearch,
4201 &sAlternative,
4202 &sPrimKey,
4203 &sSecKey,
4204 &sComment,
4205 &sCaseSensitive,
4206 &sWordOnly
4209 long nWidth = GetSizePixel().Width();
4210 nWidth /=7;
4211 --nWidth;
4212 for(sal_uInt16 i = 1; i < 8; i++)
4213 InsertDataColumn( i, *aTitles[i - 1], nWidth,
4214 HIB_STDSTYLE, HEADERBAR_APPEND );
4217 /* -----------------------------19.01.00 11:29--------------------------------
4219 ---------------------------------------------------------------------------*/
4220 sal_Bool SwEntryBrowseBox::SeekRow( long nRow )
4222 nCurrentRow = nRow;
4223 return TRUE;
4225 /* -----------------------------19.01.00 15:32--------------------------------
4227 ---------------------------------------------------------------------------*/
4228 String SwEntryBrowseBox::GetCellText(long nRow, USHORT nColumn) const
4230 const String* pRet = &aEmptyStr;
4231 if(aEntryArr.Count() > nRow)
4233 AutoMarkEntry* pEntry = aEntryArr[ static_cast< USHORT >(nRow) ];
4234 switch(nColumn)
4236 case ITEM_SEARCH :pRet = &pEntry->sSearch; break;
4237 case ITEM_ALTERNATIVE :pRet = &pEntry->sAlternative; break;
4238 case ITEM_PRIM_KEY :pRet = &pEntry->sPrimKey ; break;
4239 case ITEM_SEC_KEY :pRet = &pEntry->sSecKey ; break;
4240 case ITEM_COMMENT :pRet = &pEntry->sComment ; break;
4241 case ITEM_CASE :pRet = pEntry->bCase ? &sYes : &sNo; break;
4242 case ITEM_WORDONLY :pRet = pEntry->bWord ? &sYes : &sNo; break;
4245 return *pRet;
4248 /* -----------------------------19.01.00 11:29--------------------------------
4250 ---------------------------------------------------------------------------*/
4251 void SwEntryBrowseBox::PaintCell(OutputDevice& rDev,
4252 const Rectangle& rRect, sal_uInt16 nColumnId) const
4254 String sPaint = GetCellText( nCurrentRow, nColumnId );
4255 sal_uInt16 nStyle = TEXT_DRAW_CLIP | TEXT_DRAW_CENTER;
4256 rDev.DrawText( rRect, sPaint, nStyle );
4258 /* -----------------------------19.01.00 14:51--------------------------------
4260 ---------------------------------------------------------------------------*/
4261 ::svt::CellController* SwEntryBrowseBox::GetController(long /*nRow*/, sal_uInt16 nCol)
4263 return nCol < ITEM_CASE ? xController : xCheckController;
4265 /* -----------------------------19.01.00 15:36--------------------------------
4267 ---------------------------------------------------------------------------*/
4268 sal_Bool SwEntryBrowseBox::SaveModified()
4270 SetModified();
4271 USHORT nRow = static_cast< USHORT >(GetCurRow());
4272 sal_uInt16 nCol = GetCurColumnId();
4274 String sNew;
4275 sal_Bool bVal = sal_False;
4276 ::svt::CellController* pController = 0;
4277 if(nCol < ITEM_CASE)
4279 pController = xController;
4280 sNew = ((::svt::EditCellController*)pController)->GetEditImplementation()->GetText( LINEEND_LF );
4282 else
4284 pController = xCheckController;
4285 bVal = ((::svt::CheckBoxCellController*)pController)->GetCheckBox().IsChecked();
4287 AutoMarkEntry* pEntry = nRow >= aEntryArr.Count() ? new AutoMarkEntry
4288 : aEntryArr[nRow];
4289 switch(nCol)
4291 case ITEM_SEARCH : pEntry->sSearch = sNew; break;
4292 case ITEM_ALTERNATIVE : pEntry->sAlternative = sNew; break;
4293 case ITEM_PRIM_KEY : pEntry->sPrimKey = sNew; break;
4294 case ITEM_SEC_KEY : pEntry->sSecKey = sNew; break;
4295 case ITEM_COMMENT : pEntry->sComment = sNew; break;
4296 case ITEM_CASE : pEntry->bCase = bVal; break;
4297 case ITEM_WORDONLY : pEntry->bWord = bVal; break;
4299 if(nRow >= aEntryArr.Count())
4301 aEntryArr.Insert( pEntry, aEntryArr.Count() );
4302 RowInserted(nRow, 1, sal_True, sal_True);
4303 if(nCol < ITEM_WORDONLY)
4305 pController->ClearModified();
4306 GoToRow( nRow );
4309 return sal_True;
4311 /* -----------------------------19.01.00 14:32--------------------------------
4313 ---------------------------------------------------------------------------*/
4314 void SwEntryBrowseBox::InitController(
4315 ::svt::CellControllerRef& rController, long nRow, sal_uInt16 nCol)
4317 String rTxt = GetCellText( nRow, nCol );
4318 if(nCol < ITEM_CASE)
4320 rController = xController;
4321 ::svt::CellController* pController = xController;
4322 ((::svt::EditCellController*)pController)->GetEditImplementation()->SetText( rTxt );
4324 else
4326 rController = xCheckController;
4327 ::svt::CellController* pController = xCheckController;
4328 ((::svt::CheckBoxCellController*)pController)->GetCheckBox().Check(
4329 rTxt == sYes );
4332 /* -----------------------------19.01.00 12:19--------------------------------
4334 ---------------------------------------------------------------------------*/
4335 void SwEntryBrowseBox::ReadEntries(SvStream& rInStr)
4337 AutoMarkEntry* pToInsert = 0;
4338 const String sZero('0');
4339 rtl_TextEncoding eTEnc = gsl_getSystemTextEncoding();
4340 while( !rInStr.GetError() && !rInStr.IsEof() )
4342 String sLine;
4343 rInStr.ReadByteStringLine( sLine, eTEnc );
4345 // # -> comment
4346 // ; -> delimiter between entries ->
4347 // Format: TextToSearchFor;AlternativeString;PrimaryKey;SecondaryKey
4348 // Leading and trailing blanks are ignored
4349 if( sLine.Len() )
4351 //comments are contained in separate lines but are put into the struct of the following data
4352 //line (if available)
4353 if( '#' != sLine.GetChar(0) )
4355 if( !pToInsert )
4356 pToInsert = new AutoMarkEntry;
4358 USHORT nSttPos = 0;
4359 pToInsert->sSearch = sLine.GetToken(0, ';', nSttPos );
4360 pToInsert->sAlternative = sLine.GetToken(0, ';', nSttPos );
4361 pToInsert->sPrimKey = sLine.GetToken(0, ';', nSttPos );
4362 pToInsert->sSecKey = sLine.GetToken(0, ';', nSttPos );
4364 String sStr = sLine.GetToken(0, ';', nSttPos );
4365 pToInsert->bCase = sStr.Len() && sStr != sZero;
4367 sStr = sLine.GetToken(0, ';', nSttPos );
4368 pToInsert->bWord = sStr.Len() && sStr != sZero;
4370 aEntryArr.Insert( pToInsert, aEntryArr.Count() );
4371 pToInsert = 0;
4373 else
4375 if(pToInsert)
4376 aEntryArr.Insert(pToInsert, aEntryArr.Count());
4377 pToInsert = new AutoMarkEntry;
4378 pToInsert->sComment = sLine;
4379 pToInsert->sComment.Erase(0, 1);
4383 if( pToInsert )
4384 aEntryArr.Insert(pToInsert, aEntryArr.Count());
4385 RowInserted(0, aEntryArr.Count() + 1, sal_True);
4387 /* -----------------------------19.01.00 12:19--------------------------------
4389 ---------------------------------------------------------------------------*/
4390 void SwEntryBrowseBox::WriteEntries(SvStream& rOutStr)
4392 //check if the current controller is modified
4393 sal_uInt16 nCol = GetCurColumnId();
4394 ::svt::CellController* pController;
4395 if(nCol < ITEM_CASE)
4396 pController = xController;
4397 else
4398 pController = xCheckController;
4399 if(pController ->IsModified())
4400 GoToColumnId(nCol < ITEM_CASE ? ++nCol : --nCol );
4402 rtl_TextEncoding eTEnc = gsl_getSystemTextEncoding();
4403 for(sal_uInt16 i = 0; i < aEntryArr.Count();i++)
4405 AutoMarkEntry* pEntry = aEntryArr[i];
4406 if(pEntry->sComment.Len())
4408 String sWrite('#');
4409 sWrite += pEntry->sComment;
4410 rOutStr.WriteByteStringLine( sWrite, eTEnc );
4413 String sWrite( pEntry->sSearch );
4414 sWrite += ';';
4415 sWrite += pEntry->sAlternative;
4416 sWrite += ';';
4417 sWrite += pEntry->sPrimKey;
4418 sWrite += ';';
4419 sWrite += pEntry->sSecKey;
4420 sWrite += ';';
4421 sWrite += pEntry->bCase ? '1' : '0';
4422 sWrite += ';';
4423 sWrite += pEntry->bWord ? '1' : '0';
4425 if( sWrite.Len() > 5 )
4426 rOutStr.WriteByteStringLine( sWrite, eTEnc );
4429 /* -----------------------------21.01.00 11:49--------------------------------
4431 ---------------------------------------------------------------------------*/
4432 sal_Bool SwEntryBrowseBox::IsModified()const
4434 if(bModified)
4435 return sal_True;
4438 //check if the current controller is modified
4439 sal_uInt16 nCol = GetCurColumnId();
4440 ::svt::CellController* pController;
4441 if(nCol < ITEM_CASE)
4442 pController = xController;
4443 else
4444 pController = xCheckController;
4445 return pController ->IsModified();
4447 /* -----------------------------19.01.00 11:29--------------------------------
4449 ---------------------------------------------------------------------------*/
4450 SwAutoMarkDlg_Impl::SwAutoMarkDlg_Impl(Window* pParent, const String& rAutoMarkURL,
4451 const String& rAutoMarkType, sal_Bool bCreate) :
4452 ModalDialog(pParent, SW_RES(DLG_CREATE_AUTOMARK)),
4453 aOKPB( this, SW_RES(PB_OK )),
4454 aCancelPB( this, SW_RES(PB_CANCEL )),
4455 aHelpPB( this, SW_RES(PB_HELP )),
4456 aEntriesBB( this, SW_RES(BB_ENTRIES )),
4457 aEntriesFL( this, SW_RES(FL_ENTRIES )),
4458 sAutoMarkURL(rAutoMarkURL),
4459 sAutoMarkType(rAutoMarkType),
4460 bCreateMode(bCreate)
4462 FreeResource();
4463 aOKPB.SetClickHdl(LINK(this, SwAutoMarkDlg_Impl, OkHdl));
4465 String sTitle = GetText();
4466 sTitle.AppendAscii( RTL_CONSTASCII_STRINGPARAM(": "));
4467 sTitle += sAutoMarkURL;
4468 SetText(sTitle);
4469 sal_Bool bError = sal_False;
4470 if( bCreateMode )
4471 aEntriesBB.RowInserted(0, 1, sal_True);
4472 else
4474 SfxMedium aMed( sAutoMarkURL, STREAM_STD_READ, FALSE );
4475 if( aMed.GetInStream() && !aMed.GetInStream()->GetError() )
4476 aEntriesBB.ReadEntries( *aMed.GetInStream() );
4477 else
4478 bError = sal_True;
4481 if(bError)
4482 EndDialog(RET_CANCEL);
4484 /* -----------------------------19.01.00 11:12--------------------------------
4486 ---------------------------------------------------------------------------*/
4487 SwAutoMarkDlg_Impl::~SwAutoMarkDlg_Impl()
4490 /* -----------------------------19.01.00 16:43--------------------------------
4492 ---------------------------------------------------------------------------*/
4493 IMPL_LINK(SwAutoMarkDlg_Impl, OkHdl, OKButton*, EMPTYARG)
4495 sal_Bool bError = sal_False;
4496 if(aEntriesBB.IsModified() || bCreateMode)
4498 SfxMedium aMed( sAutoMarkURL,
4499 bCreateMode ? STREAM_WRITE
4500 : STREAM_WRITE| STREAM_TRUNC,
4501 FALSE );
4502 SvStream* pStrm = aMed.GetOutStream();
4503 pStrm->SetStreamCharSet( RTL_TEXTENCODING_MS_1253 );
4504 if( !pStrm->GetError() )
4506 aEntriesBB.WriteEntries( *pStrm );
4507 aMed.Commit();
4509 else
4510 bError = sal_True;
4512 if( !bError )
4513 EndDialog(RET_OK);
4514 return 0;