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