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