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