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