LibreOffice Module sw (master)  1
cnttab.cxx
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3  * This file is part of the LibreOffice project.
4  *
5  * This Source Code Form is subject to the terms of the Mozilla Public
6  * License, v. 2.0. If a copy of the MPL was not distributed with this
7  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8  *
9  * This file incorporates work covered by the following license notice:
10  *
11  * Licensed to the Apache Software Foundation (ASF) under one or more
12  * contributor license agreements. See the NOTICE file distributed
13  * with this work for additional information regarding copyright
14  * ownership. The ASF licenses this file to you under the Apache
15  * License, Version 2.0 (the "License"); you may not use this file
16  * except in compliance with the License. You may obtain a copy of
17  * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18  */
19 
20 #include <config_folders.h>
21 
22 #include <sal/log.hxx>
23 #include <svl/style.hxx>
24 #include <vcl/help.hxx>
25 #include <vcl/weld.hxx>
26 #include <svl/stritem.hxx>
27 #include <svl/urihelper.hxx>
28 #include <unotools/pathoptions.hxx>
29 #include <sfx2/request.hxx>
30 #include <sfx2/viewfrm.hxx>
31 #include <sfx2/dispatch.hxx>
32 #include <sfx2/docfile.hxx>
33 #include <svx/dialogs.hrc>
34 #include <svx/svxdlg.hxx>
35 #include <svx/flagsdef.hxx>
36 #include <svx/svxids.hrc>
37 #include <com/sun/star/ui/dialogs/TemplateDescription.hpp>
38 #include <com/sun/star/ui/dialogs/XFilePicker3.hpp>
39 #include <com/sun/star/ui/dialogs/XFilterManager.hpp>
42 #include <editeng/unolingu.hxx>
43 #include <column.hxx>
44 #include <fmtfsize.hxx>
45 #include <shellio.hxx>
46 #include <authfld.hxx>
47 #include <swtypes.hxx>
48 #include <wrtsh.hxx>
49 #include <view.hxx>
50 #include <basesh.hxx>
51 #include <outline.hxx>
52 #include <cnttab.hxx>
53 #include <swuicnttab.hxx>
54 #include <poolfmt.hxx>
55 #include <strings.hrc>
56 #include <uitool.hxx>
57 #include <fmtcol.hxx>
58 #include <fldbas.hxx>
59 #include <expfld.hxx>
60 #include <unotools.hxx>
61 #include <unotxdoc.hxx>
62 #include <docsh.hxx>
63 #include <swmodule.hxx>
64 #include <modcfg.hxx>
65 
66 #include <cmdid.h>
67 #include <globals.hrc>
68 #include <cnttab.hrc>
69 #include <SwStyleNameMapper.hxx>
70 #include <sfx2/filedlghelper.hxx>
71 #include <toxwrap.hxx>
72 #include <chpfld.hxx>
73 
74 #include <sfx2/app.hxx>
75 
76 #include <unomid.h>
77 
78 #include <cmath>
79 #include <memory>
80 #include <vector>
81 #include <numeric>
82 
83 
84 using namespace ::com::sun::star;
85 using namespace ::com::sun::star::lang;
86 using namespace ::com::sun::star::uno;
87 using namespace com::sun::star::ui::dialogs;
88 using namespace ::sfx2;
90 
91 static const sal_Unicode aDeliStart = '['; // for the form
92 static const sal_Unicode aDeliEnd = ']'; // for the form
93 
94 static OUString lcl_CreateAutoMarkFileDlg(weld::Window* pParent, const OUString& rURL,
95  const OUString& rFileString, bool bOpen)
96 {
97  OUString sRet;
98 
99  FileDialogHelper aDlgHelper( bOpen ?
100  TemplateDescription::FILEOPEN_SIMPLE : TemplateDescription::FILESAVE_AUTOEXTENSION,
101  FileDialogFlags::NONE, pParent);
102  uno::Reference < XFilePicker3 > xFP = aDlgHelper.GetFilePicker();
103 
104  xFP->appendFilter( rFileString, "*.sdi" );
105  xFP->setCurrentFilter( rFileString ) ;
106 
107  if( !rURL.isEmpty() )
108  xFP->setDisplayDirectory( rURL );
109  else
110  {
111  SvtPathOptions aPathOpt;
112  xFP->setDisplayDirectory( aPathOpt.GetUserConfigPath() );
113  }
114 
115  if( aDlgHelper.Execute() == ERRCODE_NONE )
116  {
117  sRet = xFP->getSelectedFiles().getConstArray()[0];
118  }
119 
120  return sRet;
121 }
122 
123 namespace {
124 
125 struct AutoMarkEntry
126 {
127  OUString sSearch;
128  OUString sAlternative;
129  OUString sPrimKey;
130  OUString sSecKey;
131  OUString sComment;
132  bool bCase;
133  bool bWord;
134 
135  AutoMarkEntry() :
136  bCase(false),
137  bWord(false){}
138 };
139 
140 }
141 
142 typedef ::svt::EditBrowseBox SwEntryBrowseBox_Base;
143 
144 namespace {
145 
146 class SwEntryBrowseBox : public SwEntryBrowseBox_Base
147 {
148  VclPtr<Edit> m_aCellEdit;
149  VclPtr< ::svt::CheckBoxControl> m_aCellCheckBox;
150 
151  OUString m_sSearch;
152  OUString m_sAlternative;
153  OUString m_sPrimKey;
154  OUString m_sSecKey;
155  OUString m_sComment;
156  OUString m_sCaseSensitive;
157  OUString m_sWordOnly;
158  OUString m_sYes;
159  OUString m_sNo;
160 
161  std::vector<std::unique_ptr<AutoMarkEntry>> m_Entries;
162 
163  ::svt::CellControllerRef m_xController;
164  ::svt::CellControllerRef m_xCheckController;
165 
166  long m_nCurrentRow;
167  bool m_bModified;
168 
169 protected:
170  virtual bool SeekRow( long nRow ) override;
171  virtual void PaintCell(OutputDevice& rDev, const tools::Rectangle& rRect, sal_uInt16 nColId) const override;
172  virtual void InitController(::svt::CellControllerRef& rController, long nRow, sal_uInt16 nCol) override;
173  virtual ::svt::CellController* GetController(long nRow, sal_uInt16 nCol) override;
174  virtual bool SaveModified() override;
175 
176  std::vector<long> GetOptimalColWidths() const;
177 
178 public:
179  SwEntryBrowseBox(const css::uno::Reference<css::awt::XWindow> &rParent);
180  virtual ~SwEntryBrowseBox() override;
181  virtual void dispose() override;
182  void ReadEntries(SvStream& rInStr);
183  void WriteEntries(SvStream& rOutStr);
184 
185  bool IsModified()const override;
186 
187  virtual OUString GetCellText( long nRow, sal_uInt16 nColumn ) const override;
188  virtual void Resize() override;
189  virtual Size GetOptimalSize() const override;
190 };
191 
192 class SwAutoMarkDlg_Impl : public weld::GenericDialogController
193 {
194  OUString sAutoMarkURL;
195  bool bCreateMode;
196 
197  std::unique_ptr<weld::Button> m_xOKPB;
198  std::unique_ptr<weld::Container> m_xTable;
199  css::uno::Reference<css::awt::XWindow> m_xTableCtrlParent;
200  VclPtr<SwEntryBrowseBox> m_xEntriesBB;
201 
202  DECL_LINK(OkHdl, weld::Button&, void);
203 public:
204  SwAutoMarkDlg_Impl(weld::Window* pParent, const OUString& rAutoMarkURL,
205  bool bCreate);
206  virtual ~SwAutoMarkDlg_Impl() override;
207 };
208 
209 }
210 
211 sal_uInt16 CurTOXType::GetFlatIndex() const
212 {
213  return static_cast< sal_uInt16 >( (eType == TOX_USER && nIndex)
214  ? TOX_AUTHORITIES + nIndex : eType );
215 }
216 
218  SwWrtShell &rShell, SwTOXBase* pCurTOX,
219  sal_uInt16 nToxType, bool bGlobal)
220  : SfxTabDialogController(pParent, "modules/swriter/ui/tocdialog.ui", "TocDialog", &rSet)
221  , m_pMgr( new SwTOXMgr( &rShell ) )
222  , m_rWrtShell(rShell)
223  , m_pParamTOXBase(pCurTOX)
224  , m_sUserDefinedIndex(SwResId(STR_USER_DEFINED_INDEX))
225  , m_nInitialTOXType(nToxType)
226  , m_bEditTOX(false)
227  , m_bExampleCreated(false)
228  , m_bGlobalFlag(bGlobal)
229  , m_xShowExampleCB(m_xBuilder->weld_check_button("showexample"))
230 {
233 
234  const sal_uInt16 nUserTypeCount = m_rWrtShell.GetTOXTypeCount(TOX_USER);
235  m_vTypeData.resize(nUserTypeCount + 6);
236  //the standard user index is on position TOX_USER
237  //all user indexes follow after position TOX_AUTHORITIES
238  if(pCurTOX)
239  {
240  m_bEditTOX = true;
241  }
242  for(int i = m_vTypeData.size() - 1; i > -1; i--)
243  {
244  m_vTypeData[i].m_pxIndexSections.reset(new SwIndexSections_Impl);
245  if(pCurTOX)
246  {
247  m_eCurrentTOXType.eType = pCurTOX->GetType();
248  sal_uInt16 nArrayIndex = static_cast< sal_uInt16 >(m_eCurrentTOXType.eType);
250  {
251  //which user type is it?
252  for(sal_uInt16 nUser = 0; nUser < nUserTypeCount; nUser++)
253  {
254  const SwTOXType* pTemp = m_rWrtShell.GetTOXType(TOX_USER, nUser);
255  if(pCurTOX->GetTOXType() == pTemp)
256  {
257  m_eCurrentTOXType.nIndex = nUser;
258  nArrayIndex = static_cast< sal_uInt16 >(nUser > 0 ? TOX_AUTHORITIES + nUser : TOX_USER);
259  break;
260  }
261  }
262  }
263  m_vTypeData[nArrayIndex].m_pForm.reset(new SwForm(pCurTOX->GetTOXForm()));
264  m_vTypeData[nArrayIndex].m_pDescription = CreateTOXDescFromTOXBase(pCurTOX);
266  {
267  const SwAuthorityFieldType* pFType = static_cast<const SwAuthorityFieldType*>(
269  if(pFType)
270  {
271  OUString sBrackets;
272  if(pFType->GetPrefix())
273  sBrackets += OUStringChar(pFType->GetPrefix());
274  if(pFType->GetSuffix())
275  sBrackets += OUStringChar(pFType->GetSuffix());
276  m_vTypeData[nArrayIndex].m_pDescription->SetAuthBrackets(sBrackets);
277  m_vTypeData[nArrayIndex].m_pDescription->SetAuthSequence(pFType->IsSequence());
278  }
279  else
280  {
281  m_vTypeData[nArrayIndex].m_pDescription->SetAuthBrackets("[]");
282  }
283  }
284  }
285  }
287  AddTabPage("index", SwTOXSelectTabPage::Create, nullptr);
288  AddTabPage("styles", SwTOXStylesTabPage::Create, nullptr);
289  AddTabPage("columns", SwColumnPage::Create, nullptr);
290  AddTabPage("background", pFact->GetTabPageCreatorFunc(RID_SVXPAGE_BKG), nullptr);
291  AddTabPage("entries", SwTOXEntryTabPage::Create, nullptr);
292  if (!pCurTOX)
293  SetCurPageId("index");
294 
295  m_xShowExampleCB->connect_toggled(LINK(this, SwMultiTOXTabDialog, ShowPreviewHdl));
296  m_xShowExampleCB->set_active(SW_MOD()->GetModuleConfig()->IsShowIndexPreview());
297 
298  ShowPreviewHdl(*m_xShowExampleCB);
299 }
300 
302 {
303  SW_MOD()->GetModuleConfig()->SetShowIndexPreview(m_xShowExampleCB->get_active());
304 }
305 
306 void SwMultiTOXTabDialog::PageCreated(const OString& rId, SfxTabPage &rPage)
307 {
308  if (rId == "background")
309  {
310  SfxAllItemSet aSet(*(GetInputSetImpl()->GetPool()));
311  aSet.Put (SfxUInt32Item(SID_FLAG_TYPE, static_cast<sal_uInt32>(SvxBackgroundTabFlags::SHOW_SELECTOR)));
312  rPage.PageCreated(aSet);
313  }
314  else if (rId == "columns")
315  {
317 
318  static_cast<SwColumnPage&>(rPage).SetPageWidth(rSize.GetWidth());
319  }
320  else if (rId == "entries")
321  static_cast<SwTOXEntryTabPage&>(rPage).SetWrtShell(m_rWrtShell);
322  else if (rId == "index")
323  {
324  static_cast<SwTOXSelectTabPage&>(rPage).SetWrtShell(m_rWrtShell);
326  static_cast<SwTOXSelectTabPage&>(rPage).SelectType(static_cast<TOXTypes>(m_nInitialTOXType));
327  }
328 }
329 
331 {
332  short nRet = SfxTabDialogController::Ok();
335 
336  const sal_uInt16 nIndex = m_eCurrentTOXType.GetFlatIndex();
337  if(m_vTypeData[nIndex].m_pForm)
338  {
339  rDesc.SetForm(*m_vTypeData[nIndex].m_pForm);
340  aNewDef.SetTOXForm(*m_vTypeData[nIndex].m_pForm);
341  }
342  rDesc.ApplyTo(aNewDef);
343  if(!m_bGlobalFlag)
344  m_pMgr->UpdateOrInsertTOX(
345  rDesc, nullptr, GetOutputItemSet());
346  else if(m_bEditTOX)
347  m_pMgr->UpdateOrInsertTOX(
348  rDesc, &m_pParamTOXBase, GetOutputItemSet());
349 
352 
353  return nRet;
354 }
355 
357 {
358  const sal_uInt16 nIndex = eType.GetFlatIndex();
359  if(!m_vTypeData[nIndex].m_pForm)
360  m_vTypeData[nIndex].m_pForm.reset(new SwForm(eType.eType));
361  return m_vTypeData[nIndex].m_pForm.get();
362 }
363 
365 {
366  const sal_uInt16 nIndex = eType.GetFlatIndex();
367  if(!m_vTypeData[nIndex].m_pDescription)
368  {
369  const SwTOXBase* pDef = m_rWrtShell.GetDefaultTOXBase( eType.eType );
370  if(pDef)
371  m_vTypeData[nIndex].m_pDescription = CreateTOXDescFromTOXBase(pDef);
372  else
373  {
374  m_vTypeData[nIndex].m_pDescription.reset(new SwTOXDescription(eType.eType));
375  if(eType.eType == TOX_USER)
376  m_vTypeData[nIndex].m_pDescription->SetTitle(m_sUserDefinedIndex);
377  else
378  m_vTypeData[nIndex].m_pDescription->SetTitle(
379  m_rWrtShell.GetTOXType(eType.eType, 0)->GetTypeName());
380  }
381  if(TOX_AUTHORITIES == eType.eType)
382  {
383  const SwAuthorityFieldType* pFType = static_cast<const SwAuthorityFieldType*>(
385  if(pFType)
386  {
387  m_vTypeData[nIndex].m_pDescription->SetAuthBrackets(OUStringChar(pFType->GetPrefix()) +
388  OUStringChar(pFType->GetSuffix()));
389  m_vTypeData[nIndex].m_pDescription->SetAuthSequence(pFType->IsSequence());
390  }
391  else
392  {
393  m_vTypeData[nIndex].m_pDescription->SetAuthBrackets("[]");
394  }
395  }
396  else if(TOX_INDEX == eType.eType)
397  m_vTypeData[nIndex].m_pDescription->SetMainEntryCharStyle(SwResId(STR_POOLCHR_IDX_MAIN_ENTRY));
398 
399  }
400  return *m_vTypeData[nIndex].m_pDescription;
401 }
402 
403 std::unique_ptr<SwTOXDescription> SwMultiTOXTabDialog::CreateTOXDescFromTOXBase(
404  const SwTOXBase*pCurTOX)
405 {
406  std::unique_ptr<SwTOXDescription> pDesc(new SwTOXDescription(pCurTOX->GetType()));
407  for(sal_uInt16 i = 0; i < MAXLEVEL; i++)
408  pDesc->SetStyleNames(pCurTOX->GetStyleNames(i), i);
409  pDesc->SetAutoMarkURL(m_rWrtShell.GetTOIAutoMarkURL());
410  pDesc->SetTitle(pCurTOX->GetTitle());
411 
412  pDesc->SetContentOptions(pCurTOX->GetCreateType());
413  if(pDesc->GetTOXType() == TOX_INDEX)
414  pDesc->SetIndexOptions(pCurTOX->GetOptions());
415  pDesc->SetMainEntryCharStyle(pCurTOX->GetMainEntryCharStyle());
416  if(pDesc->GetTOXType() != TOX_INDEX)
417  pDesc->SetLevel(static_cast<sal_uInt8>(pCurTOX->GetLevel()));
418  pDesc->SetCreateFromObjectNames(pCurTOX->IsFromObjectNames());
419  pDesc->SetSequenceName(pCurTOX->GetSequenceName());
420  pDesc->SetCaptionDisplay(pCurTOX->GetCaptionDisplay());
421  pDesc->SetFromChapter(pCurTOX->IsFromChapter());
422  pDesc->SetReadonly(pCurTOX->IsProtected());
423  pDesc->SetOLEOptions(pCurTOX->GetOLEOptions());
424  pDesc->SetLevelFromChapter(pCurTOX->IsLevelFromChapter());
425  pDesc->SetLanguage(pCurTOX->GetLanguage());
426  pDesc->SetSortAlgorithm(pCurTOX->GetSortAlgorithm());
427  return pDesc;
428 }
429 
431 {
432  if (m_xShowExampleCB->get_active())
433  {
434  if(!m_xExampleFrame && !m_bExampleCreated)
435  {
436  m_bExampleCreated = true;
437  OUString sTemplate("internal/idxexample.odt");
438 
439  SvtPathOptions aOpt;
440  bool bExist = aOpt.SearchFile( sTemplate, SvtPathOptions::PATH_TEMPLATE );
441 
442  if(!bExist)
443  {
444  OUString sInfo(SwResId(STR_FILE_NOT_FOUND));
445  sInfo = sInfo.replaceFirst( "%1", sTemplate );
446  sInfo = sInfo.replaceFirst( "%2", aOpt.GetTemplatePath() );
447  std::unique_ptr<weld::MessageDialog> xInfoBox(Application::CreateMessageDialog(m_xDialog.get(),
448  VclMessageType::Info, VclButtonsType::Ok,
449  sInfo));
450  xInfoBox->run();
451  }
452  else
453  {
454  Link<SwOneExampleFrame&,void> aLink(LINK(this, SwMultiTOXTabDialog, CreateExample_Hdl));
455  m_xExampleFrame.reset(new SwOneExampleFrame(EX_SHOW_ONLINE_LAYOUT, &aLink, &sTemplate));
456  m_xExampleFrameWin.reset(new weld::CustomWeld(*m_xBuilder, "example", *m_xExampleFrame));
457  }
458  m_xShowExampleCB->set_visible(m_xExampleFrame != nullptr);
459  }
460  }
461 
462  if (m_xExampleFrame)
463  {
464  const bool bSetViewWindow = m_xShowExampleCB->get_active();
465  if (bSetViewWindow)
466  m_xExampleFrame->Show();
467  else
468  m_xExampleFrame->Hide();
469  }
470 
471  m_xDialog->resize_to_request();
472 }
473 
474 bool SwMultiTOXTabDialog::IsNoNum(SwWrtShell& rSh, const OUString& rName)
475 {
476  SwTextFormatColl* pColl = rSh.GetParaStyle(rName);
477  if(pColl && ! pColl->IsAssignedToListLevelOfOutlineStyle())
478  return true;
479 
480  const sal_uInt16 nId = SwStyleNameMapper::GetPoolIdFromUIName(
482  return nId != USHRT_MAX &&
484 }
485 
486 namespace {
487 
488 class SwAddStylesDlg_Impl : public SfxDialogController
489 {
490  OUString* pStyleArr;
491 
492  std::unique_ptr<weld::Button> m_xOk;
493  std::unique_ptr<weld::Button> m_xLeftPB;
494  std::unique_ptr<weld::Button> m_xRightPB;
495  std::unique_ptr<weld::TreeView> m_xHeaderTree;
496 
497  DECL_LINK(OkHdl, weld::Button&, void);
498  DECL_LINK(LeftRightHdl, weld::Button&, void);
499  DECL_LINK(KeyInput, const KeyEvent&, bool);
500  DECL_LINK(TreeSizeAllocHdl, const Size&, void);
501  typedef std::pair<int, int> row_col;
502  DECL_LINK(RadioToggleOnHdl, const row_col&, void);
503 
504 public:
505  SwAddStylesDlg_Impl(weld::Window* pParent, SwWrtShell const & rWrtSh, OUString rStringArr[]);
506 };
507 
508 }
509 
510 SwAddStylesDlg_Impl::SwAddStylesDlg_Impl(weld::Window* pParent,
511  SwWrtShell const & rWrtSh, OUString rStringArr[])
512  : SfxDialogController(pParent, "modules/swriter/ui/assignstylesdialog.ui", "AssignStylesDialog")
513  , pStyleArr(rStringArr)
514  , m_xOk(m_xBuilder->weld_button("ok"))
515  , m_xLeftPB(m_xBuilder->weld_button("left"))
516  , m_xRightPB(m_xBuilder->weld_button("right"))
517  , m_xHeaderTree(m_xBuilder->weld_tree_view("styles"))
518 {
519  m_xOk->connect_clicked(LINK(this, SwAddStylesDlg_Impl, OkHdl));
520  m_xLeftPB->connect_clicked(LINK(this, SwAddStylesDlg_Impl, LeftRightHdl));
521  m_xRightPB->connect_clicked(LINK(this, SwAddStylesDlg_Impl, LeftRightHdl));
522  m_xHeaderTree->connect_size_allocate(LINK(this, SwAddStylesDlg_Impl, TreeSizeAllocHdl));
523 
524  std::vector<int> aRadioColumns;
525  for (sal_uInt16 i = 0; i <= MAXLEVEL; ++i)
526  aRadioColumns.push_back(i + 1);
527  m_xHeaderTree->set_toggle_columns_as_radio(aRadioColumns);
528  m_xHeaderTree->connect_toggled(LINK(this, SwAddStylesDlg_Impl, RadioToggleOnHdl));
529 
530  std::vector<int> aWidths;
531  aWidths.push_back(m_xHeaderTree->get_approximate_digit_width() * 30);
532  int nPadding = m_xHeaderTree->get_approximate_digit_width() * 2;
533  OUString sTitle(m_xHeaderTree->get_column_title(1));
534  for (sal_uInt16 i = 0; i <= MAXLEVEL; ++i)
535  {
536  sTitle = OUString::number(i);
537  m_xHeaderTree->set_column_title(i + 1, sTitle);
538  aWidths.push_back(m_xHeaderTree->get_pixel_size(sTitle).Width() + nPadding);
539  }
540  m_xHeaderTree->set_column_fixed_widths(aWidths);
541  auto nWidth = std::accumulate(aWidths.begin(), aWidths.end(), 0);
542  m_xHeaderTree->set_size_request(nWidth, m_xHeaderTree->get_height_rows(15));
543 
544  int nRow(0);
545  for (sal_uInt16 i = 0; i < MAXLEVEL; ++i)
546  {
547  const OUString &rStyles{rStringArr[i]};
548  if (rStyles.isEmpty())
549  continue;
550  sal_Int32 nPos(0);
551  do
552  {
553  OUString sEntry = rStyles.getToken(0, TOX_STYLE_DELIMITER, nPos);
554  m_xHeaderTree->append_text(sEntry);
555  for (sal_uInt16 j = 0; j <= MAXLEVEL; ++j)
556  {
557  TriState eState = i == j - 1 ? TRISTATE_TRUE : TRISTATE_FALSE;
558  m_xHeaderTree->set_toggle(nRow, eState, j + 1);
559  }
560  ++nRow;
561  } while (nPos>=0);
562  }
563  // now the other styles
564 
565  const sal_uInt16 nSz = rWrtSh.GetTextFormatCollCount();
566  for (sal_uInt16 j = 0; j < nSz; ++j)
567  {
568  const SwTextFormatColl& rColl = rWrtSh.GetTextFormatColl(j);
569  if (rColl.IsDefault())
570  continue;
571 
572  const OUString aName = rColl.GetName();
573  if (!aName.isEmpty())
574  {
575  bool bEntry = false;
576  int nChildren = m_xHeaderTree->n_children();
577  for (int i = 0; i < nChildren; ++i)
578  {
579  if (m_xHeaderTree->get_text(i, 0) == aName)
580  {
581  bEntry = true;
582  break;
583  }
584  }
585  if (!bEntry)
586  {
587  m_xHeaderTree->append_text(aName);
588  for (sal_uInt16 k = 0; k <= MAXLEVEL; ++k)
589  {
590  TriState eState = k == 0 ? TRISTATE_TRUE : TRISTATE_FALSE;
591  m_xHeaderTree->set_toggle(nRow, eState, k + 1);
592  }
593  ++nRow;
594  }
595  }
596  }
597  m_xHeaderTree->make_sorted();
598  m_xHeaderTree->select(0);
599  m_xHeaderTree->connect_key_release(LINK(this, SwAddStylesDlg_Impl, KeyInput));
600 }
601 
602 IMPL_LINK(SwAddStylesDlg_Impl, TreeSizeAllocHdl, const Size&, rSize, void)
603 {
604  auto nWidth = rSize.Width();
605 
606  std::vector<int> aWidths;
607  aWidths.push_back(0);
608  int nPadding = m_xHeaderTree->get_approximate_digit_width() * 2;
609  for (sal_uInt16 i = 0; i <= MAXLEVEL; ++i)
610  {
611  OUString sTitle(m_xHeaderTree->get_column_title(i + 1));
612  aWidths.push_back(m_xHeaderTree->get_pixel_size(sTitle).Width() + nPadding);
613  }
614  auto nOtherWidth = std::accumulate(aWidths.begin(), aWidths.end(), 0);
615  aWidths[0] = nWidth - nOtherWidth;
616  m_xHeaderTree->set_column_fixed_widths(aWidths);
617 }
618 
619 IMPL_LINK(SwAddStylesDlg_Impl, RadioToggleOnHdl, const row_col&, rRowCol, void)
620 {
621  for (sal_uInt16 i = 0; i <= MAXLEVEL; ++i)
622  {
623  TriState eState = rRowCol.second == i + 1 ? TRISTATE_TRUE : TRISTATE_FALSE;
624  m_xHeaderTree->set_toggle(rRowCol.first, eState, i + 1);
625  }
626 }
627 
628 IMPL_LINK(SwAddStylesDlg_Impl, KeyInput, const KeyEvent&, rKEvt, bool)
629 {
630  vcl::KeyCode aCode = rKEvt.GetKeyCode();
631  bool bHandled = false;
632 
633  if (aCode.GetCode() == KEY_ADD || aCode.GetCode() == KEY_RIGHT)
634  {
635  LeftRightHdl(*m_xRightPB);
636  bHandled = true;
637  }
638  else if (aCode.GetCode() == KEY_SUBTRACT || aCode.GetCode() == KEY_LEFT)
639  {
640  LeftRightHdl(*m_xLeftPB);
641  bHandled = true;
642  }
643 
644  return bHandled;
645 }
646 
647 IMPL_LINK_NOARG(SwAddStylesDlg_Impl, OkHdl, weld::Button&, void)
648 {
649  for(sal_uInt16 i = 0; i < MAXLEVEL; i++)
650  pStyleArr[i].clear();
651 
652  int nChildren = m_xHeaderTree->n_children();
653  for (int i = 0; i < nChildren; ++i)
654  {
655  int nToggleColumn = 0;
656  for (sal_uInt16 j = 0; j <= MAXLEVEL; ++j)
657  {
658  if (m_xHeaderTree->get_toggle(i, j + 1) == TRISTATE_TRUE)
659  {
660  nToggleColumn = j;
661  break;
662  }
663  }
664  if (nToggleColumn)
665  {
666  int nLevel = nToggleColumn - 1;
667  if(!pStyleArr[nLevel].isEmpty())
668  pStyleArr[nLevel] += OUStringChar(TOX_STYLE_DELIMITER);
669  pStyleArr[nLevel] += m_xHeaderTree->get_text(i, 0);
670  }
671  }
672 
673  //TODO write back style names
674  m_xDialog->response(RET_OK);
675 }
676 
677 IMPL_LINK(SwAddStylesDlg_Impl, LeftRightHdl, weld::Button&, rBtn, void)
678 {
679  bool bLeft = &rBtn == m_xLeftPB.get();
680  int nEntry = m_xHeaderTree->get_selected_index();
681  if (nEntry != -1)
682  {
683  int nToggleColumn = 0;
684  for (sal_uInt16 j = 0; j <= MAXLEVEL; ++j)
685  {
686  if (m_xHeaderTree->get_toggle(nEntry, j + 1) == TRISTATE_TRUE)
687  {
688  nToggleColumn = j;
689  break;
690  }
691  }
692 
693  if (bLeft)
694  {
695  if (nToggleColumn)
696  --nToggleColumn;
697  }
698  else
699  {
700  if (nToggleColumn < MAXLEVEL)
701  ++nToggleColumn;
702  }
703 
704  for (sal_uInt16 j = 0; j <= MAXLEVEL; ++j)
705  {
706  m_xHeaderTree->set_toggle(nEntry, j == nToggleColumn ? TRISTATE_TRUE : TRISTATE_FALSE, j + 1);
707  }
708  }
709 }
710 
712  : SfxTabPage(pPage, pController, "modules/swriter/ui/tocindexpage.ui", "TocIndexPage", &rAttrSet)
713  , sAutoMarkType(SwResId(STR_AUTOMARK_TYPE))
714  , m_bWaitingInitialSettings(true)
715  , m_xTitleED(m_xBuilder->weld_entry("title"))
716  , m_xTypeFT(m_xBuilder->weld_label("typeft"))
717  , m_xTypeLB(m_xBuilder->weld_combo_box("type"))
718  , m_xReadOnlyCB(m_xBuilder->weld_check_button("readonly"))
719  , m_xAreaFrame(m_xBuilder->weld_widget("areaframe"))
720  , m_xAreaLB(m_xBuilder->weld_combo_box("scope"))
721  , m_xLevelFT(m_xBuilder->weld_label("levelft"))
722  , m_xLevelNF(m_xBuilder->weld_spin_button("level"))
723  , m_xCreateFrame(m_xBuilder->weld_widget("createframe"))
724  , m_xFromHeadingsCB(m_xBuilder->weld_check_button("fromheadings"))
725  , m_xStylesCB(m_xBuilder->weld_check_button("stylescb"))
726  , m_xAddStylesCB(m_xBuilder->weld_check_button("addstylescb"))
727  , m_xAddStylesPB(m_xBuilder->weld_button("styles"))
728  , m_xFromTablesCB(m_xBuilder->weld_check_button("fromtables"))
729  , m_xFromFramesCB(m_xBuilder->weld_check_button("fromframes"))
730  , m_xFromGraphicsCB(m_xBuilder->weld_check_button("fromgraphics"))
731  , m_xFromOLECB(m_xBuilder->weld_check_button("fromoles"))
732  , m_xLevelFromChapterCB(m_xBuilder->weld_check_button("uselevel"))
733  , m_xFromCaptionsRB(m_xBuilder->weld_radio_button("captions"))
734  , m_xFromObjectNamesRB(m_xBuilder->weld_radio_button("objnames"))
735  , m_xCaptionSequenceFT(m_xBuilder->weld_label("categoryft"))
736  , m_xCaptionSequenceLB(m_xBuilder->weld_combo_box("category"))
737  , m_xDisplayTypeFT(m_xBuilder->weld_label("displayft"))
738  , m_xDisplayTypeLB(m_xBuilder->weld_combo_box("display"))
739  , m_xTOXMarksCB(m_xBuilder->weld_check_button("indexmarks"))
740  , m_xIdxOptionsFrame(m_xBuilder->weld_widget("optionsframe"))
741  , m_xCollectSameCB(m_xBuilder->weld_check_button("combinesame"))
742  , m_xUseFFCB(m_xBuilder->weld_check_button("useff"))
743  , m_xUseDashCB(m_xBuilder->weld_check_button("usedash"))
744  , m_xCaseSensitiveCB(m_xBuilder->weld_check_button("casesens"))
745  , m_xInitialCapsCB(m_xBuilder->weld_check_button("initcaps"))
746  , m_xKeyAsEntryCB(m_xBuilder->weld_check_button("keyasentry"))
747  , m_xFromFileCB(m_xBuilder->weld_check_button("fromfile"))
748  , m_xAutoMarkPB(m_xBuilder->weld_menu_button("file"))
749  , m_xFromObjCLB(m_xBuilder->weld_tree_view("objects"))
750  , m_xFromObjFrame(m_xBuilder->weld_widget("objectframe"))
751  , m_xSequenceCB(m_xBuilder->weld_check_button("numberentries"))
752  , m_xBracketLB(m_xBuilder->weld_combo_box("brackets"))
753  , m_xAuthorityFrame(m_xBuilder->weld_widget("authframe"))
754  , m_xSortFrame(m_xBuilder->weld_widget("sortframe"))
755  , m_xLanguageLB(new SvxLanguageBox(m_xBuilder->weld_combo_box("lang")))
756  , m_xSortAlgorithmLB(m_xBuilder->weld_combo_box("keytype"))
757 {
758  sAddStyleUser = m_xStylesCB->get_label();
760 
761  m_xLanguageLB->SetLanguageList( SvxLanguageListFlags::ALL | SvxLanguageListFlags::ONLY_KNOWN,
762  false );
763 
764  //Default mode is arranged to be the tallest mode
765  //of alphabetical index, lock that size in now
766  LanguageHdl(nullptr); //fill sort algorithm list
767  Size aPrefSize(m_xContainer->get_preferred_size());
768  m_xContainer->set_size_request(aPrefSize.Width(), aPrefSize.Height());
769 
770  sAddStyleContent = m_xAddStylesCB->get_label();
771 
772  std::vector<int> aWidths;
773  aWidths.push_back(m_xFromObjCLB->get_checkbox_column_width());
774  m_xFromObjCLB->set_column_fixed_widths(aWidths);
775 
776  for (size_t i = 0; i < SAL_N_ELEMENTS(RES_SRCTYPES); ++i)
777  {
778  OUString sId(OUString::number(static_cast<sal_uInt32>(RES_SRCTYPES[i].second)));
779  m_xFromObjCLB->append();
780  m_xFromObjCLB->set_toggle(i, TRISTATE_FALSE, 0);
781  m_xFromObjCLB->set_text(i, SwResId(RES_SRCTYPES[i].first), 1);
782  m_xFromObjCLB->set_id(i, sId);
783  }
784 
786  m_xTypeLB->connect_changed(LINK(this, SwTOXSelectTabPage, TOXTypeHdl));
787 
788  m_xAddStylesPB->connect_clicked(LINK(this, SwTOXSelectTabPage, AddStylesHdl));
789 
790  m_xAutoMarkPB->connect_toggled(LINK(this, SwTOXSelectTabPage, MenuEnableHdl));
791  m_xAutoMarkPB->connect_selected(LINK(this, SwTOXSelectTabPage, MenuExecuteHdl));
792 
793  Link<weld::ToggleButton&,void> aLk = LINK(this, SwTOXSelectTabPage, CheckBoxHdl);
794  m_xAddStylesCB->connect_toggled(aLk);
795  m_xFromHeadingsCB->connect_toggled(aLk);
796  m_xTOXMarksCB->connect_toggled(aLk);
797  m_xFromFileCB->connect_toggled(aLk);
798  m_xCollectSameCB->connect_toggled(aLk);
799  m_xUseFFCB->connect_toggled(aLk);
800  m_xUseDashCB->connect_toggled(aLk);
801  m_xInitialCapsCB->connect_toggled(aLk);
802  m_xKeyAsEntryCB->connect_toggled(aLk);
803 
804  m_xTitleED->connect_changed(LINK(this, SwTOXSelectTabPage, ModifyEntryHdl));
805  m_xLevelNF->connect_value_changed(LINK(this, SwTOXSelectTabPage, ModifySpinHdl));
806  m_xSortAlgorithmLB->connect_changed(LINK(this, SwTOXSelectTabPage, ModifyListBoxHdl));
807 
808  aLk = LINK(this, SwTOXSelectTabPage, RadioButtonHdl);
809  m_xFromCaptionsRB->connect_toggled(aLk);
810  m_xFromObjectNamesRB->connect_toggled(aLk);
811  RadioButtonHdl(*m_xFromCaptionsRB);
812 
813  m_xLanguageLB->connect_changed(LINK(this, SwTOXSelectTabPage, LanguageListBoxHdl));
814  m_xTypeLB->set_active(0);
815  m_xTitleED->save_value();
816 }
817 
819 {
820  pIndexRes.reset();
821  pIndexEntryWrapper.reset();
822  m_xLanguageLB.reset();
823 }
824 
826 {
827  const sal_uInt16 nUserTypeCount = rSh.GetTOXTypeCount(TOX_USER);
828  if(nUserTypeCount > 1)
829  {
830  //insert all new user indexes names after the standard user index
831  sal_Int32 nPos = m_xTypeLB->find_id(OUString::number(sal_uInt32(TO_USER))) + 1;
832  for (sal_uInt16 nUser = 1; nUser < nUserTypeCount; nUser++)
833  {
834  sal_uInt32 nEntryData = nUser << 8;
835  nEntryData |= TO_USER;
836  OUString sId(OUString::number(nEntryData));
837  m_xTypeLB->insert(nPos++, rSh.GetTOXType(TOX_USER, nUser)->GetTypeName(),
838  &sId, nullptr, nullptr);
839  }
840  }
841 }
842 
844 {
845  return true;
846 }
847 
849 {
850  sal_uInt16 nRet = TOX_INDEX;
851  switch(eType.eType)
852  {
853  case TOX_INDEX : nRet = TO_INDEX; break;
854  case TOX_USER :
855  {
856  nRet = eType.nIndex << 8;
857  nRet |= TO_USER;
858  }
859  break;
860  case TOX_CONTENT : nRet = TO_CONTENT; break;
861  case TOX_ILLUSTRATIONS:nRet = TO_ILLUSTRATION; break;
862  case TOX_OBJECTS : nRet = TO_OBJECT; break;
863  case TOX_TABLES : nRet = TO_TABLE; break;
864  case TOX_AUTHORITIES : nRet = TO_AUTHORITIES; break;
865  case TOX_BIBLIOGRAPHY : nRet = TO_BIBLIOGRAPHY; break;
866  case TOX_CITATION :break;
867  }
868  return nRet;
869 }
870 
872 {
873  CurTOXType eCurType (eSet);
874 
875  sal_uInt32 nData = lcl_TOXTypesToUserData(eCurType);
876  m_xTypeLB->set_active_id(OUString::number(nData));
877  m_xTypeFT->set_sensitive(false);
878  m_xTypeLB->set_sensitive(false);
879  TOXTypeHdl(*m_xTypeLB);
880 }
881 
882 static CurTOXType lcl_UserData2TOXTypes(sal_uInt16 nData)
883 {
884  CurTOXType eRet;
885 
886  switch(nData&0xff)
887  {
888  case TO_INDEX : eRet.eType = TOX_INDEX; break;
889  case TO_USER :
890  {
891  eRet.eType = TOX_USER;
892  eRet.nIndex = (nData&0xff00) >> 8;
893  }
894  break;
895  case TO_CONTENT : eRet.eType = TOX_CONTENT; break;
896  case TO_ILLUSTRATION: eRet.eType = TOX_ILLUSTRATIONS; break;
897  case TO_OBJECT : eRet.eType = TOX_OBJECTS; break;
898  case TO_TABLE : eRet.eType = TOX_TABLES; break;
899  case TO_AUTHORITIES : eRet.eType = TOX_AUTHORITIES; break;
900  case TO_BIBLIOGRAPHY : eRet.eType = TOX_BIBLIOGRAPHY; break;
901  default: OSL_FAIL("what a type?");
902  }
903  return eRet;
904 }
905 
907 {
908  SwMultiTOXTabDialog* pTOXDlg = static_cast<SwMultiTOXTabDialog*>(GetDialogController());
909  const CurTOXType aCurType = pTOXDlg->GetCurrentTOXType();
910  SwTOXDescription& rDesc = pTOXDlg->GetTOXDescription(aCurType);
911  m_xReadOnlyCB->set_active(rDesc.IsReadonly());
912  if (!m_xTitleED->get_value_changed_from_saved())
913  {
914  if (rDesc.GetTitle())
915  m_xTitleED->set_text(*rDesc.GetTitle());
916  else
917  m_xTitleED->set_text(OUString());
918  m_xTitleED->save_value();
919  }
920 
921  m_xAreaLB->set_active(rDesc.IsFromChapter() ? 1 : 0);
922 
923  if (aCurType.eType != TOX_INDEX)
924  m_xLevelNF->set_value(rDesc.GetLevel()); //content, user
925 
926  SwTOXElement nCreateType = rDesc.GetContentOptions();
927 
928  //user + content
929  bool bHasStyleNames = false;
930 
931  for( sal_uInt16 i = 0; i < MAXLEVEL; i++)
932  if(!rDesc.GetStyleNames(i).isEmpty())
933  {
934  bHasStyleNames = true;
935  break;
936  }
937  m_xAddStylesCB->set_active(bHasStyleNames && (nCreateType & SwTOXElement::Template));
938 
939  m_xFromOLECB->set_active( bool(nCreateType & SwTOXElement::Ole) );
940  m_xFromTablesCB->set_active( bool(nCreateType & SwTOXElement::Table) );
941  m_xFromGraphicsCB->set_active( bool(nCreateType & SwTOXElement::Graphic) );
942  m_xFromFramesCB->set_active( bool(nCreateType & SwTOXElement::Frame) );
943 
944  m_xLevelFromChapterCB->set_active(rDesc.IsLevelFromChapter());
945 
946  //all but illustration and table
947  m_xTOXMarksCB->set_active( bool(nCreateType & SwTOXElement::Mark) );
948 
949  //content
950  if(TOX_CONTENT == aCurType.eType)
951  {
952  m_xFromHeadingsCB->set_active( bool(nCreateType & SwTOXElement::OutlineLevel) );
953  m_xAddStylesCB->set_label(sAddStyleContent);
954  m_xAddStylesPB->set_sensitive(m_xAddStylesCB->get_active());
955  }
956  //index only
957  else if(TOX_INDEX == aCurType.eType)
958  {
959  const SwTOIOptions nIndexOptions = rDesc.GetIndexOptions();
960  m_xCollectSameCB->set_active( bool(nIndexOptions & SwTOIOptions::SameEntry) );
961  m_xUseFFCB->set_active( bool(nIndexOptions & SwTOIOptions::FF) );
962  m_xUseDashCB->set_active( bool(nIndexOptions & SwTOIOptions::Dash) );
963  if (m_xUseFFCB->get_active())
964  m_xUseDashCB->set_sensitive(false);
965  else if (m_xUseDashCB->get_active())
966  m_xUseFFCB->set_sensitive(false);
967 
968  m_xCaseSensitiveCB->set_active( bool(nIndexOptions & SwTOIOptions::CaseSensitive) );
969  m_xInitialCapsCB->set_active( bool(nIndexOptions & SwTOIOptions::InitialCaps) );
970  m_xKeyAsEntryCB->set_active( bool(nIndexOptions & SwTOIOptions::KeyAsEntry) );
971  }
972  else if (TOX_ILLUSTRATIONS == aCurType.eType || TOX_TABLES == aCurType.eType)
973  {
974  m_xFromObjectNamesRB->set_active(rDesc.IsCreateFromObjectNames());
975  m_xFromCaptionsRB->set_active(!rDesc.IsCreateFromObjectNames());
976  OUString sName(rDesc.GetSequenceName());
977  int nIndex = m_xCaptionSequenceLB->find_text(sName);
978  if (nIndex != -1)
979  m_xCaptionSequenceLB->set_active(nIndex);
980  m_xDisplayTypeLB->set_active(static_cast<sal_Int32>(rDesc.GetCaptionDisplay()));
981  if (m_xDisplayTypeLB->get_active() == -1)
982  m_xDisplayTypeLB->set_active(0);
983  RadioButtonHdl(*m_xFromCaptionsRB);
984 
985  }
986  else if(TOX_OBJECTS == aCurType.eType)
987  {
988  SwTOOElements nOLEData = rDesc.GetOLEOptions();
989  for (int nFromObj = 0, nCount = m_xFromObjCLB->n_children(); nFromObj < nCount; ++nFromObj)
990  {
991  SwTOOElements nData = static_cast<SwTOOElements>(m_xFromObjCLB->get_id(nFromObj).toInt32());
992  m_xFromObjCLB->set_toggle(nFromObj, bool(nData & nOLEData) ? TRISTATE_TRUE : TRISTATE_FALSE, 0);
993  }
994  }
995  else if(TOX_AUTHORITIES == aCurType.eType)
996  {
997  const OUString& sBrackets(rDesc.GetAuthBrackets());
998  if(sBrackets.isEmpty() || sBrackets == " ")
999  m_xBracketLB->set_active(0);
1000  else
1001  m_xBracketLB->set_active_text(sBrackets);
1002  m_xSequenceCB->set_active(rDesc.IsAuthSequence());
1003  }
1004  m_xAutoMarkPB->set_sensitive(m_xFromFileCB->get_active());
1005 
1006  for(sal_uInt16 i = 0; i < MAXLEVEL; i++)
1007  aStyleArr[i] = rDesc.GetStyleNames(i);
1008 
1009  m_xLanguageLB->set_active_id(rDesc.GetLanguage());
1010  LanguageHdl(nullptr);
1011  for (int nCnt = 0, nEntryCount = m_xSortAlgorithmLB->get_count(); nCnt < nEntryCount; ++nCnt)
1012  {
1013  const OUString& rEntryData = m_xSortAlgorithmLB->get_id(nCnt);
1014  if (rEntryData == rDesc.GetSortAlgorithm())
1015  {
1016  m_xSortAlgorithmLB->set_active(nCnt);
1017  break;
1018  }
1019  }
1020 }
1021 
1023 {
1024  SwMultiTOXTabDialog* pTOXDlg = static_cast<SwMultiTOXTabDialog*>(GetDialogController());
1025  CurTOXType aCurType = pTOXDlg->GetCurrentTOXType();
1026  SwTOXDescription& rDesc = pTOXDlg->GetTOXDescription(aCurType);
1027  rDesc.SetTitle(m_xTitleED->get_text());
1028  rDesc.SetFromChapter(1 == m_xAreaLB->get_active());
1029  SwTOXElement nContentOptions = SwTOXElement::NONE;
1030  if (m_xTOXMarksCB->get_visible() && m_xTOXMarksCB->get_active())
1031  nContentOptions |= SwTOXElement::Mark;
1032 
1034  switch(rDesc.GetTOXType())
1035  {
1036  case TOX_CONTENT:
1037  if(m_xFromHeadingsCB->get_active())
1038  nContentOptions |= SwTOXElement::OutlineLevel;
1039  break;
1040  case TOX_USER:
1041  {
1042  rDesc.SetTOUName(m_xTypeLB->get_active_text());
1043 
1044  if(m_xFromOLECB->get_active())
1045  nContentOptions |= SwTOXElement::Ole;
1046  if(m_xFromTablesCB->get_active())
1047  nContentOptions |= SwTOXElement::Table;
1048  if(m_xFromFramesCB->get_active())
1049  nContentOptions |= SwTOXElement::Frame;
1050  if(m_xFromGraphicsCB->get_active())
1051  nContentOptions |= SwTOXElement::Graphic;
1052  }
1053  break;
1054  case TOX_INDEX:
1055  {
1056  nContentOptions = SwTOXElement::Mark;
1057 
1058  if(m_xCollectSameCB->get_active())
1059  nIndexOptions |= SwTOIOptions::SameEntry;
1060  if(m_xUseFFCB->get_active())
1061  nIndexOptions |= SwTOIOptions::FF;
1062  if(m_xUseDashCB->get_active())
1063  nIndexOptions |= SwTOIOptions::Dash;
1064  if(m_xCaseSensitiveCB->get_active())
1065  nIndexOptions |= SwTOIOptions::CaseSensitive;
1066  if(m_xInitialCapsCB->get_active())
1067  nIndexOptions |= SwTOIOptions::InitialCaps;
1068  if(m_xKeyAsEntryCB->get_active())
1069  nIndexOptions |= SwTOIOptions::KeyAsEntry;
1070  if(m_xFromFileCB->get_active())
1072  else
1073  rDesc.SetAutoMarkURL(OUString());
1074  }
1075  break;
1076  case TOX_ILLUSTRATIONS:
1077  case TOX_TABLES :
1078  rDesc.SetCreateFromObjectNames(m_xFromObjectNamesRB->get_active());
1079  rDesc.SetSequenceName(m_xCaptionSequenceLB->get_active_text());
1080  rDesc.SetCaptionDisplay(static_cast<SwCaptionDisplay>(m_xDisplayTypeLB->get_active()));
1081  break;
1082  case TOX_OBJECTS:
1083  {
1085  for (int i = 0, nCount = m_xFromObjCLB->n_children(); i < nCount; ++i)
1086  {
1087  if (m_xFromObjCLB->get_toggle(i, 0) == TRISTATE_TRUE)
1088  {
1089  SwTOOElements nData = static_cast<SwTOOElements>(m_xFromObjCLB->get_id(i).toInt32());
1090  nOLEData |= nData;
1091  }
1092  }
1093  rDesc.SetOLEOptions(nOLEData);
1094  }
1095  break;
1096  case TOX_AUTHORITIES:
1097  case TOX_BIBLIOGRAPHY :
1098  {
1099  if (m_xBracketLB->get_active())
1100  rDesc.SetAuthBrackets(m_xBracketLB->get_active_text());
1101  else
1102  rDesc.SetAuthBrackets(OUString());
1103  rDesc.SetAuthSequence(m_xSequenceCB->get_active());
1104  }
1105  break;
1106  case TOX_CITATION :
1107  break;
1108  }
1109 
1110  rDesc.SetLevelFromChapter( m_xLevelFromChapterCB->get_visible() &&
1111  m_xLevelFromChapterCB->get_active());
1112  if (m_xTOXMarksCB->get_active() && m_xTOXMarksCB->get_visible())
1113  nContentOptions |= SwTOXElement::Mark;
1114  if (m_xFromHeadingsCB->get_active() && m_xFromHeadingsCB->get_visible())
1115  nContentOptions |= SwTOXElement::OutlineLevel;
1116  if (m_xAddStylesCB->get_active() && m_xAddStylesCB->get_visible())
1117  nContentOptions |= SwTOXElement::Template;
1118 
1119  rDesc.SetContentOptions(nContentOptions);
1120  rDesc.SetIndexOptions(nIndexOptions);
1121  rDesc.SetLevel(m_xLevelNF->get_value());
1122 
1123  rDesc.SetReadonly(m_xReadOnlyCB->get_active());
1124 
1125  for(sal_uInt16 i = 0; i < MAXLEVEL; i++)
1126  rDesc.SetStyleNames(aStyleArr[i], i);
1127 
1128  rDesc.SetLanguage(m_xLanguageLB->get_active_id());
1129  const OUString& rEntryData = m_xSortAlgorithmLB->get_active_id();
1130  rDesc.SetSortAlgorithm(rEntryData);
1131 }
1132 
1134 {
1135  SwMultiTOXTabDialog* pTOXDlg = static_cast<SwMultiTOXTabDialog*>(GetDialogController());
1136  SwWrtShell& rSh = pTOXDlg->GetWrtShell();
1137  const CurTOXType aCurType = pTOXDlg->GetCurrentTOXType();
1138  sal_uInt32 nData = lcl_TOXTypesToUserData(aCurType);
1139  m_xTypeLB->set_active_id(OUString::number(nData));
1140 
1143  m_xFromFileCB->set_active(!sAutoMarkURL.isEmpty());
1144 
1145  m_xCaptionSequenceLB->clear();
1146  const size_t nCount = rSh.GetFieldTypeCount(SwFieldIds::SetExp);
1147  for (size_t i = 0; i < nCount; ++i)
1148  {
1149  SwFieldType *pType = rSh.GetFieldType( i, SwFieldIds::SetExp );
1150  if( pType->Which() == SwFieldIds::SetExp &&
1151  static_cast<SwSetExpFieldType *>( pType)->GetType() & nsSwGetSetExpType::GSE_SEQ )
1152  m_xCaptionSequenceLB->append_text(pType->GetName());
1153  }
1154 
1155  if(pTOXDlg->IsTOXEditMode())
1156  {
1157  m_xTypeFT->set_sensitive(false);
1158  m_xTypeLB->set_sensitive(false);
1159  }
1160 
1162  {
1163  // save current values into the proper TOXDescription
1165  }
1166  m_bWaitingInitialSettings = false;
1167 
1168  TOXTypeHdl(*m_xTypeLB);
1169  CheckBoxHdl(*m_xAddStylesCB);
1170 }
1171 
1173 {
1174  //nothing to do
1175 }
1176 
1178 {
1179  if (_pSet)
1180  _pSet->Put(SfxUInt16Item(FN_PARAM_TOX_TYPE, m_xTypeLB->get_active_id().toUInt32()));
1182  return DeactivateRC::LeavePage;
1183 }
1184 
1185 std::unique_ptr<SfxTabPage> SwTOXSelectTabPage::Create(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet* rAttrSet)
1186 {
1187  return std::make_unique<SwTOXSelectTabPage>(pPage, pController, *rAttrSet);
1188 }
1189 
1190 IMPL_LINK(SwTOXSelectTabPage, TOXTypeHdl, weld::ComboBox&, rBox, void)
1191 {
1192  SwMultiTOXTabDialog* pTOXDlg = static_cast<SwMultiTOXTabDialog*>(GetDialogController());
1193  const sal_uInt16 nType = rBox.get_active_id().toUInt32();
1194  CurTOXType eCurType = lcl_UserData2TOXTypes(nType);
1195  pTOXDlg->SetCurrentTOXType(eCurType);
1196 
1197  m_xAreaLB->set_visible( 0 != (nType & (TO_CONTENT|TO_ILLUSTRATION|TO_USER|TO_INDEX|TO_TABLE|TO_OBJECT)) );
1198  m_xLevelFT->set_visible( 0 != (nType & (TO_CONTENT)) );
1199  m_xLevelNF->set_visible( 0 != (nType & (TO_CONTENT)) );
1200  m_xLevelFromChapterCB->set_visible( 0 != (nType & (TO_USER)) );
1201  m_xAreaFrame->set_visible( 0 != (nType & (TO_CONTENT|TO_ILLUSTRATION|TO_USER|TO_INDEX|TO_TABLE|TO_OBJECT)) );
1202 
1203  m_xFromHeadingsCB->set_visible( 0 != (nType & (TO_CONTENT)) );
1204  m_xAddStylesCB->set_visible( 0 != (nType & (TO_CONTENT|TO_USER)) );
1205  m_xAddStylesPB->set_visible( 0 != (nType & (TO_CONTENT|TO_USER)) );
1206 
1207  m_xFromTablesCB->set_visible( 0 != (nType & (TO_USER)) );
1208  m_xFromFramesCB->set_visible( 0 != (nType & (TO_USER)) );
1209  m_xFromGraphicsCB->set_visible( 0 != (nType & (TO_USER)) );
1210  m_xFromOLECB->set_visible( 0 != (nType & (TO_USER)) );
1211 
1212  m_xFromCaptionsRB->set_visible( 0 != (nType & (TO_ILLUSTRATION|TO_TABLE)) );
1213  m_xFromObjectNamesRB->set_visible( 0 != (nType & (TO_ILLUSTRATION|TO_TABLE)) );
1214 
1215  m_xTOXMarksCB->set_visible( 0 != (nType & (TO_CONTENT|TO_USER)) );
1216 
1217  m_xCreateFrame->set_visible( 0 != (nType & (TO_CONTENT|TO_ILLUSTRATION|TO_USER|TO_TABLE)) );
1218  m_xCaptionSequenceFT->set_visible( 0 != (nType & (TO_ILLUSTRATION|TO_TABLE)) );
1219  m_xCaptionSequenceLB->set_visible( 0 != (nType & (TO_ILLUSTRATION|TO_TABLE)) );
1220  m_xDisplayTypeFT->set_visible( 0 != (nType & (TO_ILLUSTRATION|TO_TABLE)) );
1221  m_xDisplayTypeLB->set_visible( 0 != (nType & (TO_ILLUSTRATION|TO_TABLE)) );
1222 
1223  m_xAuthorityFrame->set_visible( 0 != (nType & TO_AUTHORITIES) );
1224 
1225  bool bEnableSortLanguage = 0 != (nType & (TO_INDEX|TO_AUTHORITIES));
1226  m_xSortFrame->set_visible(bEnableSortLanguage);
1227 
1228  if( nType & TO_ILLUSTRATION )
1229  {
1231  m_xCaptionSequenceLB->set_active_text(sName);
1232  }
1233  else if( nType & TO_TABLE )
1234  {
1236  m_xCaptionSequenceLB->set_active_text(sName);
1237  }
1238  else if( nType & TO_USER )
1239  {
1240  m_xAddStylesCB->set_label(sAddStyleUser);
1241  }
1242 
1243  m_xIdxOptionsFrame->set_visible( 0 != (nType & TO_INDEX) );
1244 
1245  //object index
1246  m_xFromObjFrame->set_visible( 0 != (nType & TO_OBJECT) );
1247 
1248  //set control values from the proper TOXDescription
1249  {
1250  ApplyTOXDescription();
1251  }
1252  ModifyHdl();
1253 }
1254 
1256 {
1258  {
1260  SwMultiTOXTabDialog* pTOXDlg = static_cast<SwMultiTOXTabDialog*>(GetDialogController());
1262  }
1263 }
1264 
1266 {
1267  ModifyHdl();
1268 }
1269 
1271 {
1272  ModifyHdl();
1273 }
1274 
1276 {
1277  ModifyHdl();
1278 }
1279 
1280 IMPL_LINK(SwTOXSelectTabPage, CheckBoxHdl, weld::ToggleButton&, rButton, void)
1281 {
1282  SwMultiTOXTabDialog* pTOXDlg = static_cast<SwMultiTOXTabDialog*>(GetDialogController());
1283  const CurTOXType aCurType = pTOXDlg->GetCurrentTOXType();
1284  if(TOX_CONTENT == aCurType.eType)
1285  {
1286  //at least one of the three CheckBoxes must be checked
1287  if (!m_xAddStylesCB->get_active() && !m_xFromHeadingsCB->get_active() && !m_xTOXMarksCB->get_active())
1288  {
1289  //TODO: InfoBox?
1290  rButton.set_active(true);
1291  }
1292  m_xAddStylesPB->set_sensitive(m_xAddStylesCB->get_active());
1293  }
1294  if (TOX_USER == aCurType.eType)
1295  {
1296  m_xAddStylesPB->set_sensitive(m_xAddStylesCB->get_active());
1297  }
1298  else if (TOX_INDEX == aCurType.eType)
1299  {
1300  m_xAutoMarkPB->set_sensitive(m_xFromFileCB->get_active());
1301  m_xUseFFCB->set_sensitive(m_xCollectSameCB->get_active() && !m_xUseDashCB->get_active());
1302  m_xUseDashCB->set_sensitive(m_xCollectSameCB->get_active() && !m_xUseFFCB->get_active());
1303  m_xCaseSensitiveCB->set_sensitive(m_xCollectSameCB->get_active());
1304  }
1305  ModifyHdl();
1306 };
1307 
1309 {
1310  bool bEnable = m_xFromCaptionsRB->get_active();
1311  m_xCaptionSequenceFT->set_sensitive(bEnable);
1312  m_xCaptionSequenceLB->set_sensitive(bEnable);
1313  m_xDisplayTypeFT->set_sensitive(bEnable);
1314  m_xDisplayTypeLB->set_sensitive(bEnable);
1315  ModifyHdl();
1316 }
1317 
1318 IMPL_LINK(SwTOXSelectTabPage, LanguageListBoxHdl, weld::ComboBox&, rBox, void)
1319 {
1320  LanguageHdl(&rBox);
1321 }
1322 
1324 {
1325  lang::Locale aLcl( LanguageTag( m_xLanguageLB->get_active_id() ).getLocale() );
1326  Sequence< OUString > aSeq = pIndexEntryWrapper->GetAlgorithmList( aLcl );
1327 
1328  if( !pIndexRes )
1329  pIndexRes.reset(new IndexEntryResource());
1330 
1331  OUString sOldString = m_xSortAlgorithmLB->get_active_id();
1332  m_xSortAlgorithmLB->clear();
1333 
1334  sal_Int32 nEnd = aSeq.getLength();
1335  for( sal_Int32 nCnt = 0; nCnt < nEnd; ++nCnt )
1336  {
1337  const OUString sAlg(aSeq[ nCnt ]);
1338  const OUString sUINm = pIndexRes->GetTranslation( sAlg );
1339  m_xSortAlgorithmLB->append(sAlg, sUINm);
1340  if( sAlg == sOldString )
1341  m_xSortAlgorithmLB->set_active(nCnt);
1342  }
1343 
1344  if (m_xSortAlgorithmLB->get_active() == -1)
1345  m_xSortAlgorithmLB->set_active(0);
1346 
1347  if (pBox)
1348  ModifyHdl();
1349 };
1350 
1352 {
1353  SwAddStylesDlg_Impl aDlg(GetFrameWeld(), static_cast<SwMultiTOXTabDialog*>(GetDialogController())->GetWrtShell(),
1354  aStyleArr);
1355  aDlg.run();
1356  ModifyHdl();
1357 }
1358 
1360 {
1361  m_xAutoMarkPB->set_item_sensitive("edit", !sAutoMarkURL.isEmpty());
1362 }
1363 
1364 IMPL_LINK(SwTOXSelectTabPage, MenuExecuteHdl, const OString&, rIdent, void)
1365 {
1366  const OUString sSaveAutoMarkURL = sAutoMarkURL;
1367 
1368  if (rIdent == "open")
1369  {
1370  sAutoMarkURL = lcl_CreateAutoMarkFileDlg(GetFrameWeld(),
1371  sAutoMarkURL, sAutoMarkType, true);
1372  }
1373  else if (rIdent == "new" || rIdent == "edit")
1374  {
1375  bool bNew = (rIdent == "new");
1376  if (bNew)
1377  {
1378  sAutoMarkURL = lcl_CreateAutoMarkFileDlg(GetFrameWeld(),
1379  sAutoMarkURL, sAutoMarkType, false);
1380  if (sAutoMarkURL.isEmpty())
1381  return;
1382  }
1383 
1384  SwAutoMarkDlg_Impl aAutoMarkDlg(GetFrameWeld(), sAutoMarkURL, bNew);
1385  if (RET_OK != aAutoMarkDlg.run() && bNew)
1386  sAutoMarkURL = sSaveAutoMarkURL;
1387  }
1388 }
1389 
1391 {
1392 protected:
1394 public:
1395  virtual WindowType GetType() const = 0;
1396  virtual void GrabFocus() = 0;
1397  virtual void Hide() = 0;
1398  virtual void set_grid_left_attach(int nPos) = 0;
1399  virtual void get_extents_relative_to(weld::Widget& rRelative, int& x, int& y, int& width, int& height) = 0;
1400  void SetGetFocusHdl(const Link<SwTOXWidget&,void>& rLink) { aGetFocusLink = rLink; }
1401  virtual ~SwTOXWidget() {}
1402 };
1403 
1404 class SwTOXEdit : public SwTOXWidget
1405 {
1406  std::unique_ptr<weld::Builder> m_xBuilder;
1412  std::unique_ptr<weld::Entry> m_xEntry;
1413 
1414  DECL_LINK(ModifyHdl, weld::Entry&, void);
1415 public:
1416  SwTOXEdit(SwTokenWindow* pTokenWin, const SwFormToken& rToken)
1417  : m_xBuilder(Application::CreateBuilder(pTokenWin->get_child_container(), "modules/swriter/ui/toxentrywidget.ui"))
1418  , aFormToken(rToken)
1419  , bNextControl(false)
1420  , m_pParent(pTokenWin)
1421  , m_xEntry(m_xBuilder->weld_entry("entry", true))
1422  {
1423  m_xEntry->connect_changed(LINK(this, SwTOXEdit, ModifyHdl));
1424  m_xEntry->connect_key_press(LINK(this, SwTOXEdit, KeyInputHdl));
1425  m_xEntry->connect_focus_in(LINK(this, SwTOXEdit, FocusInHdl));
1426  m_xEntry->set_tooltip_text(m_pParent->CreateQuickHelp(rToken));
1427  }
1428 
1429  virtual WindowType GetType() const override
1430  {
1431  return WindowType::EDIT;
1432  }
1433 
1434  virtual void GrabFocus() override
1435  {
1436  m_xEntry->grab_focus();
1437  }
1438 
1439  virtual void Hide() override
1440  {
1441  m_xEntry->hide();
1442  }
1443 
1444  void Show()
1445  {
1446  m_xEntry->show();
1447  }
1448 
1449  void SetAccessibleName(const OUString& rName)
1450  {
1451  m_xEntry->set_accessible_name(rName);
1452  }
1453 
1454  virtual void set_grid_left_attach(int nPos) override
1455  {
1456  m_xEntry->set_grid_left_attach(nPos);
1457  }
1458 
1459  virtual void get_extents_relative_to(weld::Widget& rRelative, int& x, int& y, int& width, int& height) override
1460  {
1461  m_xEntry->get_extents_relative_to(rRelative, x, y, width, height);
1462  }
1463 
1464  OUString GetText() const
1465  {
1466  return m_xEntry->get_text();
1467  }
1468 
1469  void SetText(const OUString& rText)
1470  {
1471  m_xEntry->set_text(rText);
1472  }
1473 
1474  void get_selection_bounds(int& rStartPos, int& rEndPos)
1475  {
1476  m_xEntry->get_selection_bounds(rStartPos, rEndPos);
1477  }
1478 
1479  void select_region(int nStartPos, int nEndPos)
1480  {
1481  m_xEntry->select_region(nStartPos, nEndPos);
1482  }
1483 
1485  {
1486  aModifiedLink = rLink;
1487  }
1488 
1489  DECL_LINK(KeyInputHdl, const KeyEvent&, bool);
1490  DECL_LINK(FocusInHdl, weld::Widget&, void);
1491 
1492  bool IsNextControl() const { return bNextControl; }
1493  void SetPrevNextLink(const Link<SwTOXEdit&,void>& rLink) { aPrevNextControlLink = rLink; }
1494 
1496  {
1497  aFormToken.sText = m_xEntry->get_text();
1498  return aFormToken;
1499  }
1500 
1501  void SetCharStyleName(const OUString& rSet, sal_uInt16 nPoolId)
1502  {
1503  aFormToken.sCharStyleName = rSet;
1504  aFormToken.nPoolId = nPoolId;
1505  }
1506 
1507  void AdjustSize();
1508 };
1509 
1511 {
1512  aModifiedLink.Call(*this);
1513 }
1514 
1515 IMPL_LINK(SwTOXEdit, KeyInputHdl, const KeyEvent&, rKEvt, bool)
1516 {
1517  bool bCall = false;
1518  int nStartPos, nEndPos;
1519  bool bStartIsEnd = !m_xEntry->get_selection_bounds(nStartPos, nEndPos);
1520  int nMin = std::min(nStartPos, nEndPos);
1521  const sal_Int32 nTextLen = GetText().getLength();
1522  if ((bStartIsEnd && !nMin) || nMin == nTextLen)
1523  {
1524  vcl::KeyCode aCode = rKEvt.GetKeyCode();
1525  if (aCode.GetCode() == KEY_RIGHT && nMin == nTextLen)
1526  {
1527  bNextControl = true;
1528  bCall = true;
1529  }
1530  else if (aCode.GetCode() == KEY_LEFT && !nMin)
1531  {
1532  bNextControl = false;
1533  bCall = true;
1534  }
1535  else if ( (aCode.GetCode() == KEY_F3) && aCode.IsShift() && !aCode.IsMod1() && !aCode.IsMod2() )
1536  {
1537  if (m_pParent)
1538  {
1539  m_pParent->SetFocus2theAllBtn();
1540  }
1541  }
1542  if (bCall && aPrevNextControlLink.IsSet())
1543  aPrevNextControlLink.Call(*this);
1544  else
1545  bCall = false;
1546 
1547  }
1548  return bCall;
1549 }
1550 
1552 {
1553  aGetFocusLink.Call(*this);
1554 }
1555 
1557 {
1558  auto nWidth = m_xEntry->get_pixel_size(GetText()).Width();
1559  float fChars = nWidth / m_xEntry->get_approximate_digit_width();
1560  m_xEntry->set_width_chars(std::max(1.0f, std::ceil(fChars)));
1561 }
1562 
1563 class SwTOXButton : public SwTOXWidget
1564 {
1565  std::unique_ptr<weld::Builder> m_xBuilder;
1570  std::unique_ptr<weld::ToggleButton> m_xButton;
1571 public:
1572  SwTOXButton(SwTokenWindow* pTokenWin, const SwFormToken& rToken)
1573  : m_xBuilder(Application::CreateBuilder(pTokenWin->get_child_container(), "modules/swriter/ui/toxbuttonwidget.ui"))
1574  , aFormToken(rToken)
1575  , bNextControl(false)
1576  , m_pParent(pTokenWin)
1577  , m_xButton(m_xBuilder->weld_toggle_button("button", true))
1578  {
1579  m_xButton->connect_key_press(LINK(this, SwTOXButton, KeyInputHdl));
1580  m_xButton->connect_focus_in(LINK(this, SwTOXButton, FocusInHdl));
1581  m_xButton->set_tooltip_text(m_pParent->CreateQuickHelp(rToken));
1582  }
1583 
1584  virtual WindowType GetType() const override
1585  {
1586  return WindowType::PUSHBUTTON;
1587  }
1588 
1589  virtual void GrabFocus() override
1590  {
1591  m_xButton->grab_focus();
1592  }
1593 
1594  virtual void Hide() override
1595  {
1596  m_xButton->hide();
1597  }
1598 
1599  void Show()
1600  {
1601  m_xButton->show();
1602  }
1603 
1604  void SetAccessibleName(const OUString& rName)
1605  {
1606  m_xButton->set_accessible_name(rName);
1607  }
1608 
1609  virtual void set_grid_left_attach(int nPos) override
1610  {
1611  m_xButton->set_grid_left_attach(nPos);
1612  }
1613 
1614  void get_extents_relative_to(weld::Widget& rRelative, int& x, int& y, int& width, int& height) override
1615  {
1616  m_xButton->get_extents_relative_to(rRelative, x, y, width, height);
1617  }
1618 
1619  void Check(bool bCheck = true)
1620  {
1621  m_xButton->set_active(bCheck);
1622  }
1623 
1624  DECL_LINK(KeyInputHdl, const KeyEvent&, bool);
1625  DECL_LINK(FocusInHdl, weld::Widget&, void);
1626 
1627  bool IsNextControl() const {return bNextControl;}
1628  void SetPrevNextLink(const Link<SwTOXButton&,void>& rLink) {aPrevNextControlLink = rLink;}
1629  const SwFormToken& GetFormToken() const {return aFormToken;}
1630 
1631  void SetCharStyleName(const OUString& rSet, sal_uInt16 nPoolId)
1632  {
1633  aFormToken.sCharStyleName = rSet;
1634  aFormToken.nPoolId = nPoolId;
1635  }
1636 
1638  { aFormToken.nTabStopPosition = nSet; }
1639 
1641  { aFormToken.cTabFillChar = cSet; }
1642 
1644  { aFormToken.eTabAlign = eAlign;}
1645 
1646 //---> i89791
1647  //used for entry number format, in TOC only
1648  //needed for different UI dialog position
1649  void SetEntryNumberFormat(sal_uInt16 nSet) {
1650  switch(nSet)
1651  {
1652  default:
1653  case 0:
1654  aFormToken.nChapterFormat = CF_NUMBER;
1655  break;
1656  case 1:
1658  break;
1659  }
1660  }
1661 
1662  void SetChapterInfo(sal_uInt16 nSet) {
1663  switch(nSet)
1664  {
1665  default:
1666  case 0:
1668  break;
1669  case 1:
1670  aFormToken.nChapterFormat = CF_TITLE;
1671  break;
1672  case 2:
1673  aFormToken.nChapterFormat = CF_NUMBER_NOPREPST;
1674  break;
1675  }
1676  }
1677 
1678  void SetOutlineLevel( sal_uInt16 nSet ) { aFormToken.nOutlineLevel = nSet;}//i53420
1679 
1680  void SetText(const OUString& rText)
1681  {
1682  m_xButton->set_label(rText);
1683  }
1684 
1685  void SetLinkEnd()
1686  {
1687  OSL_ENSURE(TOKEN_LINK_START == aFormToken.eTokenType,
1688  "call SetLinkEnd for link start only!");
1689  aFormToken.eTokenType = TOKEN_LINK_END;
1690  aFormToken.sText = SwForm::GetFormLinkEnd();
1691  SetText(aFormToken.sText);
1692  }
1693 
1695  {
1696  OSL_ENSURE(TOKEN_LINK_END == aFormToken.eTokenType,
1697  "call SetLinkStart for link start only!");
1698  aFormToken.eTokenType = TOKEN_LINK_START;
1699  aFormToken.sText = SwForm::GetFormLinkStt();
1700  SetText(aFormToken.sText);
1701  }
1702 };
1703 
1704 IMPL_LINK(SwTOXButton, KeyInputHdl, const KeyEvent&, rKEvt, bool)
1705 {
1706  bool bCall = false;
1707  vcl::KeyCode aCode = rKEvt.GetKeyCode();
1708  if (aCode.GetCode() == KEY_RIGHT)
1709  {
1710  bNextControl = true;
1711  bCall = true;
1712  }
1713  else if (aCode.GetCode() == KEY_LEFT)
1714  {
1715  bNextControl = false;
1716  bCall = true;
1717  }
1718  else if (aCode.GetCode() == KEY_DELETE)
1719  {
1720  m_pParent->RemoveControl(this, true);
1721  //this is invalid here
1722  return true;
1723  }
1724  else if ( (aCode.GetCode() == KEY_F3) && aCode.IsShift() && !aCode.IsMod1() && !aCode.IsMod2() )
1725  {
1726  if (m_pParent)
1727  {
1728  m_pParent->SetFocus2theAllBtn();
1729  }
1730  }
1731  if (bCall && aPrevNextControlLink.IsSet())
1732  aPrevNextControlLink.Call(*this);
1733  else
1734  bCall = false;
1735  return bCall;
1736 }
1737 
1739 {
1740  aGetFocusLink.Call(*this);
1741 }
1742 
1743 namespace
1744 {
1745  const char* STR_AUTH_FIELD_ARY[] =
1746  {
1747  STR_AUTH_FIELD_IDENTIFIER,
1748  STR_AUTH_FIELD_AUTHORITY_TYPE,
1749  STR_AUTH_FIELD_ADDRESS,
1750  STR_AUTH_FIELD_ANNOTE,
1751  STR_AUTH_FIELD_AUTHOR,
1752  STR_AUTH_FIELD_BOOKTITLE,
1753  STR_AUTH_FIELD_CHAPTER,
1754  STR_AUTH_FIELD_EDITION,
1755  STR_AUTH_FIELD_EDITOR,
1756  STR_AUTH_FIELD_HOWPUBLISHED,
1757  STR_AUTH_FIELD_INSTITUTION,
1758  STR_AUTH_FIELD_JOURNAL,
1759  STR_AUTH_FIELD_MONTH,
1760  STR_AUTH_FIELD_NOTE,
1761  STR_AUTH_FIELD_NUMBER,
1762  STR_AUTH_FIELD_ORGANIZATIONS,
1763  STR_AUTH_FIELD_PAGES,
1764  STR_AUTH_FIELD_PUBLISHER,
1765  STR_AUTH_FIELD_SCHOOL,
1766  STR_AUTH_FIELD_SERIES,
1767  STR_AUTH_FIELD_TITLE,
1768  STR_AUTH_FIELD_TYPE,
1769  STR_AUTH_FIELD_VOLUME,
1770  STR_AUTH_FIELD_YEAR,
1771  STR_AUTH_FIELD_URL,
1772  STR_AUTH_FIELD_CUSTOM1,
1773  STR_AUTH_FIELD_CUSTOM2,
1774  STR_AUTH_FIELD_CUSTOM3,
1775  STR_AUTH_FIELD_CUSTOM4,
1776  STR_AUTH_FIELD_CUSTOM5,
1777  STR_AUTH_FIELD_ISBN
1778  };
1779 }
1780 
1782  : SfxTabPage(pPage, pController, "modules/swriter/ui/tocentriespage.ui", "TocEntriesPage", &rAttrSet)
1783  , sDelimStr(SwResId(STR_DELIM))
1784  , sNoCharStyle(SwResId(STR_NO_CHAR_STYLE))
1785  , m_pCurrentForm(nullptr)
1786  , bInLevelHdl(false)
1787  , m_xTypeFT(m_xBuilder->weld_label("typeft"))
1788  , m_xLevelFT(m_xBuilder->weld_label("levelft"))
1789  , m_xLevelLB(m_xBuilder->weld_tree_view("level"))
1790  , m_xAllLevelsPB(m_xBuilder->weld_button("all"))
1791  , m_xEntryNoPB(m_xBuilder->weld_button("chapterno"))
1792  , m_xEntryPB(m_xBuilder->weld_button("entrytext"))
1793  , m_xTabPB(m_xBuilder->weld_button("tabstop"))
1794  , m_xChapterInfoPB(m_xBuilder->weld_button("chapterinfo"))
1795  , m_xPageNoPB(m_xBuilder->weld_button("pageno"))
1796  , m_xHyperLinkPB(m_xBuilder->weld_button("hyperlink"))
1797  , m_xAuthFieldsLB(m_xBuilder->weld_combo_box("authfield"))
1798  , m_xAuthInsertPB(m_xBuilder->weld_button("insert"))
1799  , m_xAuthRemovePB(m_xBuilder->weld_button("remove"))
1800  , m_xCharStyleLB(m_xBuilder->weld_combo_box("charstyle"))
1801  , m_xEditStylePB(m_xBuilder->weld_button("edit"))
1802  , m_xChapterEntryFT(m_xBuilder->weld_label("chapterentryft"))
1803  , m_xChapterEntryLB(m_xBuilder->weld_combo_box("chapterentry"))
1804  , m_xNumberFormatFT(m_xBuilder->weld_label("numberformatft"))
1805  , m_xNumberFormatLB(m_xBuilder->weld_combo_box("numberformat"))
1806  , m_xEntryOutlineLevelFT(m_xBuilder->weld_label("entryoutlinelevelft"))
1807  , m_xEntryOutlineLevelNF(m_xBuilder->weld_spin_button("entryoutlinelevel"))
1808  , m_xFillCharFT(m_xBuilder->weld_label("fillcharft"))
1809  , m_xFillCharCB(m_xBuilder->weld_combo_box("fillchar"))
1810  , m_xTabPosFT(m_xBuilder->weld_label("tabstopposft"))
1811  , m_xTabPosMF(m_xBuilder->weld_metric_spin_button("tabstoppos", FieldUnit::CM))
1812  , m_xAutoRightCB(m_xBuilder->weld_check_button("alignright"))
1813  , m_xFormatFrame(m_xBuilder->weld_widget("formatframe"))
1814  , m_xMainEntryStyleFT(m_xBuilder->weld_label("mainstyleft"))
1815  , m_xMainEntryStyleLB(m_xBuilder->weld_combo_box("mainstyle"))
1816  , m_xAlphaDelimCB(m_xBuilder->weld_check_button("alphadelim"))
1817  , m_xCommaSeparatedCB(m_xBuilder->weld_check_button("commasep"))
1818  , m_xRelToStyleCB(m_xBuilder->weld_check_button("reltostyle"))
1819  , m_xSortingFrame(m_xBuilder->weld_widget("sortingframe"))
1820  , m_xSortDocPosRB(m_xBuilder->weld_radio_button("sortpos"))
1821  , m_xSortContentRB(m_xBuilder->weld_radio_button("sortcontents"))
1822  , m_xSortKeyFrame(m_xBuilder->weld_widget("sortkeyframe"))
1823  , m_xFirstKeyLB(m_xBuilder->weld_combo_box("key1lb"))
1824  , m_xFirstSortUpRB(m_xBuilder->weld_radio_button("up1cb"))
1825  , m_xFirstSortDownRB(m_xBuilder->weld_radio_button("down1cb"))
1826  , m_xSecondKeyLB(m_xBuilder->weld_combo_box("key2lb"))
1827  , m_xSecondSortUpRB(m_xBuilder->weld_radio_button("up2cb"))
1828  , m_xSecondSortDownRB(m_xBuilder->weld_radio_button("down2cb"))
1829  , m_xThirdKeyLB(m_xBuilder->weld_combo_box("key3lb"))
1830  , m_xThirdSortUpRB(m_xBuilder->weld_radio_button("up3cb"))
1831  , m_xThirdSortDownRB(m_xBuilder->weld_radio_button("down3cb"))
1832  , m_xTokenWIN(new SwTokenWindow(m_xBuilder->weld_container("token")))
1833 {
1834  const OUString sNoCharSortKey(SwResId(STR_NOSORTKEY));
1835 
1836  sAuthTypeStr = m_xTypeFT->get_label();
1837  sLevelStr = m_xLevelFT->get_label();
1838  m_xAuthFieldsLB->make_sorted();
1839  m_xTokenWIN->SetTabPage(this);
1840 
1842  aLastTOXType.nIndex = 0;
1843 
1845  m_xEntryNoPB->connect_clicked(LINK(this, SwTOXEntryTabPage, InsertTokenHdl));
1846  m_xEntryPB->connect_clicked(LINK(this, SwTOXEntryTabPage, InsertTokenHdl));
1847  m_xChapterInfoPB->connect_clicked(LINK(this, SwTOXEntryTabPage, InsertTokenHdl));
1848  m_xPageNoPB->connect_clicked(LINK(this, SwTOXEntryTabPage, InsertTokenHdl));
1849  m_xTabPB->connect_clicked(LINK(this, SwTOXEntryTabPage, InsertTokenHdl));
1850  m_xHyperLinkPB->connect_clicked(LINK(this, SwTOXEntryTabPage, InsertTokenHdl));
1851  m_xEditStylePB->connect_clicked(LINK(this, SwTOXEntryTabPage, EditStyleHdl));
1852  m_xLevelLB->connect_changed(LINK(this, SwTOXEntryTabPage, LevelHdl));
1853  m_xTokenWIN->SetButtonSelectedHdl(LINK(this, SwTOXEntryTabPage, TokenSelectedHdl));
1854  m_xTokenWIN->SetModifyHdl(LINK(this, SwTOXEntryTabPage, ModifyHdl));
1855  m_xCharStyleLB->connect_changed(LINK(this, SwTOXEntryTabPage, StyleSelectHdl));
1856  m_xCharStyleLB->append_text(sNoCharStyle);
1857  m_xChapterEntryLB->connect_changed(LINK(this, SwTOXEntryTabPage, ChapterInfoHdl));
1858  m_xEntryOutlineLevelNF->connect_value_changed(LINK(this, SwTOXEntryTabPage, ChapterInfoOutlineHdl));
1859  m_xNumberFormatLB->connect_changed(LINK(this, SwTOXEntryTabPage, NumberFormatHdl));
1860 
1861  m_xTabPosMF->connect_value_changed(LINK(this, SwTOXEntryTabPage, TabPosHdl));
1862  m_xFillCharCB->connect_changed(LINK(this, SwTOXEntryTabPage, FillCharHdl));
1863  m_xAutoRightCB->connect_toggled(LINK(this, SwTOXEntryTabPage, AutoRightHdl));
1864  m_xAuthInsertPB->connect_clicked(LINK(this, SwTOXEntryTabPage, RemoveInsertAuthHdl));
1865  m_xAuthRemovePB->connect_clicked(LINK(this, SwTOXEntryTabPage, RemoveInsertAuthHdl));
1866  m_xSortDocPosRB->connect_toggled(LINK(this, SwTOXEntryTabPage, SortKeyHdl));
1867  m_xSortContentRB->connect_toggled(LINK(this, SwTOXEntryTabPage, SortKeyHdl));
1868  m_xAllLevelsPB->connect_clicked(LINK(this, SwTOXEntryTabPage, AllLevelsHdl));
1869 
1870  m_xAlphaDelimCB->connect_toggled(LINK(this, SwTOXEntryTabPage, ModifyClickHdl));
1871  m_xCommaSeparatedCB->connect_toggled(LINK(this, SwTOXEntryTabPage, ModifyClickHdl));
1872  m_xRelToStyleCB->connect_toggled(LINK(this, SwTOXEntryTabPage, ModifyClickHdl));
1873 
1874  FieldUnit aMetric = ::GetDfltMetric(false);
1875  ::SetFieldUnit(*m_xTabPosMF, aMetric);
1876 
1877  m_xSortDocPosRB->set_active(true);
1878 
1879  m_xFillCharCB->set_entry_max_length(1);
1880  m_xFillCharCB->append_text(OUString(' '));
1881  m_xFillCharCB->append_text(OUString('.'));
1882  m_xFillCharCB->append_text(OUString('-'));
1883  m_xFillCharCB->append_text(OUString('_'));
1884  m_xFillCharCB->append_text(OUString(u'\x2024')); // ONE DOT LEADER
1885  m_xFillCharCB->append_text(OUString(u'\x2025')); // TWO DOT LEADER
1886  m_xFillCharCB->append_text(OUString(u'\x2026')); // HORIZONTAL ELLIPSIS
1887 
1888  m_xEditStylePB->set_sensitive(false);
1889 
1890  //fill the types in
1891  for (sal_uInt16 i = 0; i < AUTH_FIELD_END; ++i)
1892  {
1893  OUString sId(OUString::number(i));
1894  m_xAuthFieldsLB->append(sId, SwResId(STR_AUTH_FIELD_ARY[i]));
1895  }
1896 
1897  m_xFirstKeyLB->append(OUString::number(USHRT_MAX), sNoCharSortKey);
1898  m_xSecondKeyLB->append(OUString::number(USHRT_MAX), sNoCharSortKey);
1899  m_xThirdKeyLB->append(OUString::number(USHRT_MAX), sNoCharSortKey);
1900 
1901  for (sal_uInt16 i = 0; i < AUTH_FIELD_END; ++i)
1902  {
1903  const OUString sTmp(m_xAuthFieldsLB->get_text(i));
1904  const OUString sEntryData(m_xAuthFieldsLB->get_id(i));
1905  m_xFirstKeyLB->append(sEntryData, sTmp);
1906  m_xSecondKeyLB->append(sEntryData, sTmp);
1907  m_xThirdKeyLB->append(sEntryData, sTmp);
1908  }
1909  m_xFirstKeyLB->set_active(0);
1910  m_xSecondKeyLB->set_active(0);
1911  m_xThirdKeyLB->set_active(0);
1912 
1913  //lock size
1914  Size aPrefSize(m_xContainer->get_preferred_size());
1915  m_xContainer->set_size_request(aPrefSize.Width(), aPrefSize.Height());
1916 }
1917 
1919 {
1920  m_xTokenWIN.reset();
1921 }
1922 
1924 {
1925  OnModify(true);
1926 }
1927 
1929 {
1930  OnModify(false);
1931 }
1932 
1933 // bAllLevels is used as signal to change all levels of the example
1934 void SwTOXEntryTabPage::OnModify(bool bAllLevels)
1935 {
1936  UpdateDescriptor();
1937 
1938  SwMultiTOXTabDialog* pTOXDlg = static_cast<SwMultiTOXTabDialog*>(GetDialogController());
1939  if (pTOXDlg)
1940  {
1941  sal_uInt16 nCurLevel = m_xLevelLB->get_selected_index() + 1;
1942  if (aLastTOXType.eType == TOX_CONTENT && bAllLevels)
1943  nCurLevel = USHRT_MAX;
1944  pTOXDlg->CreateOrUpdateExample(
1945  pTOXDlg->GetCurrentTOXType().eType, TOX_PAGE_ENTRY, nCurLevel);
1946  }
1947 }
1948 
1950 {
1951  // nothing to do
1952  return true;
1953 }
1954 
1956 {
1957  SwMultiTOXTabDialog* pTOXDlg = static_cast<SwMultiTOXTabDialog*>(GetDialogController());
1958  const CurTOXType aCurType = pTOXDlg->GetCurrentTOXType();
1959  m_pCurrentForm = pTOXDlg->GetForm(aCurType);
1960  if(TOX_INDEX == aCurType.eType)
1961  {
1962  SwTOXDescription& rDesc = pTOXDlg->GetTOXDescription(aCurType);
1963  const OUString& sMainEntryCharStyle = rDesc.GetMainEntryCharStyle();
1964  if(!sMainEntryCharStyle.isEmpty())
1965  {
1966  if (m_xMainEntryStyleLB->find_text(sMainEntryCharStyle) == -1)
1967  m_xMainEntryStyleLB->append_text(sMainEntryCharStyle);
1968  m_xMainEntryStyleLB->set_active_text(sMainEntryCharStyle);
1969  }
1970  else
1971  m_xMainEntryStyleLB->set_active_text(sNoCharStyle);
1972  m_xAlphaDelimCB->set_active( bool(rDesc.GetIndexOptions() & SwTOIOptions::AlphaDelimiter) );
1973  }
1974  m_xRelToStyleCB->set_active(m_pCurrentForm->IsRelTabPos());
1976 }
1977 
1979 {
1980  SwMultiTOXTabDialog* pTOXDlg = static_cast<SwMultiTOXTabDialog*>(GetDialogController());
1981  const CurTOXType aCurType = pTOXDlg->GetCurrentTOXType();
1982 
1983  m_pCurrentForm = pTOXDlg->GetForm(aCurType);
1984  if( !( aLastTOXType == aCurType ))
1985  {
1986  bool bToxIsAuthorities = TOX_AUTHORITIES == aCurType.eType;
1987  bool bToxIsIndex = TOX_INDEX == aCurType.eType;
1988  bool bToxIsContent = TOX_CONTENT == aCurType.eType;
1989  bool bToxSupportsLinks = TOX_CONTENT == aCurType.eType ||
1990  TOX_ILLUSTRATIONS == aCurType.eType ||
1991  TOX_TABLES == aCurType.eType ||
1992  TOX_OBJECTS == aCurType.eType ||
1993  TOX_USER == aCurType.eType;
1994 
1995  m_xLevelLB->clear();
1996  for(sal_uInt16 i = 1; i < m_pCurrentForm->GetFormMax(); i++)
1997  {
1998  if(bToxIsAuthorities)
2000  static_cast<ToxAuthorityType>(i - 1)) );
2001  else if( bToxIsIndex )
2002  {
2003  if(i == 1)
2004  m_xLevelLB->append_text( sDelimStr );
2005  else
2006  m_xLevelLB->append_text( OUString::number(i - 1) );
2007  }
2008  else
2009  m_xLevelLB->append_text(OUString::number(i));
2010  }
2011  if(bToxIsAuthorities)
2012  {
2013  SwWrtShell& rSh = pTOXDlg->GetWrtShell();
2014  const SwAuthorityFieldType* pFType = static_cast<const SwAuthorityFieldType*>(
2015  rSh.GetFieldType(SwFieldIds::TableOfAuthorities, OUString()));
2016  if(pFType)
2017  {
2018  if(pFType->IsSortByDocument())
2019  m_xSortDocPosRB->set_active(true);
2020  else
2021  {
2022  m_xSortContentRB->set_active(true);
2023  const sal_uInt16 nKeyCount = pFType->GetSortKeyCount();
2024  if(0 < nKeyCount)
2025  {
2026  const SwTOXSortKey* pKey = pFType->GetSortKey(0);
2027  m_xFirstKeyLB->set_active_id(OUString::number(pKey->eField));
2028  m_xFirstSortUpRB->set_active(pKey->bSortAscending);
2029  m_xFirstSortDownRB->set_active(!pKey->bSortAscending);
2030  }
2031  if(1 < nKeyCount)
2032  {
2033  const SwTOXSortKey* pKey = pFType->GetSortKey(1);
2034  m_xSecondKeyLB->set_active_id(OUString::number(pKey->eField));
2035  m_xSecondSortUpRB->set_active(pKey->bSortAscending);
2036  m_xSecondSortDownRB->set_active(!pKey->bSortAscending);
2037  }
2038  if(2 < nKeyCount)
2039  {
2040  const SwTOXSortKey* pKey = pFType->GetSortKey(2);
2041  m_xThirdKeyLB->set_active_id(OUString::number(pKey->eField));
2042  m_xThirdSortUpRB->set_active(pKey->bSortAscending);
2043  m_xThirdSortDownRB->set_active(!pKey->bSortAscending);
2044  }
2045  }
2046  }
2047  SortKeyHdl(m_xSortDocPosRB->get_active() ? *m_xSortDocPosRB : *m_xSortContentRB);
2048  m_xLevelFT->set_label(sAuthTypeStr);
2049  }
2050  else
2051  m_xLevelFT->set_label(sLevelStr);
2052 
2053  m_xLevelLB->select(bToxIsIndex ? 1 : 0);
2054 
2055  //show or hide controls
2056  m_xEntryNoPB->set_visible(bToxIsContent);
2057  m_xHyperLinkPB->set_visible(bToxSupportsLinks);
2058  m_xRelToStyleCB->set_visible(!bToxIsAuthorities);
2059  m_xChapterInfoPB->set_visible(!bToxIsContent && !bToxIsAuthorities);
2060  m_xEntryPB->set_visible(!bToxIsAuthorities);
2061  m_xPageNoPB->set_visible(!bToxIsAuthorities);
2062  m_xAuthFieldsLB->set_visible(bToxIsAuthorities);
2063  m_xAuthInsertPB->set_visible(bToxIsAuthorities);
2064  m_xAuthRemovePB->set_visible(bToxIsAuthorities);
2065 
2066  m_xFormatFrame->set_visible(!bToxIsAuthorities);
2067 
2068  m_xSortingFrame->set_visible(bToxIsAuthorities);
2069  m_xSortKeyFrame->set_visible(bToxIsAuthorities);
2070 
2071  m_xMainEntryStyleFT->set_visible(bToxIsIndex);
2072  m_xMainEntryStyleLB->set_visible(bToxIsIndex);
2073  m_xAlphaDelimCB->set_visible(bToxIsIndex);
2074  m_xCommaSeparatedCB->set_visible(bToxIsIndex);
2075  }
2076  aLastTOXType = aCurType;
2077 
2078  //invalidate PatternWindow
2079  m_xTokenWIN->SetInvalid();
2080  LevelHdl(*m_xLevelLB);
2081 }
2082 
2084 {
2085  WriteBackLevel();
2086  SwMultiTOXTabDialog* pTOXDlg = static_cast<SwMultiTOXTabDialog*>(GetDialogController());
2087  SwTOXDescription& rDesc = pTOXDlg->GetTOXDescription(aLastTOXType);
2089  {
2090  const OUString sTemp(m_xMainEntryStyleLB->get_active_text());
2091  rDesc.SetMainEntryCharStyle(sNoCharStyle == sTemp ? OUString(): sTemp);
2093  if (m_xAlphaDelimCB->get_active())
2094  nIdxOptions |= SwTOIOptions::AlphaDelimiter;
2095  rDesc.SetIndexOptions(nIdxOptions);
2096  }
2097  else if (TOX_AUTHORITIES == aLastTOXType.eType)
2098  {
2099  rDesc.SetSortByDocument(m_xSortDocPosRB->get_active());
2100  SwTOXSortKey aKey1, aKey2, aKey3;
2101  aKey1.eField = static_cast<ToxAuthorityField>(m_xFirstKeyLB->get_active_id().toInt32());
2102  aKey1.bSortAscending = m_xFirstSortUpRB->get_active();
2103  aKey2.eField = static_cast<ToxAuthorityField>(m_xSecondKeyLB->get_active_id().toInt32());
2104  aKey2.bSortAscending = m_xSecondSortUpRB->get_active();
2105  aKey3.eField = static_cast<ToxAuthorityField>(m_xThirdKeyLB->get_active_id().toInt32());
2106  aKey3.bSortAscending = m_xThirdSortUpRB->get_active();
2107 
2108  rDesc.SetSortKeys(aKey1, aKey2, aKey3);
2109  }
2110  SwForm* pCurrentForm = pTOXDlg->GetForm(aLastTOXType);
2111  if (m_xRelToStyleCB->get_visible())
2112  pCurrentForm->SetRelTabPos(m_xRelToStyleCB->get_active());
2113  if (m_xCommaSeparatedCB->get_visible())
2114  pCurrentForm->SetCommaSeparated(m_xCommaSeparatedCB->get_active());
2115 }
2116 
2118 {
2119  UpdateDescriptor();
2120  return DeactivateRC::LeavePage;
2121 }
2122 
2123 std::unique_ptr<SfxTabPage> SwTOXEntryTabPage::Create(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet* rAttrSet)
2124 {
2125  return std::make_unique<SwTOXEntryTabPage>(pPage, pController, *rAttrSet);
2126 }
2127 
2129 {
2130  if (m_xCharStyleLB->get_active() != -1)
2131  {
2132  SfxStringItem aStyle(SID_STYLE_EDIT, m_xCharStyleLB->get_active_text());
2133  SfxUInt16Item aFamily(SID_STYLE_FAMILY, sal_uInt16(SfxStyleFamily::Char));
2134  static_cast<SwMultiTOXTabDialog*>(GetDialogController())->GetWrtShell().
2135  GetView().GetViewFrame()->GetDispatcher()->ExecuteList(SID_STYLE_EDIT,
2136  SfxCallMode::SYNCHRON,
2137  { &aStyle, &aFamily });
2138  }
2139 }
2140 
2141 IMPL_LINK(SwTOXEntryTabPage, RemoveInsertAuthHdl, weld::Button&, rButton, void)
2142 {
2143  bool bInsert = &rButton == m_xAuthInsertPB.get();
2144  if(bInsert)
2145  {
2146  sal_Int32 nSelPos = m_xAuthFieldsLB->get_active();
2147  const OUString sToInsert(m_xAuthFieldsLB->get_active_text());
2148  SwFormToken aInsert(TOKEN_AUTHORITY);
2149  aInsert.nAuthorityField = m_xAuthFieldsLB->get_id(nSelPos).toUInt32();
2150  m_xTokenWIN->InsertAtSelection(aInsert);
2151  m_xAuthFieldsLB->remove_text(sToInsert);
2152  m_xAuthFieldsLB->set_active(nSelPos ? nSelPos - 1 : 0);
2153  }
2154  else
2155  {
2156  SwTOXWidget* pCtrl = m_xTokenWIN->GetActiveControl();
2157  OSL_ENSURE(WindowType::EDIT != pCtrl->GetType(), "Remove should be disabled");
2158  if (WindowType::EDIT != pCtrl->GetType())
2159  {
2160  //fill it into the ListBox
2161  const SwFormToken& rToken = static_cast<SwTOXButton*>(pCtrl)->GetFormToken();
2162  PreTokenButtonRemoved(rToken);
2163  m_xTokenWIN->RemoveControl(static_cast<SwTOXButton*>(pCtrl));
2164  }
2165  }
2166  ModifyHdl(nullptr);
2167 }
2168 
2170 {
2171  //fill it into the ListBox
2172  sal_uInt32 nData = rToken.nAuthorityField;
2173  m_xAuthFieldsLB->append(OUString::number(nData), SwResId(STR_AUTH_FIELD_ARY[nData]));
2174 }
2175 
2177 {
2178  m_xAllLevelsPB->grab_focus();
2179 }
2180 
2181 // This function initializes the default value in the Token
2182 // put here the UI dependent initializations
2183 IMPL_LINK(SwTOXEntryTabPage, InsertTokenHdl, weld::Button&, rBtn, void)
2184 {
2185  OUString sText;
2186  FormTokenType eTokenType = TOKEN_ENTRY_NO;
2187  OUString sCharStyle;
2188  sal_uInt16 nChapterFormat = CF_NUMBER; // i89791
2189  if (&rBtn == m_xEntryNoPB.get())
2190  {
2191  sText = SwForm::GetFormEntryNum();
2192  eTokenType = TOKEN_ENTRY_NO;
2193  }
2194  else if (&rBtn == m_xEntryPB.get())
2195  {
2196  if( TOX_CONTENT == m_pCurrentForm->GetTOXType() )
2197  {
2198  sText = SwForm::GetFormEntryText();
2199  eTokenType = TOKEN_ENTRY_TEXT;
2200  }
2201  else
2202  {
2203  sText = SwForm::GetFormEntry();
2204  eTokenType = TOKEN_ENTRY;
2205  }
2206  }
2207  else if (&rBtn == m_xChapterInfoPB.get())
2208  {
2209  sText = SwForm::GetFormChapterMark();
2210  eTokenType = TOKEN_CHAPTER_INFO;
2211  nChapterFormat = CF_NUM_NOPREPST_TITLE; // i89791
2212  }
2213  else if (&rBtn == m_xPageNoPB.get())
2214  {
2215  sText = SwForm::GetFormPageNums();
2216  eTokenType = TOKEN_PAGE_NUMS;
2217  }
2218  else if (&rBtn == m_xHyperLinkPB.get())
2219  {
2220  sText = SwForm::GetFormLinkStt();
2221  eTokenType = TOKEN_LINK_START;
2222  sCharStyle = SwResId(STR_POOLCHR_TOXJUMP);
2223  }
2224  else if (&rBtn == m_xTabPB.get())
2225  {
2226  sText = SwForm::GetFormTab();
2227  eTokenType = TOKEN_TAB_STOP;
2228  }
2229  SwFormToken aInsert(eTokenType);
2230  aInsert.sCharStyleName = sCharStyle;
2231  aInsert.nTabStopPosition = 0;
2232  aInsert.nChapterFormat = nChapterFormat; // i89791
2233  m_xTokenWIN->InsertAtSelection(aInsert);
2234  ModifyHdl(nullptr);
2235 }
2236 
2238 {
2239  //get current level
2240  //write it into all levels
2241  if(m_xTokenWIN->IsValid())
2242  {
2243  const OUString sNewToken = m_xTokenWIN->GetPattern();
2244  for(sal_uInt16 i = 1; i < m_pCurrentForm->GetFormMax(); i++)
2245  m_pCurrentForm->SetPattern(i, sNewToken);
2246 
2247  OnModify(true);
2248  }
2249 }
2250 
2252 {
2253  if(m_xTokenWIN->IsValid())
2254  {
2255  const OUString sNewToken = m_xTokenWIN->GetPattern();
2256  const sal_uInt16 nLastLevel = m_xTokenWIN->GetLastLevel();
2257  if(nLastLevel != USHRT_MAX)
2258  m_pCurrentForm->SetPattern(nLastLevel + 1, sNewToken);
2259  }
2260 }
2261 
2263 {
2264  if(bInLevelHdl)
2265  return;
2266  bInLevelHdl = true;
2267  WriteBackLevel();
2268 
2269  const sal_uInt16 nLevel = rBox.get_selected_index();
2270  m_xTokenWIN->SetForm(*m_pCurrentForm, nLevel);
2271  if(TOX_AUTHORITIES == m_pCurrentForm->GetTOXType())
2272  {
2273  //fill the types in
2274  m_xAuthFieldsLB->clear();
2275  for( sal_uInt32 i = 0; i < AUTH_FIELD_END; i++)
2276  {
2277  m_xAuthFieldsLB->append(OUString::number(i), SwResId(STR_AUTH_FIELD_ARY[i]));
2278  }
2279 
2280  // #i21237#
2281  SwFormTokens aPattern = m_pCurrentForm->GetPattern(nLevel + 1);
2282 
2283  for(const auto& aToken : aPattern)
2284  {
2285  if(TOKEN_AUTHORITY == aToken.eTokenType)
2286  {
2287  sal_uInt32 nSearch = aToken.nAuthorityField;
2288  int nLstBoxPos = m_xAuthFieldsLB->find_id(OUString::number(nSearch));
2289  OSL_ENSURE(nLstBoxPos != -1, "Entry not found?");
2290  m_xAuthFieldsLB->remove(nLstBoxPos);
2291  }
2292  }
2293  m_xAuthFieldsLB->set_active(0);
2294  }
2295  bInLevelHdl = false;
2296  rBox.grab_focus();
2297 }
2298 
2300 {
2301  bool bEnable = m_xSortContentRB->get_active();
2302  m_xSortKeyFrame->set_sensitive(bEnable);
2303 }
2304 
2305 IMPL_LINK(SwTOXEntryTabPage, TokenSelectedHdl, SwFormToken&, rToken, void)
2306 {
2307  if (!rToken.sCharStyleName.isEmpty())
2308  m_xCharStyleLB->set_active_text(rToken.sCharStyleName);
2309  else
2310  m_xCharStyleLB->set_active_text(sNoCharStyle);
2311 
2312  const OUString sEntry = m_xCharStyleLB->get_active_text();
2313  m_xEditStylePB->set_sensitive(sEntry != sNoCharStyle);
2314 
2315  if(rToken.eTokenType == TOKEN_CHAPTER_INFO)
2316  {
2317 //---> i89791
2318  switch(rToken.nChapterFormat)
2319  {
2320  default:
2321  m_xChapterEntryLB->set_active(-1);//to alert the user
2322  break;
2323  case CF_NUM_NOPREPST_TITLE:
2324  m_xChapterEntryLB->set_active(0);
2325  break;
2326  case CF_TITLE:
2327  m_xChapterEntryLB->set_active(1);
2328  break;
2329  case CF_NUMBER_NOPREPST:
2330  m_xChapterEntryLB->set_active(2);
2331  break;
2332  }
2333 //i53420
2334 
2335  m_xEntryOutlineLevelNF->set_value(rToken.nOutlineLevel);
2336  }
2337 
2338 //i53420
2339  if(rToken.eTokenType == TOKEN_ENTRY_NO)
2340  {
2341  m_xEntryOutlineLevelNF->set_value(rToken.nOutlineLevel);
2342  const sal_uInt16 nFormat =
2343  rToken.nChapterFormat == CF_NUM_NOPREPST_TITLE ? 1 : 0;
2344  m_xNumberFormatLB->set_active(nFormat);
2345  }
2346 
2347  bool bTabStop = TOKEN_TAB_STOP == rToken.eTokenType;
2348  m_xFillCharFT->set_visible(bTabStop);
2349  m_xFillCharCB->set_visible(bTabStop);
2350  m_xTabPosFT->set_visible(bTabStop);
2351  m_xTabPosMF->set_visible(bTabStop);
2352  m_xAutoRightCB->set_visible(bTabStop);
2353  m_xAutoRightCB->set_sensitive(bTabStop);
2354  if(bTabStop)
2355  {
2356  m_xTabPosMF->set_value(m_xTabPosMF->normalize(rToken.nTabStopPosition), FieldUnit::TWIP);
2357  m_xAutoRightCB->set_active(SvxTabAdjust::End == rToken.eTabAlign);
2358  m_xFillCharCB->set_entry_text(OUString(rToken.cTabFillChar));
2359  m_xTabPosFT->set_sensitive(!m_xAutoRightCB->get_active());
2360  m_xTabPosMF->set_sensitive(!m_xAutoRightCB->get_active());
2361  }
2362  else
2363  {
2364  m_xTabPosMF->set_sensitive(false);
2365  }
2366 
2367  bool bIsChapterInfo = rToken.eTokenType == TOKEN_CHAPTER_INFO;
2368  bool bIsEntryNumber = rToken.eTokenType == TOKEN_ENTRY_NO;
2369  m_xChapterEntryFT->set_visible( bIsChapterInfo );
2370  m_xChapterEntryLB->set_visible( bIsChapterInfo );
2371  m_xEntryOutlineLevelFT->set_visible( bIsChapterInfo || bIsEntryNumber );
2372  m_xEntryOutlineLevelNF->set_visible( bIsChapterInfo || bIsEntryNumber );
2373  m_xNumberFormatFT->set_visible( bIsEntryNumber );
2374  m_xNumberFormatLB->set_visible( bIsEntryNumber );
2375 
2376  //now enable the visible buttons
2377  //- inserting the same type of control is not allowed
2378  //- some types of controls can only appear once (EntryText EntryNumber)
2379 
2380  if (m_xEntryNoPB->get_visible())
2381  {
2382  m_xEntryNoPB->set_sensitive(TOKEN_ENTRY_NO != rToken.eTokenType );
2383  }
2384  if (m_xEntryPB->get_visible())
2385  {
2386  m_xEntryPB->set_sensitive(TOKEN_ENTRY_TEXT != rToken.eTokenType &&
2387  !m_xTokenWIN->Contains(TOKEN_ENTRY_TEXT)
2388  && !m_xTokenWIN->Contains(TOKEN_ENTRY));
2389  }
2390 
2391  if (m_xChapterInfoPB->get_visible())
2392  {
2393  m_xChapterInfoPB->set_sensitive(TOKEN_CHAPTER_INFO != rToken.eTokenType);
2394  }
2395  if (m_xPageNoPB->get_visible())
2396  {
2397  m_xPageNoPB->set_sensitive(TOKEN_PAGE_NUMS != rToken.eTokenType &&
2398  !m_xTokenWIN->Contains(TOKEN_PAGE_NUMS));
2399  }
2400  if (m_xTabPB->get_visible())
2401  {
2402  m_xTabPB->set_sensitive(!bTabStop);
2403  }
2404  if (m_xHyperLinkPB->get_visible())
2405  {
2406  m_xHyperLinkPB->set_sensitive(TOKEN_LINK_START != rToken.eTokenType &&
2407  TOKEN_LINK_END != rToken.eTokenType);
2408  }
2409  //table of authorities
2410  if (m_xAuthInsertPB->get_visible())
2411  {
2412  bool bText = TOKEN_TEXT == rToken.eTokenType;
2413  m_xAuthInsertPB->set_sensitive(bText && !m_xAuthFieldsLB->get_active_text().isEmpty());
2414  m_xAuthRemovePB->set_sensitive(!bText);
2415  }
2416 }
2417 
2418 IMPL_LINK(SwTOXEntryTabPage, StyleSelectHdl, weld::ComboBox&, rBox, void)
2419 {
2420  OUString sEntry = rBox.get_active_text();
2421  const sal_uInt16 nId = rBox.get_active_id().toUInt32();
2422  const bool bEqualsNoCharStyle = sEntry == sNoCharStyle;
2423  m_xEditStylePB->set_sensitive(!bEqualsNoCharStyle);
2424  if (bEqualsNoCharStyle)
2425  sEntry.clear();
2426  SwTOXWidget* pCtrl = m_xTokenWIN->GetActiveControl();
2427  OSL_ENSURE(pCtrl, "no active control?");
2428  if(pCtrl)
2429  {
2430  if(WindowType::EDIT == pCtrl->GetType())
2431  static_cast<SwTOXEdit*>(pCtrl)->SetCharStyleName(sEntry, nId);
2432  else
2433  static_cast<SwTOXButton*>(pCtrl)->SetCharStyleName(sEntry, nId);
2434 
2435  }
2436  ModifyHdl(nullptr);
2437 }
2438 
2439 IMPL_LINK(SwTOXEntryTabPage, ChapterInfoHdl, weld::ComboBox&, rBox, void)
2440 {
2441  int nPos = rBox.get_active();
2442  if (nPos != -1)
2443  {
2444  SwTOXWidget* pCtrl = m_xTokenWIN->GetActiveControl();
2445  OSL_ENSURE(pCtrl, "no active control?");
2446  if(pCtrl && WindowType::EDIT != pCtrl->GetType())
2447  static_cast<SwTOXButton*>(pCtrl)->SetChapterInfo(nPos);
2448  ModifyHdl(nullptr);
2449  }
2450 }
2451 
2452 IMPL_LINK(SwTOXEntryTabPage, ChapterInfoOutlineHdl, weld::SpinButton&, rEdit, void)
2453 {
2454  const sal_uInt16 nLevel = rEdit.get_value();
2455 
2456  SwTOXWidget* pCtrl = m_xTokenWIN->GetActiveControl();
2457  OSL_ENSURE(pCtrl, "no active control?");
2458  if(pCtrl && WindowType::EDIT != pCtrl->GetType())
2459  static_cast<SwTOXButton*>(pCtrl)->SetOutlineLevel(nLevel);
2460 
2461  ModifyHdl(nullptr);
2462 }
2463 
2464 IMPL_LINK(SwTOXEntryTabPage, NumberFormatHdl, weld::ComboBox&, rBox, void)
2465 {
2466  const sal_Int32 nPos = rBox.get_active();
2467  if (nPos != -1)
2468  {
2469  SwTOXWidget* pCtrl = m_xTokenWIN->GetActiveControl();
2470  OSL_ENSURE(pCtrl, "no active control?");
2471  if(pCtrl && WindowType::EDIT != pCtrl->GetType())
2472  {
2473  static_cast<SwTOXButton*>(pCtrl)->SetEntryNumberFormat(nPos);//i89791
2474  }
2475  ModifyHdl(nullptr);
2476  }
2477 }
2478 
2480 {
2481  SwTOXWidget* pCtrl = m_xTokenWIN->GetActiveControl();
2482  OSL_ENSURE(pCtrl && WindowType::EDIT != pCtrl->GetType() &&
2483  TOKEN_TAB_STOP == static_cast<SwTOXButton*>(pCtrl)->GetFormToken().eTokenType,
2484  "no active style::TabStop control?");
2485  if( pCtrl && WindowType::EDIT != pCtrl->GetType() )
2486  {
2487  static_cast<SwTOXButton*>(pCtrl)->SetTabPosition( static_cast< SwTwips >(
2488  rEdit.denormalize(rEdit.get_value(FieldUnit::TWIP))));
2489  }
2490  ModifyHdl(nullptr);
2491 }
2492 
2493 IMPL_LINK(SwTOXEntryTabPage, FillCharHdl, weld::ComboBox&, rBox, void)
2494 {
2495  SwTOXWidget* pCtrl = m_xTokenWIN->GetActiveControl();
2496  OSL_ENSURE(pCtrl && WindowType::EDIT != pCtrl->GetType() &&
2497  TOKEN_TAB_STOP == static_cast<SwTOXButton*>(pCtrl)->GetFormToken().eTokenType,
2498  "no active style::TabStop control?");
2499  if (pCtrl && WindowType::EDIT != pCtrl->GetType())
2500  {
2501  sal_Unicode cSet;
2502  if (!rBox.get_active_text().isEmpty())
2503  cSet = rBox.get_active_text()[0];
2504  else
2505  cSet = ' ';
2506  static_cast<SwTOXButton*>(pCtrl)->SetFillChar( cSet );
2507  }
2508  ModifyHdl(nullptr);
2509 }
2510 
2511 IMPL_LINK(SwTOXEntryTabPage, AutoRightHdl, weld::ToggleButton&, rBox, void)
2512 {
2513  //the most right style::TabStop is usually right aligned
2514  SwTOXWidget* pCurCtrl = m_xTokenWIN->GetActiveControl();
2515  OSL_ENSURE(WindowType::EDIT != pCurCtrl->GetType() &&
2516  static_cast<SwTOXButton*>(pCurCtrl)->GetFormToken().eTokenType == TOKEN_TAB_STOP,
2517  "no style::TabStop selected!");
2518 
2519  const SwFormToken& rToken = static_cast<SwTOXButton*>(pCurCtrl)->GetFormToken();
2520  bool bChecked = rBox.get_active();
2521  if(rToken.eTokenType == TOKEN_TAB_STOP)
2522  static_cast<SwTOXButton*>(pCurCtrl)->SetTabAlign(
2523  bChecked ? SvxTabAdjust::End : SvxTabAdjust::Left);
2524  m_xTabPosFT->set_sensitive(!bChecked);
2525  m_xTabPosMF->set_sensitive(!bChecked);
2526  ModifyHdl(nullptr);
2527 }
2528 
2530 {
2531  SwDocShell* pDocSh = rSh.GetView().GetDocShell();
2532  ::FillCharStyleListBox(*m_xCharStyleLB, pDocSh, true, true);
2533  const OUString sDefault(SwResId(STR_POOLCOLL_STANDARD));
2534  for (int i = 0, nCount = m_xCharStyleLB->get_count(); i < nCount; ++i)
2535  {
2536  const OUString sEntry = m_xCharStyleLB->get_text(i);
2537  if(sDefault != sEntry)
2538  {
2539  m_xMainEntryStyleLB->append(m_xCharStyleLB->get_id(i), sEntry);
2540  }
2541  }
2543  RES_POOLCHR_IDX_MAIN_ENTRY, OUString()));
2544 }
2545 
2546 static const char* STR_TOKEN_ARY[] =
2547 {
2548  STR_TOKEN_ENTRY_NO,
2549  STR_TOKEN_ENTRY, //mapped from original STR_TOKEN_ENTRY_TEXT,
2550  STR_TOKEN_ENTRY,
2551  STR_TOKEN_TAB_STOP,
2552  nullptr,
2553  STR_TOKEN_PAGE_NUMS,
2554  STR_TOKEN_CHAPTER_INFO,
2555  STR_TOKEN_LINK_START,
2556  STR_TOKEN_LINK_END,
2557  STR_TOKEN_AUTHORITY
2558 };
2559 
2560 static const char* STR_TOKEN_HELP_ARY[] =
2561 {
2562  STR_TOKEN_HELP_ENTRY_NO,
2563  STR_TOKEN_HELP_ENTRY, // mapped from original STR_TOKEN_HELP_ENTRY_TEXT,
2564  STR_TOKEN_HELP_ENTRY,
2565  STR_TOKEN_HELP_TAB_STOP,
2566  STR_TOKEN_HELP_TEXT,
2567  STR_TOKEN_HELP_PAGE_NUMS,
2568  STR_TOKEN_HELP_CHAPTER_INFO,
2569  STR_TOKEN_HELP_LINK_START,
2570  STR_TOKEN_HELP_LINK_END,
2571  STR_TOKEN_HELP_AUTHORITY
2572 };
2573 
2574 SwTokenWindow::SwTokenWindow(std::unique_ptr<weld::Container> xParent)
2575  : m_pForm(nullptr)
2576  , m_nLevel(0)
2577  , m_bValid(false)
2578  , m_sCharStyle(SwResId(STR_CHARSTYLE))
2579  , m_pActiveCtrl(nullptr)
2580  , m_pParent(nullptr)
2581  , m_xParentWidget(std::move(xParent))
2582  , m_xBuilder(Application::CreateBuilder(m_xParentWidget.get(), "modules/swriter/ui/tokenwidget.ui"))
2583  , m_xContainer(m_xBuilder->weld_container("TokenWidget"))
2584  , m_xLeftScrollWin(m_xBuilder->weld_button("left"))
2585  , m_xCtrlParentWin(m_xBuilder->weld_container("ctrl"))
2586  , m_xScrollWin(m_xBuilder->weld_scrolled_window("scrollwin"))
2587  , m_xRightScrollWin(m_xBuilder->weld_button("right"))
2588 {
2589  m_xScrollWin->connect_hadjustment_changed(LINK(this, SwTokenWindow, ScrollHdl));
2590  m_xCtrlParentWin->set_size_request(-1, Edit::GetMinimumEditSize().Height());
2591  m_xCtrlParentWin->connect_size_allocate(LINK(this, SwTokenWindow, AdjustPositionsHdl));
2592 
2593  for (sal_uInt32 i = 0; i < TOKEN_END; ++i)
2594  {
2595  const char* pTextId = STR_TOKEN_ARY[i];
2596  if (pTextId)
2597  m_aButtonTexts[i] = SwResId(pTextId);
2598 
2599  const char* pHelpId = STR_TOKEN_HELP_ARY[i];
2600  m_aButtonHelpTexts[i] = SwResId(pHelpId);
2601  }
2602 
2603  m_sAccessibleName = SwResId(STR_STRUCTURE);
2604  m_sAdditionalAccnameString1 = SwResId(STR_ADDITIONAL_ACCNAME_STRING1);
2605  m_sAdditionalAccnameString2 = SwResId(STR_ADDITIONAL_ACCNAME_STRING2);
2606  m_sAdditionalAccnameString3 = SwResId(STR_ADDITIONAL_ACCNAME_STRING3);
2607 
2608  Link<weld::Button&,void> aLink(LINK(this, SwTokenWindow, ScrollBtnHdl));
2609  m_xLeftScrollWin->connect_clicked(aLink);
2610  m_xRightScrollWin->connect_clicked(aLink);
2611 }
2612 
2614 {
2615 }
2616 
2617 void SwTokenWindow::SetForm(SwForm& rForm, sal_uInt16 nL)
2618 {
2619  SetActiveControl(nullptr);
2620  m_bValid = true;
2621 
2622  if (m_pForm)
2623  {
2624  //apply current level settings to the form
2625  m_aControlList.clear();
2626  }
2627 
2628  m_nLevel = nL;
2629  m_pForm = &rForm;
2630  //now the display
2631  if(m_nLevel < MAXLEVEL || rForm.GetTOXType() == TOX_AUTHORITIES)
2632  {
2633  // #i21237#
2634  SwFormTokens aPattern = m_pForm->GetPattern(m_nLevel + 1);
2635  bool bLastWasText = false; //assure alternating text - code - text
2636 
2637  SwTOXWidget* pSetActiveControl = nullptr;
2638  for (const auto& aToken : aPattern) // #i21237#
2639  {
2640  if(TOKEN_TEXT == aToken.eTokenType)
2641  {
2642  SAL_WARN_IF(bLastWasText, "sw", "text following text is invalid");
2643  SwTOXWidget* pCtrl = InsertItem(aToken.sText, aToken);
2644  bLastWasText = true;
2645  if (!GetActiveControl())
2646  SetActiveControl(pCtrl);
2647  }
2648  else
2649  {
2650  if( !bLastWasText )
2651  {
2652  SwFormToken aTemp(TOKEN_TEXT);
2653  SwTOXWidget* pCtrl = InsertItem(OUString(), aTemp);
2654  if(!pSetActiveControl)
2655  pSetActiveControl = pCtrl;
2656  }
2657 
2658  OUString sForm;
2659  switch( aToken.eTokenType )
2660  {
2661  case TOKEN_ENTRY_NO: sForm = SwForm::GetFormEntryNum(); break;
2662  case TOKEN_ENTRY_TEXT: sForm = SwForm::GetFormEntryText(); break;
2663  case TOKEN_ENTRY: sForm = SwForm::GetFormEntry(); break;
2664  case TOKEN_TAB_STOP: sForm = SwForm::GetFormTab(); break;
2665  case TOKEN_PAGE_NUMS: sForm = SwForm::GetFormPageNums(); break;
2666  case TOKEN_CHAPTER_INFO: sForm = SwForm::GetFormChapterMark(); break;
2667  case TOKEN_LINK_START: sForm = SwForm::GetFormLinkStt(); break;
2668  case TOKEN_LINK_END: sForm = SwForm::GetFormLinkEnd(); break;
2669  case TOKEN_AUTHORITY: sForm = SwForm::GetFormAuth(); break;
2670  default:; //prevent warning
2671  }
2672 
2673  InsertItem( sForm, aToken );
2674  bLastWasText = false;
2675  }
2676  }
2677  if(!bLastWasText)
2678  {
2679  SwFormToken aTemp(TOKEN_TEXT);
2680  SwTOXWidget* pCtrl = InsertItem(OUString(), aTemp);
2681  if(!pSetActiveControl)
2682  pSetActiveControl = pCtrl;
2683  }
2684  SetActiveControl(pSetActiveControl);
2685  }
2686  AdjustScrolling();
2687 }
2688 
2690 {
2691  if (pSet != m_pActiveCtrl)
2692  {
2693  m_pActiveCtrl = pSet;
2694  if( m_pActiveCtrl )
2695  {
2697  //it must be a SwTOXEdit
2698  const SwFormToken* pFToken;
2699  if( WindowType::EDIT == m_pActiveCtrl->GetType() )
2700  pFToken = &static_cast<SwTOXEdit*>(m_pActiveCtrl)->GetFormToken();
2701  else
2702  pFToken = &static_cast<SwTOXButton*>(m_pActiveCtrl)->GetFormToken();
2703 
2704  SwFormToken aTemp( *pFToken );
2705  m_aButtonSelectedHdl.Call( aTemp );
2706  }
2707  }
2708 }
2709 
2710 SwTOXWidget* SwTokenWindow::InsertItem(const OUString& rText, const SwFormToken& rToken)
2711 {
2712  SwTOXWidget* pRet = nullptr;
2713 
2714  if (TOKEN_TEXT == rToken.eTokenType)
2715  {
2716  SwTOXEdit* pEdit = new SwTOXEdit(this, rToken);
2717  pEdit->set_grid_left_attach(m_aControlList.size());
2718 
2719  m_aControlList.emplace_back(pEdit);
2720 
2721  pEdit->SetText(rText);
2722  sal_uInt32 nIndex = GetControlIndex( TOKEN_TEXT );
2723  OUString strName(m_sAccessibleName + OUString::number(nIndex));
2724  if ( nIndex == 1 )
2725  {
2726  /*Press left or right arrow to choose the structure controls*/
2727  strName += " (" + m_sAdditionalAccnameString2 + ", "
2728  /*Press Ctrl+Alt+A to move focus for more operations*/
2730  /*Press Ctrl+Alt+B to move focus back to the current structure control*/
2732  }
2733  pEdit->SetAccessibleName(strName);
2734  pEdit->AdjustSize();
2735  pEdit->SetModifyHdl(LINK(this, SwTokenWindow, EditResize ));
2736  pEdit->SetPrevNextLink(LINK(this, SwTokenWindow, NextItemHdl));
2737  pEdit->SetGetFocusHdl(LINK(this, SwTokenWindow, TbxFocusHdl));
2738  pEdit->Show();
2739  pRet = pEdit;
2740  }
2741  else
2742  {
2743  SwTOXButton* pButton = new SwTOXButton(this, rToken);
2744  pButton->set_grid_left_attach(m_aControlList.size());
2745 
2746  m_aControlList.emplace_back(pButton);
2747 
2748  pButton->SetPrevNextLink(LINK(this, SwTokenWindow, NextItemBtnHdl));
2749  pButton->SetGetFocusHdl(LINK(this, SwTokenWindow, TbxFocusBtnHdl));
2750 
2751  if(TOKEN_AUTHORITY != rToken.eTokenType)
2752  pButton->SetText(m_aButtonTexts[rToken.eTokenType]);
2753  else
2754  {
2755  //use the first two chars as symbol
2757  static_cast<ToxAuthorityField>(rToken.nAuthorityField)));
2758  pButton->SetText(sTmp.copy(0, 2));
2759  }
2760 
2761  sal_uInt32 nIndex = GetControlIndex( rToken.eTokenType );
2762  OUString sAccName = m_aButtonHelpTexts[rToken.eTokenType];
2763  if ( nIndex )
2764  {
2765  sAccName += " " + OUString::number(nIndex);
2766  }
2767  pButton->SetAccessibleName( sAccName );
2768 
2769  pButton->Show();
2770  pRet = pButton;
2771  }
2772 
2773  return pRet;
2774 }
2775 
2777 {
2778  OSL_ENSURE(m_pActiveCtrl, "no active control!");
2779 
2780  if(!m_pActiveCtrl)
2781  return;
2782 
2783  SwFormToken aToInsertToken(rToken);
2784 
2785  if(TOKEN_LINK_START == aToInsertToken.eTokenType)
2786  {
2787  //determine if start or end of hyperlink is appropriate
2788  //eventually change a following link start into a link end
2789  // groups of LS LE should be ignored
2790  // <insert>
2791  //LS <insert>
2792  //LE <insert>
2793  //<insert> LS
2794  //<insert> LE
2795  //<insert>
2796  bool bPreStartLinkFound = false;
2797  bool bPreEndLinkFound = false;
2798 
2799  const SwTOXWidget* pControl = nullptr;
2800  const SwTOXWidget* pExchange = nullptr;
2801 
2802  auto it = m_aControlList.cbegin();
2803  for( ; it != m_aControlList.cend() && m_pActiveCtrl != it->get(); ++it )
2804  {
2805  pControl = it->get();
2806 
2807  if( WindowType::EDIT != pControl->GetType())
2808  {
2809  const SwFormToken& rNewToken =
2810  static_cast<const SwTOXButton*>(pControl)->GetFormToken();
2811 
2812  if( TOKEN_LINK_START == rNewToken.eTokenType )
2813  {
2814  bPreStartLinkFound = true;
2815  pExchange = nullptr;
2816  }
2817  else if(TOKEN_LINK_END == rNewToken.eTokenType)
2818  {
2819  if( bPreStartLinkFound )
2820  bPreStartLinkFound = false;
2821  else
2822  {
2823  bPreEndLinkFound = false;
2824  pExchange = pControl;
2825  }
2826  }
2827  }
2828  }
2829 
2830  bool bPostLinkStartFound = false;
2831 
2832  if(!bPreStartLinkFound && !bPreEndLinkFound)
2833  {
2834  for( ; it != m_aControlList.cend(); ++it )
2835  {
2836  pControl = it->get();
2837 
2838  if( pControl != m_pActiveCtrl &&
2839  WindowType::EDIT != pControl->GetType())
2840  {
2841  const SwFormToken& rNewToken =
2842  static_cast<const SwTOXButton*>(pControl)->GetFormToken();
2843 
2844  if( TOKEN_LINK_START == rNewToken.eTokenType )
2845  {
2846  if(bPostLinkStartFound)
2847  break;
2848  bPostLinkStartFound = true;
2849  pExchange = pControl;
2850  }
2851  else if(TOKEN_LINK_END == rNewToken.eTokenType )
2852  {
2853  if(bPostLinkStartFound)
2854  {
2855  bPostLinkStartFound = false;
2856  pExchange = nullptr;
2857  }
2858  break;
2859  }
2860  }
2861  }
2862  }
2863 
2864  if(bPreStartLinkFound)
2865  {
2866  aToInsertToken.eTokenType = TOKEN_LINK_END;
2867  aToInsertToken.sText = m_aButtonTexts[TOKEN_LINK_END];
2868  }
2869 
2870  if(bPostLinkStartFound)
2871  {
2872  OSL_ENSURE(pExchange, "no control to exchange?");
2873  if(pExchange)
2874  {
2875  const_cast<SwTOXButton*>(static_cast<const SwTOXButton*>(pExchange))->SetLinkEnd();
2876  const_cast<SwTOXButton*>(static_cast<const SwTOXButton*>(pExchange))->SetText(m_aButtonTexts[TOKEN_LINK_END]);
2877  }
2878  }
2879 
2880  if(bPreEndLinkFound)
2881  {
2882  OSL_ENSURE(pExchange, "no control to exchange?");
2883 
2884  if(pExchange)
2885  {
2886  const_cast<SwTOXButton*>(static_cast<const SwTOXButton*>(pExchange))->SetLinkStart();
2887  const_cast<SwTOXButton*>(static_cast<const SwTOXButton*>(pExchange))->SetText(m_aButtonTexts[TOKEN_LINK_START]);
2888  }
2889  }
2890  }
2891 
2892  //if the active control is text then insert a new button at the selection
2893  //else replace the button
2894  auto iterActive = std::find_if(m_aControlList.begin(), m_aControlList.end(),
2895  [this](const auto& rControl)
2896  {
2897  SwTOXWidget* pCtrl = rControl.get();
2898  return pCtrl == m_pActiveCtrl;
2899  });
2900 
2901  assert(iterActive != m_aControlList.end());
2902  if (iterActive == m_aControlList.end())
2903  return;
2904 
2905  if (WindowType::EDIT == m_pActiveCtrl->GetType())
2906  {
2907  ++iterActive;
2908 
2909  int nStartPos, nEndPos;
2910  static_cast<SwTOXEdit*>(m_pActiveCtrl)->get_selection_bounds(nStartPos, nEndPos);
2911 
2912  const OUString sEditText = static_cast<SwTOXEdit*>(m_pActiveCtrl)->GetText();
2913  const OUString sLeft = sEditText.copy( 0, std::min(nStartPos, nEndPos) );
2914  const OUString sRight = sEditText.copy( std::max(nStartPos, nEndPos) );
2915 
2916  static_cast<SwTOXEdit*>(m_pActiveCtrl)->SetText(sLeft);
2917  static_cast<SwTOXEdit*>(m_pActiveCtrl)->AdjustSize();
2918 
2919  SwFormToken aTmpToken(TOKEN_TEXT);
2920  SwTOXEdit* pEdit = new SwTOXEdit(this, aTmpToken);
2921  iterActive = m_aControlList.emplace(iterActive, pEdit);
2922 
2923  pEdit->SetText(sRight);
2924  sal_uInt32 nIndex = GetControlIndex( TOKEN_TEXT );
2925  OUString strName(m_sAccessibleName + OUString::number(nIndex));
2926  if ( nIndex == 1)
2927  {
2928  /*Press left or right arrow to choose the structure controls*/
2929  strName += " (" + m_sAdditionalAccnameString2 + ", "
2930  /*Press Ctrl+Alt+A to move focus for more operations*/
2932  /*Press Ctrl+Alt+B to move focus back to the current structure control*/
2934  }
2935  pEdit->SetAccessibleName(strName);
2936  pEdit->AdjustSize();
2937  pEdit->SetModifyHdl(LINK(this, SwTokenWindow, EditResize ));
2938  pEdit->SetPrevNextLink(LINK(this, SwTokenWindow, NextItemHdl));
2939  pEdit->SetGetFocusHdl(LINK(this, SwTokenWindow, TbxFocusHdl));
2940  pEdit->Show();
2941  }
2942  else
2943  {
2944  m_pActiveCtrl->Hide();
2945  m_pActiveCtrl = nullptr;
2946  iterActive = m_aControlList.erase(iterActive);
2947  }
2948 
2949  //now the new button
2950  SwTOXButton* pButton = new SwTOXButton(this, aToInsertToken);
2951  m_aControlList.emplace(iterActive, pButton);
2952 
2953  pButton->SetPrevNextLink(LINK(this, SwTokenWindow, NextItemBtnHdl));
2954  pButton->SetGetFocusHdl(LINK(this, SwTokenWindow, TbxFocusBtnHdl));
2955 
2956  if (TOKEN_AUTHORITY != aToInsertToken.eTokenType)
2957  {
2958  pButton->SetText(m_aButtonTexts[aToInsertToken.eTokenType]);
2959  }
2960  else
2961  {
2962  //use the first two chars as symbol
2964  static_cast<ToxAuthorityField>(aToInsertToken.nAuthorityField)));
2965  pButton->SetText(sTmp.copy(0, 2));
2966  }
2967 
2968  pButton->Check();
2969  pButton->Show();
2970  SetActiveControl(pButton);
2971 
2972  AdjustPositions();
2973 }
2974 
2975 void SwTokenWindow::RemoveControl(const SwTOXButton* pDel, bool bInternalCall)
2976 {
2977  if (bInternalCall && TOX_AUTHORITIES == m_pForm->GetTOXType())
2979 
2980  auto it = std::find_if(m_aControlList.begin(), m_aControlList.end(),
2981  [pDel](const auto& rControl)
2982  {
2983  SwTOXWidget* pCtrl = rControl.get();
2984  return pCtrl == pDel;
2985  });
2986  assert(it != m_aControlList.end()); //Control does not exist!
2987  if (it == m_aControlList.end())
2988  return;
2989 
2990  // the two neighbours of the box must be merged
2991  // the properties of the right one will be lost
2992  assert(it != m_aControlList.begin() && it != m_aControlList.end() - 1); //Button at first or last position?
2993  if (it == m_aControlList.begin() || it == m_aControlList.end() - 1)
2994  return;
2995 
2996  auto itLeft = it, itRight = it;
2997  --itLeft;
2998  ++itRight;
2999  SwTOXWidget* pLeftEdit = itLeft->get();
3000  SwTOXWidget* pRightEdit = itRight->get();
3001 
3002  static_cast<SwTOXEdit*>(pLeftEdit)->SetText(static_cast<SwTOXEdit*>(pLeftEdit)->GetText() +
3003  static_cast<SwTOXEdit*>(pRightEdit)->GetText());
3004  static_cast<SwTOXEdit*>(pLeftEdit)->AdjustSize();
3005 
3006  m_pActiveCtrl->Hide();
3007  m_pActiveCtrl = nullptr;
3008 
3009  m_aControlList.erase(itRight);
3010  m_aControlList.erase(it);
3011 
3012  SetActiveControl(pLeftEdit);
3013  AdjustPositions();
3014  m_aModifyHdl.Call(nullptr);
3015 }
3016 
3017 IMPL_LINK_NOARG(SwTokenWindow, AdjustPositionsHdl, const Size&, void)
3018 {
3019  AdjustScrolling();
3020 }
3021 
3023 {
3024  for (size_t i = 0; i < m_aControlList.size(); ++i)
3025  m_aControlList[i]->set_grid_left_attach(i);
3026  AdjustScrolling();
3027 }
3028 
3030 {
3031  m_xScrollWin->hadjustment_set_value(nOffset);
3032 }
3033 
3035 {
3036  AdjustScrolling();
3037 }
3038 
3040 {
3041  if (m_aControlList.size() > 1)
3042  {
3043  //validate scroll buttons
3044 
3045  auto nLeft = m_xScrollWin->hadjustment_get_value();
3046  auto nSpace = m_xScrollWin->hadjustment_get_page_size();
3047  auto nWidth = m_xScrollWin->hadjustment_get_upper();
3048 
3049  bool bEnable = nWidth > nSpace;
3050 
3051  //the active control must be visible
3052  if (bEnable && m_pActiveCtrl)
3053  {
3054  int x, y, width, height;
3055  m_pActiveCtrl->get_extents_relative_to(*m_xCtrlParentWin, x, y, width, height);
3056 
3057  if (x < nLeft || x + width > nLeft + nSpace)
3058  {
3059  MoveControls(x);
3060  nLeft = x;
3061  }
3062 
3063  m_xLeftScrollWin->set_sensitive(nLeft > 0);
3064  m_xRightScrollWin->set_sensitive(nLeft + nSpace < nWidth);
3065  }
3066  else
3067  {
3068  //if the control fits into the space then the first control must be at position 0
3069  m_xRightScrollWin->set_sensitive(false);
3070  m_xLeftScrollWin->set_sensitive(false);
3071  }
3072  }
3073 }
3074 
3075 IMPL_LINK(SwTokenWindow, ScrollBtnHdl, weld::Button&, rBtn, void)
3076 {
3077  if (m_aControlList.empty())
3078  return;
3079 
3080  const auto nSpace = m_xScrollWin->hadjustment_get_page_size();
3081  const auto nWidth = m_xScrollWin->hadjustment_get_upper();
3082  const auto nLeft = m_xScrollWin->hadjustment_get_value();
3083 
3084  long nMove = nLeft;
3085  if (&rBtn == m_xLeftScrollWin.get())
3086  {
3087  //find the first completely visible control (left edge visible)
3088  auto it = std::find_if(m_aControlList.begin(), m_aControlList.end(),
3089  [this, nLeft](const auto& rControl)
3090  {
3091  SwTOXWidget* pCtrl = rControl.get();
3092 
3093  int x, y, width, height;
3094  pCtrl->get_extents_relative_to(*m_xCtrlParentWin, x, y, width, height);
3095 
3096  return x >= nLeft;
3097  });
3098  if (it != m_aControlList.end())
3099  {
3100  if (it == m_aControlList.begin())
3101  {
3102  nMove = 0;
3103  }
3104  else
3105  {
3106  //move the left neighbor to the start position
3107  auto itLeft = it;
3108  --itLeft;
3109  SwTOXWidget* pLeft = itLeft->get();
3110 
3111  int x, y, width, height;
3112  pLeft->get_extents_relative_to(*m_xCtrlParentWin, x, y, width, height);
3113 
3114  nMove = x;
3115  }
3116  }
3117  }
3118  else
3119  {
3120  //find the first completely visible control (right edge visible)
3121  auto it = std::find_if(m_aControlList.rbegin(), m_aControlList.rend(),
3122  [this, nLeft, nSpace](const auto& rControl) {
3123  SwTOXWidget* pCtrl = rControl.get();
3124 
3125  int x, y, width, height;
3126  pCtrl->get_extents_relative_to(*m_xCtrlParentWin, x, y, width, height);
3127 
3128  auto nXPos = x + width;
3129  return nXPos <= nLeft + nSpace;
3130  });
3131  if (it != m_aControlList.rend() && it != m_aControlList.rbegin())
3132  {
3133  //move the right neighbor to the right edge right aligned
3134  auto itRight = it;
3135  --itRight;
3136  SwTOXWidget* pRight = itRight->get();
3137 
3138  int x, y, width, height;
3139  pRight->get_extents_relative_to(*m_xCtrlParentWin, x, y, width, height);
3140 
3141  nMove = x + width - nSpace;
3142  }
3143 
3144  //move it left until it's completely visible
3145  }
3146 
3147  if (nMove != nLeft)
3148  {
3149  // move the complete list
3150  MoveControls(nMove);
3151  m_xLeftScrollWin->set_sensitive(nMove > 0);
3152  m_xRightScrollWin->set_sensitive(nMove + nSpace < nWidth);
3153  }
3154 }
3155 
3157 {
3158  OUStringBuffer sRet;
3159 
3160  for (const auto& elem : m_aControlList)
3161  {
3162  const SwTOXWidget* pCtrl = elem.get();
3163 
3164  const SwFormToken &rNewToken = pCtrl->GetType() == WindowType::EDIT
3165  ? const_cast<SwTOXEdit*>(static_cast<const SwTOXEdit*>(pCtrl))->GetFormToken()
3166  : static_cast<const SwTOXButton*>(pCtrl)->GetFormToken();
3167 
3168  //TODO: prevent input of TOX_STYLE_DELIMITER in KeyInput
3169  sRet.append(rNewToken.GetString());
3170  }
3171 
3172  return sRet.makeStringAndClear();
3173 }
3174 
3175 // Check if a control of the specified TokenType is already contained in the list
3177 {
3178  bool bRet = false;
3179 
3180  for (const auto& elem : m_aControlList)
3181  {
3182  const SwTOXWidget* pCtrl = elem.get();
3183  const SwFormToken &rNewToken = pCtrl->GetType() == WindowType::EDIT
3184  ? const_cast<SwTOXEdit*>(static_cast<const SwTOXEdit*>(pCtrl))->GetFormToken()
3185  : static_cast<const SwTOXButton*>(pCtrl)->GetFormToken();
3186 
3187  if (eSearchFor == rNewToken.eTokenType)
3188  {
3189  bRet = true;
3190  break;
3191  }
3192  }
3193 
3194  return bRet;
3195 }
3196 
3198 {
3199  OUString sEntry;
3200  if (rToken.eTokenType != TOKEN_AUTHORITY)
3201  sEntry = m_aButtonHelpTexts[rToken.eTokenType];
3202  else
3203  {
3205  static_cast<ToxAuthorityField>(rToken.nAuthorityField));
3206  }
3207 
3208  if (rToken.eTokenType != TOKEN_TAB_STOP)
3209  {
3210  if (!rToken.sCharStyleName.isEmpty())
3211  {
3212  sEntry += " " + m_sCharStyle + rToken.sCharStyleName;
3213  }
3214  }
3215 
3216  return sEntry;
3217 }
3218 
3219 IMPL_LINK(SwTokenWindow, EditResize, SwTOXEdit&, rEdit, void)
3220 {
3221  rEdit.AdjustSize();
3222  AdjustPositions();
3223  m_aModifyHdl.Call(nullptr);
3224 }
3225 
3226 IMPL_LINK(SwTokenWindow, NextItemHdl, SwTOXEdit&, rEdit, void)
3227 {
3228  auto it = std::find_if(m_aControlList.begin(), m_aControlList.end(),
3229  [&rEdit](const auto& rControl)
3230  {
3231  SwTOXWidget* pCtrl = rControl.get();
3232  return pCtrl == &rEdit;
3233  });
3234 
3235  if (it == m_aControlList.end())
3236  return;
3237 
3238  auto itTest = it;
3239  ++itTest;
3240 
3241  if ((it != m_aControlList.begin() && !rEdit.IsNextControl()) ||
3242  (itTest != m_aControlList.end() && rEdit.IsNextControl()))
3243  {
3244  auto iterFocus = it;
3245  rEdit.IsNextControl() ? ++iterFocus : --iterFocus;
3246 
3247  SwTOXWidget *pCtrlFocus = iterFocus->get();
3248  pCtrlFocus->GrabFocus();
3249  static_cast<SwTOXButton*>(pCtrlFocus)->Check();
3250 
3251  AdjustScrolling();
3252  }
3253 }
3254 
3255 IMPL_LINK(SwTokenWindow, TbxFocusHdl, SwTOXWidget&, rControl, void)
3256 {
3257  SwTOXEdit* pEdit = static_cast<SwTOXEdit*>(&rControl);
3258  for (const auto& aControl : m_aControlList)
3259  {
3260  SwTOXWidget* pCtrl = aControl.get();
3261  if (pCtrl && pCtrl->GetType() != WindowType::EDIT)
3262  static_cast<SwTOXButton*>(pCtrl)->Check(false);
3263  }
3264 
3265  SetActiveControl(pEdit);
3266 }
3267 
3268 IMPL_LINK(SwTokenWindow, NextItemBtnHdl, SwTOXButton&, rBtn, void )
3269 {
3270  auto it = std::find_if(m_aControlList.begin(), m_aControlList.end(),
3271  [&rBtn](const auto& rControl)
3272  {
3273  SwTOXWidget* pCtrl = rControl.get();
3274  return pCtrl == &rBtn;
3275  });
3276 
3277  if (it == m_aControlList.end())
3278  return;
3279 
3280  auto itTest = it;
3281  ++itTest;
3282 
3283  if (!rBtn.IsNextControl() || (itTest != m_aControlList.end() && rBtn.IsNextControl()))
3284  {
3285  bool isNext = rBtn.IsNextControl();
3286 
3287  auto iterFocus = it;
3288  isNext ? ++iterFocus : --iterFocus;
3289 
3290  SwTOXWidget* pCtrlFocus = iterFocus->get();
3291  pCtrlFocus->GrabFocus();
3292  int nStartPos(0), nEndPos(0);
3293 
3294  if (!isNext)
3295  {
3296  const sal_Int32 nLen = static_cast<SwTOXEdit*>(pCtrlFocus)->GetText().getLength();
3297 
3298  nStartPos = nLen;
3299  nEndPos = nLen;
3300  }
3301 
3302  static_cast<SwTOXEdit*>(pCtrlFocus)->select_region(nStartPos, nEndPos);
3303 
3304  rBtn.Check(false);
3305 
3306  AdjustScrolling();
3307  }
3308 }
3309 
3310 IMPL_LINK(SwTokenWindow, TbxFocusBtnHdl, SwTOXWidget&, rControl, void)
3311 {
3312  SwTOXButton* pBtn = static_cast<SwTOXButton*>(&rControl);
3313  for (const auto& aControl : m_aControlList)
3314  {
3315  SwTOXWidget* pControl = aControl.get();
3316 
3317  if (pControl && WindowType::EDIT != pControl->GetType())
3318  static_cast<SwTOXButton*>(pControl)->Check(pBtn == pControl);
3319  }
3320 
3321  SetActiveControl(pBtn);
3322 }
3323 
3325 {
3326  if (m_pParent)
3327  {
3329  }
3330 }
3331 
3333 {
3334  //there are only one entry-text button and only one page-number button,
3335  //so we need not add index for these two buttons.
3336  if ( eType == TOKEN_ENTRY_TEXT || eType == TOKEN_PAGE_NUMS )
3337  {
3338  return 0;
3339  }
3340 
3341  sal_uInt32 nIndex = 0;
3342  for (const auto& elem : m_aControlList)
3343  {
3344  const SwTOXWidget* pControl = elem.get();
3345 
3346  const SwFormToken& rNewToken = WindowType::EDIT == pControl->GetType()
3347  ? const_cast<SwTOXEdit*>(static_cast<const SwTOXEdit*>(pControl))->GetFormToken()
3348  : static_cast<const SwTOXButton*>(pControl)->GetFormToken();
3349 
3350  if(eType == rNewToken.eTokenType)
3351  {
3352  ++nIndex;
3353  }
3354  }
3355 
3356  return nIndex;
3357 }
3358 
3360  : SfxTabPage(pPage, pController, "modules/swriter/ui/tocstylespage.ui", "TocStylesPage", &rAttrSet)
3361  , m_xLevelLB(m_xBuilder->weld_tree_view("levels"))
3362  , m_xAssignBT(m_xBuilder->weld_button("assign"))
3363  , m_xParaLayLB(m_xBuilder->weld_tree_view("styles"))
3364  , m_xStdBT(m_xBuilder->weld_button("default"))
3365  , m_xEditStyleBT(m_xBuilder->weld_button("edit"))
3366 {
3367  m_xParaLayLB->make_sorted();
3368  auto nHeight = m_xLevelLB->get_height_rows(16);
3369  m_xLevelLB->set_size_request(-1, nHeight);
3370  m_xParaLayLB->set_size_request(-1, nHeight);
3371 
3373 
3374  m_xEditStyleBT->connect_clicked(LINK(this, SwTOXStylesTabPage, EditStyleHdl));
3375  m_xAssignBT->connect_clicked(LINK(this, SwTOXStylesTabPage, AssignHdl));
3376  m_xStdBT->connect_clicked(LINK(this, SwTOXStylesTabPage, StdHdl));
3377  m_xParaLayLB->connect_changed(LINK(this, SwTOXStylesTabPage, EnableSelectHdl));
3378  m_xLevelLB->connect_changed(LINK(this, SwTOXStylesTabPage, EnableSelectHdl));
3379  m_xParaLayLB->connect_row_activated(LINK(this, SwTOXStylesTabPage, DoubleClickHdl));
3380 }
3381 
3383 {
3384 }
3385 
3387 {
3388  return true;
3389 }
3390 
3392 {
3393  ActivatePage(*rSet);
3394 }
3395 
3397 {
3398  m_pCurrentForm.reset(new SwForm(GetForm()));
3399 
3400  // not hyperlink for user directories
3401  const sal_uInt16 nSize = m_pCurrentForm->GetFormMax();
3402 
3403  // display form pattern without title
3404 
3405  m_xLevelLB->freeze();
3406  m_xLevelLB->clear();
3407  // display 1st TemplateEntry
3408  OUString aStr( SwResId( STR_TITLE ));
3409  if( !m_pCurrentForm->GetTemplate( 0 ).isEmpty() )
3410  {
3411  aStr += " " + OUStringChar(aDeliStart)
3412  + m_pCurrentForm->GetTemplate( 0 )
3413  + OUStringChar(aDeliEnd);
3414  }
3415  m_xLevelLB->append_text(aStr);
3416 
3417  for( sal_uInt16 i=1; i < nSize; ++i )
3418  {
3419  if( TOX_INDEX == m_pCurrentForm->GetTOXType() &&
3420  FORM_ALPHA_DELIMITER == i )
3421  {
3422  aStr = SwResId(STR_ALPHA);
3423  }
3424  else
3425  {
3426  aStr = SwResId(STR_LEVEL) + OUString::number(
3427  TOX_INDEX == m_pCurrentForm->GetTOXType() ? i - 1 : i );
3428  }
3429  if( !m_pCurrentForm->GetTemplate( i ).isEmpty() )
3430  {
3431  aStr += " " + OUStringChar(aDeliStart)
3432  + m_pCurrentForm->GetTemplate( i )
3433  + OUStringChar(aDeliEnd);
3434  }
3435  m_xLevelLB->append_text(aStr);
3436  }
3437  m_xLevelLB->thaw();
3438 
3439  // initialise templates
3440  SwWrtShell& rSh = static_cast<SwMultiTOXTabDialog*>(GetDialogController())->GetWrtShell();
3441  const sal_uInt16 nSz = rSh.GetTextFormatCollCount();
3442 
3443  m_xParaLayLB->freeze();
3444  m_xParaLayLB->clear();
3445  for( sal_uInt16 i = 0; i < nSz; ++i )
3446  {
3447  const SwTextFormatColl *pColl = &rSh.GetTextFormatColl( i );
3448  if( !pColl->IsDefault() )
3449  m_xParaLayLB->append_text( pColl->GetName() );
3450  }
3451 
3452  // query pool collections and set them for the directory
3453  for( sal_uInt16 i = 0; i < m_pCurrentForm->GetFormMax(); ++i )
3454  {
3455  aStr = m_pCurrentForm->GetTemplate( i );
3456  if (!aStr.isEmpty() && m_xParaLayLB->find_text(aStr) == -1)
3457  m_xParaLayLB->append_text(aStr);
3458  }
3459  m_xParaLayLB->thaw();
3460 
3461  EnableSelectHdl(*m_xParaLayLB);
3462 }
3463 
3465 {
3466  GetForm() = *m_pCurrentForm;
3467  return DeactivateRC::LeavePage;
3468 }
3469 
3470 std::unique_ptr<SfxTabPage> SwTOXStylesTabPage::Create(weld::Container* pPage, weld::DialogController* pController,
3471  const SfxItemSet* rAttrSet)
3472 {
3473  return std::make_unique<SwTOXStylesTabPage>(pPage, pController, *rAttrSet);
3474 }
3475 
3477 {
3478  if (m_xParaLayLB->get_selected_index() != -1)
3479  {
3480  SfxStringItem aStyle(SID_STYLE_EDIT, m_xParaLayLB->get_selected_text());
3481  SfxUInt16Item aFamily(SID_STYLE_FAMILY, sal_uInt16(SfxStyleFamily::Para));
3482  SwWrtShell& rSh = static_cast<SwMultiTOXTabDialog*>(GetDialogController())->GetWrtShell();
3483  rSh.GetView().GetViewFrame()->GetDispatcher()->ExecuteList(SID_STYLE_EDIT,
3484  SfxCallMode::SYNCHRON,
3485  { &aStyle, &aFamily });
3486  }
3487 }
3488 
3489 // allocate templates
3491 {
3492  auto nLevPos = m_xLevelLB->get_selected_index();
3493  auto nTemplPos = m_xParaLayLB->get_selected_index();
3494  if (nLevPos != -1 && nTemplPos != -1)
3495  {
3496  const OUString aStr(m_xLevelLB->get_text(nLevPos).getToken(0, aDeliStart)
3497  + OUStringChar(aDeliStart)
3498  + m_xParaLayLB->get_selected_text()
3499  + OUStringChar(aDeliEnd));
3500 
3501  m_pCurrentForm->SetTemplate(nLevPos, m_xParaLayLB->get_selected_text());
3502 
3503  m_xLevelLB->remove(nLevPos);
3504  m_xLevelLB->insert_text(nLevPos, aStr);
3505  m_xLevelLB->select_text(aStr);
3506  Modify();
3507  }
3508 }
3509 
3511 {
3512  const auto nPos = m_xLevelLB->get_selected_index();
3513  if (nPos != -1)
3514  {
3515  const OUString aStr(m_xLevelLB->get_text(nPos).getToken(0, aDeliStart));
3516  m_xLevelLB->remove(nPos);
3517  m_xLevelLB->insert_text(nPos, aStr);
3518  m_xLevelLB->select_text(aStr);
3519  m_pCurrentForm->SetTemplate(nPos, OUString());
3520  Modify();
3521  }
3522 }
3523 
3525 {
3526  const OUString aTmpName(m_xParaLayLB->get_selected_text());
3527  SwWrtShell& rSh = static_cast<SwMultiTOXTabDialog*>(GetDialogController())->GetWrtShell();
3528 
3529  if(m_xParaLayLB->get_selected_index() != -1 &&
3530  (m_xLevelLB->get_selected_index() == 0 || SwMultiTOXTabDialog::IsNoNum(rSh, aTmpName)))
3531  AssignHdl(*m_xAssignBT);
3532 
3533  return true;
3534 }
3535 
3536 // enable only when selected
3538 {
3539  m_xStdBT->set_sensitive(m_xLevelLB->get_selected_index() != -1);
3540 
3541  SwWrtShell& rSh = static_cast<SwMultiTOXTabDialog*>(GetDialogController())->GetWrtShell();
3542  const OUString aTmpName(m_xParaLayLB->get_selected_text());
3543  m_xAssignBT->set_sensitive(m_xParaLayLB->get_selected_index() != -1 &&
3544  m_xLevelLB->get_selected_index() != -1 &&
3545  (m_xLevelLB->get_selected_index() == 0 || SwMultiTOXTabDialog::IsNoNum(rSh, aTmpName)));
3546  m_xEditStyleBT->set_sensitive(m_xParaLayLB->get_selected_index() != -1);
3547 }
3548 
3550 {
3551  SwMultiTOXTabDialog* pTOXDlg = static_cast<SwMultiTOXTabDialog*>(GetDialogController());
3552  if (pTOXDlg)
3553  {
3554  GetForm() = *m_pCurrentForm;
3556  }
3557 }
3558 
3559 #define ITEM_SEARCH 1
3560 #define ITEM_ALTERNATIVE 2
3561 #define ITEM_PRIM_KEY 3
3562 #define ITEM_SEC_KEY 4
3563 #define ITEM_COMMENT 5
3564 #define ITEM_CASE 6
3565 #define ITEM_WORDONLY 7
3566 
3567 SwEntryBrowseBox::SwEntryBrowseBox(const css::uno::Reference<css::awt::XWindow> &rParent)
3573  BrowserMode::HLINES |
3574  BrowserMode::VLINES |
3577  , m_aCellEdit(VclPtr<Edit>::Create(&GetDataWindow(), 0))
3578  , m_aCellCheckBox(VclPtr< ::svt::CheckBoxControl>::Create(&GetDataWindow()))
3579  , m_nCurrentRow(0)
3580  , m_bModified(false)
3581 {
3582  m_sSearch = SwResId(STR_AUTOMARK_SEARCHTERM);
3583  m_sAlternative = SwResId(STR_AUTOMARK_ALTERNATIVE);
3584  m_sPrimKey = SwResId(STR_AUTOMARK_KEY1);
3585  m_sSecKey = SwResId(STR_AUTOMARK_KEY2);
3586  m_sComment = SwResId(STR_AUTOMARK_COMMENT);
3587  m_sCaseSensitive = SwResId(STR_AUTOMARK_CASESENSITIVE);
3588  m_sWordOnly = SwResId(STR_AUTOMARK_WORDONLY);
3589  m_sYes = SwResId(STR_AUTOMARK_YES);
3590  m_sNo = SwResId(STR_AUTOMARK_NO);
3591 
3592  m_aCellCheckBox->GetBox().EnableTriState(false);
3593  m_xController = new ::svt::EditCellController(m_aCellEdit.get());
3594  m_xCheckController = new ::svt::CheckBoxCellController(m_aCellCheckBox.get());
3595 
3596  // HACK: BrowseBox doesn't invalidate its children, how it should be.
3597  // That's why WB_CLIPCHILDREN is reset in order to enforce the
3598  // children' invalidation
3599  WinBits aStyle = GetStyle();
3600  if( aStyle & WB_CLIPCHILDREN )
3601  {
3602  aStyle &= ~WB_CLIPCHILDREN;
3603  SetStyle( aStyle );
3604  }
3605 
3606  const OUString* aTitles[7] =
3607  {
3608  &m_sSearch,
3609  &m_sAlternative,
3610  &m_sPrimKey,
3611  &m_sSecKey,
3612  &m_sComment,
3613  &m_sCaseSensitive,
3614  &m_sWordOnly
3615  };
3616 
3617  long nWidth = GetSizePixel().Width();
3618  nWidth /=7;
3619  --nWidth;
3620  for(sal_uInt16 i = 1; i < 8; i++)
3621  InsertDataColumn( i, *aTitles[i - 1], nWidth );
3622 }
3623 
3624 SwEntryBrowseBox::~SwEntryBrowseBox()
3625 {
3626  disposeOnce();
3627 }
3628 
3630 {
3631  m_aCellEdit.disposeAndClear();
3632  m_aCellCheckBox.disposeAndClear();
3634 }
3635 
3636 void SwEntryBrowseBox::Resize()
3637 {
3639 
3640  long nWidth = GetSizePixel().Width();
3641  std::vector<long> aWidths = GetOptimalColWidths();
3642  long nNaturalWidth(std::accumulate(aWidths.begin(), aWidths.end(), 0));
3643  long nExcess = ((nWidth - nNaturalWidth) / aWidths.size()) - 1;
3644 
3645  for (size_t i = 0; i < aWidths.size(); ++i)
3646  SetColumnWidth(i+1, aWidths[i] + nExcess);
3647 }
3648 
3649 std::vector<long> SwEntryBrowseBox::GetOptimalColWidths() const
3650 {
3651  std::vector<long> aWidths;
3652 
3653  long nStandardColMinWidth = approximate_digit_width() * 15;
3654  long nYesNoWidth = approximate_digit_width() * 5;
3655  nYesNoWidth = std::max(nYesNoWidth, GetTextWidth(m_sYes));
3656  nYesNoWidth = std::max(nYesNoWidth, GetTextWidth(m_sNo));
3657  for (sal_uInt16 i = 1; i < 6; i++)
3658  {
3659  long nColWidth = std::max(nStandardColMinWidth,
3660  GetTextWidth(GetColumnTitle(i)));
3661  nColWidth += 12;
3662  aWidths.push_back(nColWidth);
3663  }
3664 
3665  for (sal_uInt16 i = 6; i < 8; i++)
3666  {
3667  long nColWidth = std::max(nYesNoWidth,
3668  GetTextWidth(GetColumnTitle(i)));
3669  nColWidth += 12;
3670  aWidths.push_back(nColWidth);
3671  }
3672 
3673  return aWidths;
3674 }
3675 
3676 Size SwEntryBrowseBox::GetOptimalSize() const
3677 {
3678  Size aSize = LogicToPixel(Size(276 , 175), MapMode(MapUnit::MapAppFont));
3679 
3680  std::vector<long> aWidths = GetOptimalColWidths();
3681 
3682  long nWidth(std::accumulate(aWidths.begin(), aWidths.end(), 0));
3683 
3684  aSize.setWidth( std::max(aSize.Width(), nWidth) );
3685 
3686  return aSize;
3687 }
3688 
3689 bool SwEntryBrowseBox::SeekRow( long nRow )
3690 {
3691  m_nCurrentRow = nRow;
3692  return true;
3693 }
3694 
3695 OUString SwEntryBrowseBox::GetCellText(long nRow, sal_uInt16 nColumn) const
3696 {
3697  OUString pRet;
3698  if (static_cast<size_t>(nRow) < m_Entries.size())
3699  {
3700  const AutoMarkEntry* pEntry = m_Entries[ nRow ].get();
3701  switch(nColumn)
3702  {
3703  case ITEM_SEARCH : pRet = pEntry->sSearch; break;
3704  case ITEM_ALTERNATIVE : pRet = pEntry->sAlternative; break;
3705  case ITEM_PRIM_KEY : pRet = pEntry->sPrimKey; break;
3706  case ITEM_SEC_KEY : pRet = pEntry->sSecKey; break;
3707  case ITEM_COMMENT : pRet = pEntry->sComment; break;
3708  case ITEM_CASE : pRet = pEntry->bCase ? m_sYes : m_sNo; break;
3709  case ITEM_WORDONLY : pRet = pEntry->bWord ? m_sYes : m_sNo; break;
3710  }
3711  }
3712  return pRet;
3713 }
3714 
3715 void SwEntryBrowseBox::PaintCell(OutputDevice& rDev,
3716  const tools::Rectangle& rRect, sal_uInt16 nColumnId) const
3717 {
3718  const DrawTextFlags nStyle = DrawTextFlags::Clip | DrawTextFlags::Center;
3719  rDev.DrawText( rRect, GetCellText( m_nCurrentRow, nColumnId ), nStyle );
3720 }
3721 
3722 ::svt::CellController* SwEntryBrowseBox::GetController(long /*nRow*/, sal_uInt16 nCol)
3723 {
3724  return nCol < ITEM_CASE ? m_xController.get() : m_xCheckController.get();
3725 }
3726 
3727 bool SwEntryBrowseBox::SaveModified()
3728 {
3729  m_bModified = true;
3730  const size_t nRow = GetCurRow();
3731  const sal_uInt16 nCol = GetCurColumnId();
3732 
3733  OUString sNew;
3734  bool bVal = false;
3735  ::svt::CellController* pController = nullptr;
3736  if(nCol < ITEM_CASE)
3737  {
3738  pController = m_xController.get();
3739  sNew = static_cast< ::svt::EditCellController*>(pController)->GetEditImplementation()->GetText( LINEEND_LF );
3740  }
3741  else
3742  {
3743  pController = m_xCheckController.get();
3744  bVal = static_cast< ::svt::CheckBoxCellController*>(pController)->GetCheckBox().IsChecked();
3745  }
3746  const bool bAddEntry = nRow >= m_Entries.size();
3747  std::unique_ptr<AutoMarkEntry> xNewEntry(bAddEntry ? new AutoMarkEntry : nullptr);
3748  AutoMarkEntry* pEntry = bAddEntry ? xNewEntry.get() : m_Entries[nRow].get();
3749  switch(nCol)
3750  {
3751  case ITEM_SEARCH : pEntry->sSearch = sNew; break;
3752  case ITEM_ALTERNATIVE : pEntry->sAlternative = sNew; break;
3753  case ITEM_PRIM_KEY : pEntry->sPrimKey = sNew; break;
3754  case ITEM_SEC_KEY : pEntry->sSecKey = sNew; break;
3755  case ITEM_COMMENT : pEntry->sComment = sNew; break;
3756  case ITEM_CASE : pEntry->bCase = bVal; break;
3757  case ITEM_WORDONLY : pEntry->bWord = bVal; break;
3758  }
3759  if (bAddEntry)
3760  {
3761  m_Entries.push_back(std::move(xNewEntry));
3762  RowInserted(nRow, 1, true, true);
3763  if(nCol < ITEM_WORDONLY)
3764  {
3765  pController->ClearModified();
3766  GoToRow( nRow );
3767  }
3768  }
3769  return true;
3770 }
3771 
3772 void SwEntryBrowseBox::InitController(
3773  ::svt::CellControllerRef& rController, long nRow, sal_uInt16 nCol)
3774 {
3775  const OUString rText = GetCellText( nRow, nCol );
3776  if(nCol < ITEM_CASE)
3777  {
3778  rController = m_xController;
3779  ::svt::CellController* pController = m_xController.get();
3780  static_cast< ::svt::EditCellController*>(pController)->GetEditImplementation()->SetText( rText );
3781  }
3782  else
3783  {
3784  rController = m_xCheckController;
3785  ::svt::CellController* pController = m_xCheckController.get();
3786  static_cast< ::svt::CheckBoxCellController*>(pController)->GetCheckBox().Check(
3787  rText == m_sYes );
3788  }
3789 }
3790 
3791 void SwEntryBrowseBox::ReadEntries(SvStream& rInStr)
3792 {
3793  AutoMarkEntry* pToInsert = nullptr;
3794  rtl_TextEncoding eTEnc = osl_getThreadTextEncoding();
3795  while (rInStr.good())
3796  {
3797  OUString sLine;
3798  rInStr.ReadByteStringLine( sLine, eTEnc );
3799 
3800  // # -> comment
3801  // ; -> delimiter between entries ->
3802  // Format: TextToSearchFor;AlternativeString;PrimaryKey;SecondaryKey
3803  // Leading and trailing blanks are ignored
3804  if( !sLine.isEmpty() )
3805  {
3806  //comments are contained in separate lines but are put into the struct of the following data
3807  //line (if available)
3808  if( '#' != sLine[0] )
3809  {
3810  if( !pToInsert )
3811  pToInsert = new AutoMarkEntry;
3812 
3813  sal_Int32 nSttPos = 0;
3814  pToInsert->sSearch = sLine.getToken(0, ';', nSttPos );
3815  pToInsert->sAlternative = sLine.getToken(0, ';', nSttPos );
3816  pToInsert->sPrimKey = sLine.getToken(0, ';', nSttPos );
3817  pToInsert->sSecKey = sLine.getToken(0, ';', nSttPos );
3818 
3819  OUString sStr = sLine.getToken(0, ';', nSttPos );
3820  pToInsert->bCase = !sStr.isEmpty() && sStr != "0";
3821 
3822  sStr = sLine.getToken(0, ';', nSttPos );
3823  pToInsert->bWord = !sStr.isEmpty() && sStr != "0";
3824 
3825  m_Entries.push_back(std::unique_ptr<AutoMarkEntry>(pToInsert));
3826  pToInsert = nullptr;
3827  }
3828  else
3829  {
3830  if(pToInsert)
3831  m_Entries.push_back(std::unique_ptr<AutoMarkEntry>(pToInsert));
3832  pToInsert = new AutoMarkEntry;
3833  pToInsert->sComment = sLine.copy(1);
3834  }
3835  }
3836  }
3837  if( pToInsert )
3838  m_Entries.push_back(std::unique_ptr<AutoMarkEntry>(pToInsert));
3839  RowInserted(0, m_Entries.size() + 1);
3840 }
3841 
3842 void SwEntryBrowseBox::WriteEntries(SvStream& rOutStr)
3843 {
3844  //check if the current controller is modified
3845  const sal_uInt16 nCol = GetCurColumnId();
3846  ::svt::CellController* pController;
3847  if(nCol < ITEM_CASE)
3848  pController = m_xController.get();
3849  else
3850  pController = m_xCheckController.get();
3851  if(pController ->IsModified())
3852  GoToColumnId(nCol + (nCol < ITEM_CASE ? 1 : -1 ));
3853 
3854  rtl_TextEncoding eTEnc = osl_getThreadTextEncoding();
3855  for(const std::unique_ptr<AutoMarkEntry> & rpEntry : m_Entries)
3856  {
3857  AutoMarkEntry* pEntry = rpEntry.get();
3858  if(!pEntry->sComment.isEmpty())
3859  {
3860  rOutStr.WriteByteStringLine( "#" + pEntry->sComment, eTEnc );
3861  }
3862 
3863  OUString sWrite( pEntry->sSearch + ";" +
3864  pEntry->sAlternative + ";" +
3865  pEntry->sPrimKey + ";" +
3866  pEntry->sSecKey + ";" +
3867  (pEntry->bCase ? OUStringLiteral("1") : OUStringLiteral("0")) + ";" +
3868  (pEntry->bWord ? OUStringLiteral("1") : OUStringLiteral("0")) );
3869 
3870  if( sWrite.getLength() > 5 )
3871  rOutStr.WriteByteStringLine( sWrite, eTEnc );
3872  }
3873 }
3874 
3875 bool SwEntryBrowseBox::IsModified()const
3876 {
3877  if(m_bModified)
3878  return true;
3879 
3880  //check if the current controller is modified
3881  const sal_uInt16 nCol = GetCurColumnId();
3882  ::svt::CellController* pController;
3883  if(nCol < ITEM_CASE)
3884  pController = m_xController.get();
3885  else
3886  pController = m_xCheckController.get();
3887  return pController->IsModified();
3888 }
3889 
3890 SwAutoMarkDlg_Impl::SwAutoMarkDlg_Impl(weld::Window* pParent, const OUString& rAutoMarkURL,
3891  bool bCreate)
3892  : GenericDialogController(pParent, "modules/swriter/ui/createautomarkdialog.ui", "CreateAutomarkDialog")
3893  , sAutoMarkURL(rAutoMarkURL)
3894  , bCreateMode(bCreate)
3895  , m_xOKPB(m_xBuilder->weld_button("ok"))
3896  , m_xTable(m_xBuilder->weld_container("area"))
3897  , m_xTableCtrlParent(m_xTable->CreateChildFrame())
3898  , m_xEntriesBB(VclPtr<SwEntryBrowseBox>::Create(m_xTableCtrlParent))
3899 {
3900  m_xEntriesBB->Show();
3901  m_xOKPB->connect_clicked(LINK(this, SwAutoMarkDlg_Impl, OkHdl));
3902 
3903  m_xDialog->set_title(m_xDialog->get_title() + ": " + sAutoMarkURL);
3904  bool bError = false;
3905  if( bCreateMode )
3906  m_xEntriesBB->RowInserted(0);
3907  else
3908  {
3909  SfxMedium aMed( sAutoMarkURL, StreamMode::STD_READ );
3910  if( aMed.GetInStream() && !aMed.GetInStream()->GetError() )
3911  m_xEntriesBB->ReadEntries( *aMed.GetInStream() );
3912  else
3913  bError = true;
3914  }
3915 
3916  Size aPrefSize = m_xEntriesBB->GetOptimalSize();
3917  m_xTable->set_size_request(aPrefSize.Width(), aPrefSize.Height());
3918 
3919  if (bError)
3920  m_xDialog->response(RET_CANCEL);
3921 }
3922 
3923 SwAutoMarkDlg_Impl::~SwAutoMarkDlg_Impl()
3924 {
3925  m_xEntriesBB.disposeAndClear();
3926  m_xTableCtrlParent->dispose();
3927  m_xTableCtrlParent.clear();
3928 }
3929 
3930 IMPL_LINK_NOARG(SwAutoMarkDlg_Impl, OkHdl, weld::Button&, void)
3931 {
3932  bool bError = false;
3933  if (m_xEntriesBB->IsModified() || bCreateMode)
3934  {
3935  SfxMedium aMed( sAutoMarkURL,
3936  bCreateMode ? StreamMode::WRITE
3937  : StreamMode::WRITE| StreamMode::TRUNC );
3938  SvStream* pStrm = aMed.GetOutStream();
3939  pStrm->SetStreamCharSet( RTL_TEXTENCODING_MS_1253 );
3940  if( !pStrm->GetError() )
3941  {
3942  m_xEntriesBB->WriteEntries( *pStrm );
3943  aMed.Commit();
3944  }
3945  else
3946  bError = true;
3947  }
3948  if (!bError)
3949  m_xDialog->response(RET_OK);
3950 }
3951 
3952 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
SwFieldType * GetFieldType(size_t nField, SwFieldIds nResId=SwFieldIds::Unknown) const
get field types with a ResId, if 0 get all
Definition: edfld.cxx:64
css::uno::Reference< css::linguistic2::XProofreadingIterator > get(css::uno::Reference< css::uno::XComponentContext > const &context)
SfxViewFrame * GetViewFrame() const
void SetEntryNumberFormat(sal_uInt16 nSet)
Definition: cnttab.cxx:1649
std::unique_ptr< weld::MenuButton > m_xAutoMarkPB
Definition: swuicnttab.hxx:175
TOXTypes GetTOXType() const
Definition: tox.hxx:648
Instances of SwFields and those derived from it occur 0 to n times.
Definition: fldbas.hxx:234
#define KEY_SUBTRACT
long Width() const
OUString m_aButtonHelpTexts[TOKEN_END]
Definition: swuicnttab.hxx:229
std::vector< SwFormToken > SwFormTokens
Vector of tokens.
Definition: tox.hxx:249
std::unique_ptr< weld::ComboBox > m_xAuthFieldsLB
Definition: swuicnttab.hxx:325
void DrawText(const Point &rStartPt, const OUString &rStr, sal_Int32 nIndex=0, sal_Int32 nLen=-1, MetricVector *pVector=nullptr, OUString *pDisplayText=nullptr, const SalLayoutGlyphs *pLayoutCache=nullptr)
std::unique_ptr< weld::ScrolledWindow > m_xScrollWin
Definition: swuicnttab.hxx:247
bool IsNextControl() const
Definition: cnttab.cxx:1492
TOXTypes
Definition: toxe.hxx:39
virtual void GrabFocus()=0
void SetTOUName(const OUString &rSet)
Definition: toxmgr.hxx:103
const SfxPoolItem * ExecuteList(sal_uInt16 nSlot, SfxCallMode nCall, std::initializer_list< SfxPoolItem const * > args, std::initializer_list< SfxPoolItem const * > internalargs=std::initializer_list< SfxPoolItem const * >())
virtual void Resize() override
FieldUnit
#define RES_FRM_SIZE
Definition: hintids.hxx:289
void OnModify(bool bAllLevels)
Definition: cnttab.cxx:1934
void MoveControls(long nOffset)
Definition: cnttab.cxx:3029
SwTOIOptions
Definition: tox.hxx:350
std::vector< TypeData > m_vTypeData
Definition: swuicnttab.hxx:65
sal_Int32 nIndex
SwTOXElement GetContentOptions() const
Definition: toxmgr.hxx:110
void SetLinkStart()
Definition: cnttab.cxx:1694
std::unique_ptr< weld::ComboBox > m_xNumberFormatLB
format for numbering (E#)
Definition: swuicnttab.hxx:333
Represents the style of a paragraph.
Definition: fmtcol.hxx:55
#define KEY_DELETE
void Check(bool bCheck=true)
Definition: cnttab.cxx:1619
std::unique_ptr< weld::RadioButton > m_xSecondSortUpRB
Definition: swuicnttab.hxx:355
std::unique_ptr< weld::TreeView > m_xParaLayLB
Definition: swuicnttab.hxx:407
SwFormToken aFormToken
Definition: cnttab.cxx:1407
SwTextFormatColl * GetTextCollFromPool(sal_uInt16 nId)
Definition: edfmt.cxx:123
SwTOXElement GetCreateType() const
Definition: tox.hxx:671
OUString m_sAdditionalAccnameString2
Definition: swuicnttab.hxx:236
void PreTokenButtonRemoved(const SwFormToken &rToken)
Definition: cnttab.cxx:2169
SwTOIOptions GetOptions() const
Definition: tox.hxx:710
std::unique_ptr< weld::Button > m_xRightScrollWin
Definition: swuicnttab.hxx:248
void SetMainEntryCharStyle(const OUString &rSet)
Definition: toxmgr.hxx:116
bool IsDefault() const
Definition: format.hxx:109
virtual void set_grid_left_attach(int nPos) override
Definition: cnttab.cxx:1609
std::unique_ptr< SvxLanguageBox > m_xLanguageLB
Definition: swuicnttab.hxx:187
#define TO_BIBLIOGRAPHY
Definition: cnttab.hxx:37
EditBrowseBoxFlags
virtual void ActivatePage(const SfxItemSet &) override
Definition: cnttab.cxx:1172
virtual void PageCreated(const SfxAllItemSet &aSet)
static SfxAbstractDialogFactory * Create()
sal_uInt16 m_nLevel
Definition: swuicnttab.hxx:226
void SetPattern(sal_uInt16 nLevel, const SwFormTokens &rName)
Definition: tox.cxx:918
std::unique_ptr< weld::Button > m_xAddStylesPB
Definition: swuicnttab.hxx:145
DECL_LINK(KeyInputHdl, const KeyEvent &, bool)
std::unique_ptr< weld::Button > m_xEntryPB
Definition: swuicnttab.hxx:320
std::unique_ptr< weld::ComboBox > m_xTypeLB
Definition: swuicnttab.hxx:132
std::unique_ptr< weld::ComboBox > m_xFirstKeyLB
Definition: swuicnttab.hxx:351
SwTokenWindow * m_pParent
Definition: cnttab.cxx:1411
bool IsProtected() const
Definition: tox.hxx:502
SW_DLLPUBLIC void FillCharStyleListBox(weld::ComboBox &rToFill, SwDocShell *pDocSh, bool bSorted=false, bool bWithDefault=false)
Definition: uitool.cxx:723
sal_uInt16 nOutlineLevel
Definition: tox.hxx:215
virtual bool FillItemSet(SfxItemSet *) override
Definition: cnttab.cxx:3386
const SfxItemSet * GetOutputItemSet() const
std::unique_ptr< weld::Button > m_xHyperLinkPB
Definition: swuicnttab.hxx:324
long Height() const
std::unique_ptr< weld::Button > m_xStdBT
Definition: swuicnttab.hxx:408
SwTOOElements
Definition: tox.hxx:373
Definition: tox.hxx:276
void SetSequenceName(const OUString &rSet)
Definition: toxmgr.hxx:125
const OUString & GetSequenceName() const
Definition: toxmgr.hxx:124
sal_uInt16 GetTextFormatCollCount() const
Definition: edfcol.cxx:685
OUString aStyleArr[MAXLEVEL]
Definition: swuicnttab.hxx:120
sal_uInt16 char char * pDesc
long GetWidth() const
void Create(SwFormatVertOrient &rItem, SvStream &rStrm, sal_uInt16 nVersionAbusedAsSize)
Definition: legacyitem.cxx:32
SfxDispatcher * GetDispatcher()
SwTOXDescription & GetTOXDescription(CurTOXType eTOXTypes)
Definition: cnttab.cxx:364
DECL_LINK(ModifyHdl, weld::Entry &, void)
void SelectType(TOXTypes eSet)
Definition: cnttab.cxx:871
std::unique_ptr< weld::SpinButton > m_xEntryOutlineLevelNF
level to evaluate outline level to, for i53420
Definition: swuicnttab.hxx:335
std::unique_ptr< weld::Builder > m_xBuilder
Definition: cnttab.cxx:1406
std::unique_ptr< weld::Button > m_xEditStyleBT
Definition: swuicnttab.hxx:409
Main entry in indices.
Definition: poolfmt.hxx:127
static OUString GetFormLinkStt()
Definition: tox.cxx:500
TOXTypes GetTOXType() const
Definition: toxmgr.hxx:90
void SetAuthSequence(bool bSet)
Definition: toxmgr.hxx:146
void SetReadonly(bool bSet)
Definition: toxmgr.hxx:133
std::unique_ptr< weld::ComboBox > m_xCaptionSequenceLB
Definition: swuicnttab.hxx:159
virtual void ActivatePage(const SfxItemSet &) override
Definition: cnttab.cxx:1978
SwForm * GetForm(CurTOXType eType)
Definition: cnttab.cxx:356
#define TOX_STYLE_DELIMITER
Definition: tox.hxx:386
std::unique_ptr< weld::RadioButton > m_xSortDocPosRB
Definition: swuicnttab.hxx:348
#define ITEM_COMMENT
Definition: cnttab.cxx:3563
only chapter number without post-/prefix
Definition: chpfld.hxx:35
void CreateOrUpdateExample(TOXTypes nTOXIndex, sal_uInt16 nPage=0, sal_uInt16 nCurLevel=USHRT_MAX)
Definition: cntex.cxx:137
OUString const m_sCharStyle
Definition: swuicnttab.hxx:230
void SetStyleNames(const OUString &rSet, sal_uInt16 nLvl)
Definition: toxmgr.hxx:94
bool Commit()
sal_Int16 nId
Link< SwTOXEdit &, void > aModifiedLink
Definition: cnttab.cxx:1408
std::unique_ptr< weld::TreeView > m_xLevelLB
Definition: swuicnttab.hxx:405
std::unique_ptr< weld::CheckButton > m_xRelToStyleCB
Definition: swuicnttab.hxx:346
static bool IsNoNum(SwWrtShell &rSh, const OUString &rName)
Definition: cnttab.cxx:474
virtual void ActivatePage(const SfxItemSet &) override
Definition: cnttab.cxx:3396
sal_uInt16 GetCode() const
const OUString & GetTemplatePath() const
long SwTwips
Definition: swtypes.hxx:49
SwForm * m_pCurrentForm
Definition: swuicnttab.hxx:310
std::unique_ptr< weld::RadioButton > m_xThirdSortDownRB
Definition: swuicnttab.hxx:359
virtual void dispose() override
void SetFocus2theAllBtn()
Definition: cnttab.cxx:2176
SfxItemSet * GetInputSetImpl()
OUString const & GetTOIAutoMarkURL() const
AutoMark file.
Definition: edtox.cxx:254
sal_uInt16 GetFormMax() const
Definition: tox.hxx:653
std::unique_ptr< weld::CheckButton > m_xFromFramesCB
Definition: swuicnttab.hxx:148
static OUString GetFormTab()
Definition: tox.cxx:498
virtual void get_extents_relative_to(weld::Widget &rRelative, int &x, int &y, int &width, int &height)=0
void SetLevel(sal_uInt8 nSet)
Definition: toxmgr.hxx:118
void SetWrtShell(SwWrtShell &rSh)
Definition: cnttab.cxx:2529
std::unique_ptr< weld::RadioButton > m_xFirstSortUpRB
Definition: swuicnttab.hxx:352
sal_uInt16 nPoolId
Definition: tox.hxx:212
std::unique_ptr< weld::CheckButton > m_xFromTablesCB
Definition: swuicnttab.hxx:147
float x
void SetModifyHdl(const Link< SwTOXEdit &, void > &rLink)
Definition: cnttab.cxx:1484
#define KEY_LEFT
TRISTATE_TRUE
void SetIndexOptions(SwTOIOptions nSet)
Definition: toxmgr.hxx:112
static OUString const & GetAuthTypeName(ToxAuthorityType eType)
Definition: initui.cxx:277
#define KEY_ADD
virtual void Reset(const SfxItemSet *) override
Definition: cnttab.cxx:3391
IMPL_LINK(SwAddStylesDlg_Impl, TreeSizeAllocHdl, const Size &, rSize, void)
Definition: cnttab.cxx:602
std::unique_ptr< weld::ToggleButton > m_xButton
Definition: cnttab.cxx:1570
chapter number without post-/prefix and title
Definition: chpfld.hxx:36
std::unique_ptr< weld::Widget > m_xSortKeyFrame
Definition: swuicnttab.hxx:350
sal_Unicode cTabFillChar
Definition: tox.hxx:217
std::unique_ptr< weld::Button > m_xAuthInsertPB
Definition: swuicnttab.hxx:326
sal_uInt16 GetTOXTypeCount(TOXTypes eTyp) const
Manage types of content tables.
Definition: edws.cxx:189
SwTOXWidget * m_pActiveCtrl
Definition: swuicnttab.hxx:232
virtual bool IsModified() const =0
std::unique_ptr< weld::Entry > m_xTitleED
Definition: swuicnttab.hxx:130
virtual WindowType GetType() const override
Definition: cnttab.cxx:1429
void SetRelTabPos(bool b)
Definition: tox.hxx:308
Used by the UI to modify the document model.
Definition: wrtsh.hxx:90
virtual short Ok()
SwTextFormatColl & GetTextFormatColl(sal_uInt16 nTextFormatColl) const
Definition: edfcol.cxx:690
sal_Int64 WinBits
sal_uInt16 sal_Unicode
std::unique_ptr< weld::RadioButton > m_xSecondSortDownRB
Definition: swuicnttab.hxx:356
CurTOXType aLastTOXType
Definition: swuicnttab.hxx:312
Reference< XNameAccess > m_xContainer
SwCaptionDisplay GetCaptionDisplay() const
Definition: toxmgr.hxx:127
bool IsAssignedToListLevelOfOutlineStyle() const
Definition: fmtcol.hxx:109
OUString m_sAdditionalAccnameString1
Definition: swuicnttab.hxx:235
const SwTOXSortKey * GetSortKey(sal_uInt16 nIdx) const
Definition: authfld.cxx:442
std::unique_ptr< weld::RadioButton > m_xSortContentRB
Definition: swuicnttab.hxx:349
const SwTOXType * GetTOXType() const
Definition: tox.hxx:668
OUString m_sAccessibleName
Definition: swuicnttab.hxx:234
std::unique_ptr< weld::CheckButton > m_xFromHeadingsCB
Definition: swuicnttab.hxx:142
const SwView & GetView() const
Definition: wrtsh.hxx:428
sal_Unicode GetPrefix() const
Definition: authfld.hxx:114
ErrCode GetError() const
virtual WindowType GetType() const override
Definition: cnttab.cxx:1584
virtual CreateTabPage GetTabPageCreatorFunc(sal_uInt16 nId)=0
virtual ~SwTOXSelectTabPage() override
Definition: cnttab.cxx:818
std::unique_ptr< weld::Button > m_xAuthRemovePB
Definition: swuicnttab.hxx:327
void LanguageHdl(const weld::ComboBox *)
Definition: cnttab.cxx:1323
void SetSortByDocument(bool bSet)
Definition: toxmgr.hxx:149
SwTOIOptions GetIndexOptions() const
Definition: toxmgr.hxx:113
virtual void set_grid_left_attach(int nPos)=0
std::unique_ptr< weld::ComboBox > m_xMainEntryStyleLB
Definition: swuicnttab.hxx:343
std::unique_ptr< weld::ComboBox > m_xFillCharCB
Definition: swuicnttab.hxx:337
bool ReadByteStringLine(OUString &rStr, rtl_TextEncoding eSrcCharSet, sal_Int32 nMaxBytesToRead=0xFFFE)
std::unique_ptr< weld::ComboBox > m_xAreaLB
Definition: swuicnttab.hxx:136
OUString sText
Definition: tox.hxx:208
const OUString & GetName() const
Definition: format.hxx:111
void SetExchangeSupport()
SwTOXEdit(SwTokenWindow *pTokenWin, const SwFormToken &rToken)
Definition: cnttab.cxx:1416
bool IsCreateFromObjectNames() const
Definition: toxmgr.hxx:122
virtual bool FillItemSet(SfxItemSet *) override
Definition: cnttab.cxx:1949
int nCount
virtual void Hide() override
Definition: cnttab.cxx:1594
bool IsLevelFromChapter() const
Definition: toxmgr.hxx:139
const sal_uInt8 MAXLEVEL
Definition: swtypes.hxx:95
#define TO_USER
Definition: cnttab.hxx:34
static SW_DLLPUBLIC sal_uInt16 GetPoolIdFromUIName(const OUString &rName, SwGetPoolIdFromName)
void UpdateDescriptor()
Definition: cnttab.cxx:2083
SvStream * GetOutStream()
virtual void GrabFocus() override
Definition: cnttab.cxx:1434
static OUString GetFormEntry()
Definition: tox.cxx:497
std::unique_ptr< weld::Button > m_xLeftScrollWin
Definition: swuicnttab.hxx:245
void SetAuthBrackets(const OUString &rSet)
Definition: toxmgr.hxx:143
virtual short Ok() override
Definition: cnttab.cxx:330
OUString sAddStyleContent
Definition: swuicnttab.hxx:124
void SetTitle(const OUString &rSet)
Definition: toxmgr.hxx:100
const OUString & GetSequenceName() const
Definition: tox.hxx:505
std::unique_ptr< weld::Builder > m_xBuilder
Definition: cnttab.cxx:1565
#define ITEM_SEARCH
Definition: cnttab.cxx:3559
std::vector< std::unique_ptr< SwTOXWidget > > m_aControlList
Definition: swuicnttab.hxx:249
virtual void Hide() override
Definition: cnttab.cxx:1439
SwTOOElements GetOLEOptions() const
Definition: tox.hxx:478
#define ITEM_ALTERNATIVE
Definition: cnttab.cxx:3560
const char * sName
std::unique_ptr< weld::RadioButton > m_xFirstSortDownRB
Definition: swuicnttab.hxx:353
std::unique_ptr< weld::CheckButton > m_xStylesCB
Definition: swuicnttab.hxx:143
virtual void GrabFocus() override
Definition: cnttab.cxx:1589
OUString sAuthTypeStr
Definition: swuicnttab.hxx:307
OUString sAddStyleUser
Definition: swuicnttab.hxx:123
std::unique_ptr< weld::CheckButton > m_xAddStylesCB
Definition: swuicnttab.hxx:144
virtual WindowType GetType() const =0
bool IsAuthSequence() const
Definition: toxmgr.hxx:145
std::unique_ptr< weld::CheckButton > m_xCommaSeparatedCB
Definition: swuicnttab.hxx:345
void RemoveControl(const SwTOXButton *pDel, bool bInternalCall=false)
Definition: cnttab.cxx:2975
float y
Link< SwTOXWidget &, void > aGetFocusLink
Definition: cnttab.cxx:1393
bool IsFromChapter() const
Definition: toxmgr.hxx:131
static OUString GetFormEntryNum()
Definition: tox.cxx:502
#define SAL_N_ELEMENTS(arr)
OUString m_aButtonTexts[TOKEN_END]
Definition: swuicnttab.hxx:228
void SetFromChapter(bool bSet)
Definition: toxmgr.hxx:130
sal_Int32 m_nLevel
std::unique_ptr< weld::RadioButton > m_xFromCaptionsRB
Definition: swuicnttab.hxx:154
void SetText(const OUString &rText)
Definition: cnttab.cxx:1680
std::unique_ptr< weld::CheckButton > m_xUseFFCB
Definition: swuicnttab.hxx:169
weld::Window * GetFrameWeld(const SfxFrame *pFrame)
Definition: dialoghelp.cxx:20
OUString GetString() const
Definition: tox.cxx:644
SwTOXWidget * InsertItem(const OUString &rText, const SwFormToken &aToken)
Definition: cnttab.cxx:2710
void SetPrevNextLink(const Link< SwTOXEdit &, void > &rLink)
Definition: cnttab.cxx:1493
std::unique_ptr< weld::ComboBox > m_xThirdKeyLB
Definition: swuicnttab.hxx:357
::svt::EditBrowseBox SwEntryBrowseBox_Base
Definition: cnttab.cxx:142
const SwFormToken & GetFormToken()
Definition: cnttab.cxx:1495
OUString GetPattern() const
Definition: cnttab.cxx:3156
const OUString & GetUserConfigPath() const
#define SW_MOD()
Definition: swmodule.hxx:256
Link< SwFormToken &, void > m_aButtonSelectedHdl
Definition: swuicnttab.hxx:231
sal_uInt16 const m_nInitialTOXType
Definition: swuicnttab.hxx:72
sal_uInt8 GetLevel() const
Definition: toxmgr.hxx:119
IMPL_LINK_NOARG(SwMultiTOXTabDialog, ShowPreviewHdl, weld::ToggleButton &, void)
Definition: cnttab.cxx:430
std::unique_ptr< weld::Label > m_xLevelFT
Definition: swuicnttab.hxx:316
sal_uInt32 GetControlIndex(FormTokenType eType) const
Definition: cnttab.cxx:3332
bool Contains(FormTokenType) const
Definition: cnttab.cxx:3176
virtual void Reset(const SfxItemSet *) override
Definition: cnttab.cxx:1955
SW_DLLPUBLIC FieldUnit GetDfltMetric(bool bWeb)
Definition: uitool.cxx:698
bool m_bWaitingInitialSettings
Definition: swuicnttab.hxx:128
const SwTOXBase * GetDefaultTOXBase(TOXTypes eTyp, bool bCreate=false)
Definition: edtox.cxx:110
static OUString const & GetAuthFieldName(ToxAuthorityField eType)
Definition: initui.cxx:239
SwTOXElement
Definition: tox.hxx:328
virtual void Reset(const SfxItemSet *) override
Definition: cnttab.cxx:1133
const OUString & GetSortAlgorithm() const
Definition: toxmgr.hxx:162
bool const m_bGlobalFlag
Definition: swuicnttab.hxx:76
FormTokenType eTokenType
Definition: tox.hxx:211
const SwFormTokens & GetPattern(sal_uInt16 nLevel) const
Definition: tox.cxx:932
void SetChapterInfo(sal_uInt16 nSet)
Definition: cnttab.cxx:1662
#define TO_INDEX
Definition: cnttab.hxx:31
std::unique_ptr< SwTokenWindow > m_xTokenWIN
Definition: swuicnttab.hxx:360
OUString sCharStyleName
Definition: tox.hxx:209
SwTOOElements GetOLEOptions() const
Definition: toxmgr.hxx:136
#define TO_OBJECT
Definition: cnttab.hxx:35
std::unique_ptr< weld::TreeView > m_xLevelLB
Definition: swuicnttab.hxx:317
virtual void ClearModified()=0
SwTOXWidget * GetActiveControl()
Definition: swuicnttab.hxx:288
std::unique_ptr< weld::CheckButton > m_xAlphaDelimCB
Definition: swuicnttab.hxx:344
#define TOX_PAGE_SELECT
Definition: cnttab.hxx:26
std::unique_ptr< IndexEntryResource > pIndexRes
Definition: swuicnttab.hxx:118
int i
QPRO_FUNC_TYPE const nType
bool IsFromObjectNames() const
Definition: tox.hxx:496
void FillTOXDescription()
Definition: cnttab.cxx:1022
TRISTATE_FALSE
SwWrtShell & GetWrtShell()
Definition: swuicnttab.hxx:107
SwFormToken aFormToken
Definition: cnttab.cxx:1566
std::unique_ptr< weld::SpinButton > m_xLevelNF
Definition: swuicnttab.hxx:138
size_t GetFieldTypeCount(SwFieldIds nResId=SwFieldIds::Unknown) const
count field types with a ResId, if SwFieldIds::Unknown count all
Definition: edfld.cxx:43
void SetFillChar(sal_Unicode cSet)
Definition: cnttab.cxx:1640
static CurTOXType lcl_UserData2TOXTypes(sal_uInt16 nData)
Definition: cnttab.cxx:882
virtual void PageCreated(const OString &rId, SfxTabPage &rPage) override
Definition: cnttab.cxx:306
sal_Unicode GetSuffix() const
Definition: authfld.hxx:115
std::unique_ptr< weld::ComboBox > m_xBracketLB
Definition: swuicnttab.hxx:182
float u
std::unique_ptr< SwTOXDescription > CreateTOXDescFromTOXBase(const SwTOXBase *pCurTOX)
Definition: cnttab.cxx:403
void SetAccessibleName(const OUString &rName)
Definition: cnttab.cxx:1604
#define TO_TABLE
Definition: cnttab.hxx:33
std::unique_ptr< SwForm > m_pCurrentForm
Definition: swuicnttab.hxx:403
bool IsReadonly() const
Definition: toxmgr.hxx:134
static std::unique_ptr< SfxTabPage > Create(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet *rAttrSet)
Definition: cnttab.cxx:1185
const OUString & GetTypeName() const
Definition: tox.hxx:660
static OUString GetFormChapterMark()
Definition: tox.cxx:504
void ApplyTOXDescription()
Definition: cnttab.cxx:906
void SetOutlineLevel(sal_uInt16 nSet)
Definition: cnttab.cxx:1678
#define ITEM_SEC_KEY
Definition: cnttab.cxx:3562
std::unique_ptr< weld::CheckButton > m_xUseDashCB
Definition: swuicnttab.hxx:170
virtual DeactivateRC DeactivatePage(SfxItemSet *pSet) override
Definition: cnttab.cxx:2117
sal_uInt16 nChapterFormat
Definition: tox.hxx:214
SwForm * m_pForm
Definition: swuicnttab.hxx:225
void SetAccessibleName(const OUString &rName)
Definition: cnttab.cxx:1449
bool IsSequence() const
Definition: authfld.hxx:102
void SetSortAlgorithm(const OUString &rSet)
Definition: toxmgr.hxx:163
sal_uInt16 GetFlatIndex() const
Definition: cnttab.cxx:211
static long lcl_TOXTypesToUserData(CurTOXType eType)
Definition: cnttab.cxx:848
BrowserMode
sal_uInt16 nAuthorityField
Definition: tox.hxx:216
virtual bool FillItemSet(SfxItemSet *) override
Definition: cnttab.cxx:843
DrawTextFlags
OUString SwResId(const char *pId)
Definition: swmodule.cxx:178
SwForm & GetForm()
Definition: swuicnttab.hxx:418
std::unique_ptr< weld::CheckButton > m_xFromOLECB
Definition: swuicnttab.hxx:150
Link< LinkParamNone *, void > m_aModifyHdl
Definition: swuicnttab.hxx:233
virtual void set_grid_left_attach(int nPos) override
Definition: cnttab.cxx:1454
bool IsFromChapter() const
Definition: tox.hxx:493
DocumentType const eType
sal_uInt16 GetLevel() const
Definition: tox.hxx:704
virtual ~SwTOXEntryTabPage() override
Definition: cnttab.cxx:1918
OUString m_sAdditionalAccnameString3
Definition: swuicnttab.hxx:237
void SetCreateFromObjectNames(bool bSet)
Definition: toxmgr.hxx:121
const OUString & GetTitle() const
Definition: tox.hxx:674
void AdjustPositions()
Definition: cnttab.cxx:3022
bool bSortAscending
Definition: authfld.hxx:49
static std::unique_ptr< SfxTabPage > Create(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet *rAttrSet)
Definition: cnttab.cxx:3470
void SetCurrentTOXType(const CurTOXType &eSet)
Definition: swuicnttab.hxx:100
SwCaptionDisplay GetCaptionDisplay() const
Definition: tox.hxx:508
SwDocShell * GetDocShell()
Definition: view.cxx:1107
SwTOXStylesTabPage(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet &rAttrSet)
Definition: cnttab.cxx:3359
void SetForm(SwForm &rForm, sal_uInt16 nLevel)
Definition: cnttab.cxx:2617
const SwFormToken & GetFormToken() const
Definition: cnttab.cxx:1629
Link< SwTOXEdit &, void > aPrevNextControlLink
Definition: cnttab.cxx:1409
OUString const sDelimStr
Definition: swuicnttab.hxx:305
SwTOXEntryTabPage(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet &rAttrSet)
Definition: cnttab.cxx:1781
void SetDefaultTOXBase(const SwTOXBase &rBase)
Definition: edtox.cxx:115
const OUString & GetSortAlgorithm() const
Definition: tox.hxx:519
std::unique_ptr< weld::Label > m_xTypeFT
Definition: swuicnttab.hxx:315
std::unique_ptr< weld::Button > m_xPageNoPB
Definition: swuicnttab.hxx:323
std::unique_ptr< weld::CheckButton > m_xCollectSameCB
Definition: swuicnttab.hxx:168
void SetLanguage(LanguageType nLang)
Definition: toxmgr.hxx:160
ToxAuthorityField
Definition: toxe.hxx:82
bool IsNextControl() const
Definition: cnttab.cxx:1627
only the chapter number
Definition: chpfld.hxx:32
#define ITEM_PRIM_KEY
Definition: cnttab.cxx:3561
std::unique_ptr< weld::Label > m_xTypeFT
Definition: swuicnttab.hxx:131
void SetLevelFromChapter(bool bSet)
Definition: toxmgr.hxx:140
std::unique_ptr< weld::CheckButton > m_xTOXMarksCB
Definition: swuicnttab.hxx:164
std::unique_ptr< weld::CheckButton > m_xFromFileCB
Definition: swuicnttab.hxx:174
#define ITEM_CASE
Definition: cnttab.cxx:3564
void SetAutoMarkURL(const OUString &rSet)
Definition: toxmgr.hxx:98
const OUString & GetMainEntryCharStyle() const
Definition: toxmgr.hxx:115
void SetGetFocusHdl(const Link< SwTOXWidget &, void > &rLink)
Definition: cnttab.cxx:1400
std::unique_ptr< weld::ComboBox > m_xChapterEntryLB
Definition: swuicnttab.hxx:331
const SfxPoolItem * Put(const SfxPoolItem &rItem, sal_uInt16 nWhich)
std::unique_ptr< weld::CheckButton > m_xCaseSensitiveCB
Definition: swuicnttab.hxx:171
std::unique_ptr< weld::CheckButton > m_xKeyAsEntryCB
Definition: swuicnttab.hxx:173
const CurTOXType & GetCurrentTOXType() const
Definition: swuicnttab.hxx:99
#define ITEM_WORDONLY
Definition: cnttab.cxx:3565
void AdjustSize()
Definition: cnttab.cxx:1556
bool IsRelTabPos() const
Definition: tox.hxx:307
bool IsShift() const
const SwGetSetExpType GSE_SEQ
Sequence.
Definition: fldbas.hxx:198
void WriteBackLevel()
Definition: cnttab.cxx:2251
SwTokenWindow(std::unique_ptr< weld::Container > xParent)
Definition: cnttab.cxx:2574
void SetTabPosition(SwTwips nSet)
Definition: cnttab.cxx:1637
ToxAuthorityField eField
Definition: authfld.hxx:48
weld::Entry & rEdit
static Size GetMinimumEditSize()
SwTwips nTabStopPosition
Definition: tox.hxx:210
LanguageType GetLanguage() const
Definition: toxmgr.hxx:159
TOXTypes eType
Definition: cnttab.hxx:41
std::unique_ptr< weld::CheckButton > m_xFromGraphicsCB
Definition: swuicnttab.hxx:149
WindowType
std::unique_ptr< weld::Widget > m_xFormatFrame
Definition: swuicnttab.hxx:341
virtual OUString GetName() const
Only in derived classes.
Definition: fldbas.cxx:135
virtual DeactivateRC DeactivatePage(SfxItemSet *pSet) override
Definition: cnttab.cxx:3464
void SetForm(const SwForm &rSet)
Definition: toxmgr.hxx:106
const SfxPoolItem & Get(sal_uInt16 nWhich, bool bSrchInParent=true) const
void SetCaptionDisplay(SwCaptionDisplay eSet)
Definition: toxmgr.hxx:128
static const sal_Unicode aDeliEnd
Definition: cnttab.cxx:92
#define SAL_WARN_IF(condition, area, stream)
void get_extents_relative_to(weld::Widget &rRelative, int &x, int &y, int &width, int &height) override
Definition: cnttab.cxx:1614
#define ERRCODE_NONE
WinBits const WB_BORDER
void InsertAtSelection(const SwFormToken &aToken)
Definition: cnttab.cxx:2776
void SetTabAlign(SvxTabAdjust eAlign)
Definition: cnttab.cxx:1643
void Show()
Definition: cnttab.cxx:1444
std::unique_ptr< weld::Button > m_xAllLevelsPB
Definition: swuicnttab.hxx:318
std::unique_ptr< weld::ComboBox > m_xSortAlgorithmLB
Definition: swuicnttab.hxx:188
std::unique_ptr< const IndexEntrySupplierWrapper > pIndexEntryWrapper
Definition: swuicnttab.hxx:126
void ApplyTo(SwTOXBase &rTOXBase)
Definition: toxmgr.cxx:474
TOXTypes GetType() const
Definition: tox.hxx:695
const o3tl::enumarray< SvxAdjust, unsigned short > aSvxToUnoAdjust USHRT_MAX
Definition: unosett.cxx:253
OUString const & GetStyleNames(sal_uInt16 nLevel) const
Definition: tox.hxx:483
void SetOLEOptions(SwTOOElements nOpt)
Definition: toxmgr.hxx:137
OUString aName
OUString const m_sUserDefinedIndex
Definition: swuicnttab.hxx:71
std::unique_ptr< weld::CheckButton > m_xShowExampleCB
Definition: swuicnttab.hxx:79
LanguageType GetLanguage() const
Definition: tox.hxx:516
bool IsCommaSeparated() const
Definition: tox.hxx:310
std::unique_ptr< weld::Button > m_xTabPB
Definition: swuicnttab.hxx:321
#define TOX_PAGE_ENTRY
Definition: cnttab.hxx:27
RET_OK
void SetCharStyleName(const OUString &rSet, sal_uInt16 nPoolId)
Definition: cnttab.cxx:1631
std::unique_ptr< weld::Button > m_xEditStylePB
Definition: swuicnttab.hxx:329
bool IsMod1() const
void SetSortKeys(SwTOXSortKey eKey1, SwTOXSortKey eKey2, SwTOXSortKey eKey3)
Definition: toxmgr.cxx:456
void SetStreamCharSet(rtl_TextEncoding eCharSet)
std::unique_ptr< weld::RadioButton > m_xThirdSortUpRB
Definition: swuicnttab.hxx:358
void AddTabPage(const OString &rName, CreateTabPage pCreateFunc, GetTabPageRanges pRangesFunc)
std::unique_ptr< weld::CheckButton > m_xSequenceCB
Definition: swuicnttab.hxx:181
o3tl::optional< OUString > const & GetTitle() const
Definition: toxmgr.hxx:101
virtual void Hide()=0
Reference< XExecutableDialog > m_xDialog
#define FORM_ALPHA_DELIMITER
Definition: tox.hxx:170
static const OUString & GetUIName(const OUString &rName, SwGetPoolIdFromName)
static OUString GetFormLinkEnd()
Definition: tox.cxx:501
OUString const sNoCharStyle
Definition: swuicnttab.hxx:309
std::unique_ptr< weld::Button > m_xAssignBT
Definition: swuicnttab.hxx:406
SfxOkDialogController * GetDialogController() const
static OUString GetFormEntryText()
Definition: tox.cxx:503
Sequence< sal_Int8 > aSeq
void AdjustScrolling()
Definition: cnttab.cxx:3039
SwTOXBase * m_pParamTOXBase
Definition: swuicnttab.hxx:67
OUString CreateQuickHelp(const SwFormToken &rToken)
Definition: cnttab.cxx:3197
SwTOXEntryTabPage * m_pParent
Definition: swuicnttab.hxx:241
CurTOXType m_eCurrentTOXType
Definition: swuicnttab.hxx:69
SwTOXButton(SwTokenWindow *pTokenWin, const SwFormToken &rToken)
Definition: cnttab.cxx:1572
SwTOXSelectTabPage(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet &rAttrSet)
Definition: cnttab.cxx:711
const SwTOXType * GetTOXType(TOXTypes eTyp, sal_uInt16 nId) const
Definition: edtox.cxx:199
std::unique_ptr< weld::Entry > m_xEntry
Definition: cnttab.cxx:1412
void SetText(const OUString &rText)
Definition: cnttab.cxx:1469
SwMultiTOXTabDialog(weld::Window *pParent, const SfxItemSet &rSet, SwWrtShell &rShell, SwTOXBase *pCurTOX, sal_uInt16 nToxType, bool bGlobal)
Definition: cnttab.cxx:217
void SetLinkEnd()
Definition: cnttab.cxx:1685
virtual DeactivateRC DeactivatePage(SfxItemSet *pSet) override
Definition: cnttab.cxx:1177
const OUString & GetMainEntryCharStyle() const
Definition: tox.hxx:462
static weld::MessageDialog * CreateMessageDialog(weld::Widget *pParent, VclMessageType eMessageType, VclButtonsType eButtonType, const OUString &rPrimaryMessage)
WinBits const WB_TABSTOP
#define TO_ILLUSTRATION
Definition: cnttab.hxx:32
std::unique_ptr< SwTOXMgr > m_pMgr
Definition: swuicnttab.hxx:56
std::unique_ptr< weld::Widget > m_xSortingFrame
Definition: swuicnttab.hxx:347
bool good() const
std::unique_ptr< weld::ComboBox > m_xDisplayTypeLB
Definition: swuicnttab.hxx:161
DeactivateRC
void SetFocus2theAllBtn()
Definition: cnttab.cxx:3324
std::unique_ptr< weld::Button > m_xEntryNoPB
Definition: swuicnttab.hxx:319
void SetPrevNextLink(const Link< SwTOXButton &, void > &rLink)
Definition: cnttab.cxx:1628
OUString sId
void SetWrtShell(SwWrtShell const &rSh)
Definition: cnttab.cxx:825
bool bNextControl
Definition: cnttab.cxx:1410
Link< SwTOXButton &, void > aPrevNextControlLink
Definition: cnttab.cxx:1567
void SAL_CALL first(const css::awt::SpinEvent &rEvent) override
static const char * STR_TOKEN_HELP_ARY[]
Definition: cnttab.cxx:2560
SvxTabAdjust eTabAlign
Definition: tox.hxx:213
virtual void get_extents_relative_to(weld::Widget &rRelative, int &x, int &y, int &width, int &height) override
Definition: cnttab.cxx:1459
static std::unique_ptr< SfxTabPage > Create(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet *rSet)
Definition: column.cxx:601
void Show()
Definition: cnttab.cxx:1599
void SetCharStyleName(const OUString &rSet, sal_uInt16 nPoolId)
Definition: cnttab.cxx:1501
bool IsSortByDocument() const
Definition: authfld.hxx:117
void(* f)(TrueTypeTable *)
SwTokenWindow * m_pParent
Definition: cnttab.cxx:1569
std::unique_ptr< weld::CheckButton > m_xReadOnlyCB
Definition: swuicnttab.hxx:133
#define FN_PARAM_TOX_TYPE
Definition: cmdid.h:795
#define TO_AUTHORITIES
Definition: cnttab.hxx:36
virtual ~SwTOXWidget()
Definition: cnttab.cxx:1401
void SetActiveControl(SwTOXWidget *pSet)
Definition: cnttab.cxx:2689
void SetContentOptions(SwTOXElement nSet)
Definition: toxmgr.hxx:109
static const char * STR_TOKEN_ARY[]
Definition: cnttab.cxx:2546
bool SearchFile(OUString &rIniFile, Paths ePath=PATH_USERCONFIG)
const OUString & GetStyleNames(sal_uInt16 nLvl) const
Definition: toxmgr.hxx:92
std::unique_ptr< weld::Button > m_xChapterInfoPB
Definition: swuicnttab.hxx:322
static std::unique_ptr< SfxTabPage > Create(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet *rAttrSet)
Definition: cnttab.cxx:2123
sal_uInt16 nIndex
Definition: cnttab.hxx:42
void SetCommaSeparated(bool b)
Definition: tox.hxx:311
const SwForm & GetTOXForm() const
Definition: tox.hxx:686
#define TOX_PAGE_STYLES
Definition: cnttab.hxx:28
std::unique_ptr< weld::CheckButton > m_xLevelFromChapterCB
Definition: swuicnttab.hxx:151
std::unique_ptr< weld::CheckButton > m_xInitialCapsCB
Definition: swuicnttab.hxx:172
TriState
bool bNextControl
Definition: cnttab.cxx:1568
static OUString GetFormAuth()
Definition: tox.cxx:506