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