LibreOffice Module sw (master)  1
cnttab.cxx
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3  * This file is part of the LibreOffice project.
4  *
5  * This Source Code Form is subject to the terms of the Mozilla Public
6  * License, v. 2.0. If a copy of the MPL was not distributed with this
7  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8  *
9  * This file incorporates work covered by the following license notice:
10  *
11  * Licensed to the Apache Software Foundation (ASF) under one or more
12  * contributor license agreements. See the NOTICE file distributed
13  * with this work for additional information regarding copyright
14  * ownership. The ASF licenses this file to you under the Apache
15  * License, Version 2.0 (the "License"); you may not use this file
16  * except in compliance with the License. You may obtain a copy of
17  * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18  */
19 
20 #include <sal/config.h>
21 
22 #include <o3tl/safeint.hxx>
23 #include <sal/log.hxx>
24 #include <svl/style.hxx>
25 #include <vcl/weld.hxx>
26 #include <svl/stritem.hxx>
27 #include <unotools/pathoptions.hxx>
28 #include <sfx2/viewfrm.hxx>
29 #include <sfx2/dispatch.hxx>
30 #include <sfx2/docfile.hxx>
31 #include <sfx2/sfxdlg.hxx>
32 #include <svx/dialogs.hrc>
33 #include <svx/flagsdef.hxx>
34 #include <com/sun/star/ui/dialogs/TemplateDescription.hpp>
35 #include <com/sun/star/ui/dialogs/XFilePicker3.hpp>
38 #include <column.hxx>
39 #include <fmtfsize.hxx>
40 #include <authfld.hxx>
41 #include <swtypes.hxx>
42 #include <wrtsh.hxx>
43 #include <view.hxx>
44 #include <cnttab.hxx>
45 #include <swuicnttab.hxx>
46 #include <poolfmt.hxx>
47 #include <strings.hrc>
48 #include <uitool.hxx>
49 #include <fmtcol.hxx>
50 #include <fldbas.hxx>
51 #include <expfld.hxx>
52 #include <unotools.hxx>
53 #include <docsh.hxx>
54 #include <swmodule.hxx>
55 #include <modcfg.hxx>
56 
57 #include <cmdid.h>
58 #include <cnttab.hrc>
59 #include <SwStyleNameMapper.hxx>
60 #include <sfx2/filedlghelper.hxx>
61 #include <toxwrap.hxx>
62 #include <chpfld.hxx>
63 
64 #include <cmath>
65 #include <memory>
66 #include <vector>
67 #include <numeric>
68 
69 
70 using namespace ::com::sun::star;
71 using namespace ::com::sun::star::lang;
72 using namespace ::com::sun::star::uno;
73 using namespace com::sun::star::ui::dialogs;
74 using namespace ::sfx2;
76 
77 const sal_Unicode aDeliStart = '['; // for the form
78 const sal_Unicode aDeliEnd = ']'; // for the form
79 
80 static OUString lcl_CreateAutoMarkFileDlg(weld::Window* pParent, const OUString& rURL,
81  const OUString& rFileString, bool bOpen)
82 {
83  OUString sRet;
84 
85  FileDialogHelper aDlgHelper( bOpen ?
86  TemplateDescription::FILEOPEN_SIMPLE : TemplateDescription::FILESAVE_AUTOEXTENSION,
87  FileDialogFlags::NONE, pParent);
88  uno::Reference < XFilePicker3 > xFP = aDlgHelper.GetFilePicker();
89 
90  xFP->appendFilter( rFileString, "*.sdi" );
91  xFP->setCurrentFilter( rFileString ) ;
92 
93  if( !rURL.isEmpty() )
94  xFP->setDisplayDirectory( rURL );
95  else
96  {
97  SvtPathOptions aPathOpt;
98  xFP->setDisplayDirectory( aPathOpt.GetUserConfigPath() );
99  }
100 
101  if( aDlgHelper.Execute() == ERRCODE_NONE )
102  {
103  sRet = xFP->getSelectedFiles().getConstArray()[0];
104  }
105 
106  return sRet;
107 }
108 
109 namespace {
110 
111 struct AutoMarkEntry
112 {
113  OUString sSearch;
114  OUString sAlternative;
115  OUString sPrimKey;
116  OUString sSecKey;
117  OUString sComment;
118  bool bCase;
119  bool bWord;
120 
121  AutoMarkEntry() :
122  bCase(false),
123  bWord(false){}
124 };
125 
126 }
127 
128 typedef ::svt::EditBrowseBox SwEntryBrowseBox_Base;
129 
130 namespace {
131 
132 class SwEntryBrowseBox : public SwEntryBrowseBox_Base
133 {
134  VclPtr<svt::EditControl> m_aCellEdit;
135  VclPtr<svt::CheckBoxControl> m_aCellCheckBox;
136 
137  OUString m_sYes;
138  OUString m_sNo;
139 
140  std::vector<std::unique_ptr<AutoMarkEntry>> m_Entries;
141 
142  ::svt::CellControllerRef m_xController;
143  ::svt::CellControllerRef m_xCheckController;
144 
145  sal_Int32 m_nCurrentRow;
146  bool m_bModified;
147 
148 protected:
149  virtual bool SeekRow( sal_Int32 nRow ) override;
150  virtual void PaintCell(OutputDevice& rDev, const tools::Rectangle& rRect, sal_uInt16 nColId) const override;
151  virtual void InitController(::svt::CellControllerRef& rController, sal_Int32 nRow, sal_uInt16 nCol) override;
152  virtual ::svt::CellController* GetController(sal_Int32 nRow, sal_uInt16 nCol) override;
153  virtual bool SaveModified() override;
154 
155  std::vector<tools::Long> GetOptimalColWidths() const;
156 
157 public:
158  SwEntryBrowseBox(const css::uno::Reference<css::awt::XWindow> &rParent);
159  virtual ~SwEntryBrowseBox() override;
160  virtual void dispose() override;
161  void ReadEntries(SvStream& rInStr);
162  void WriteEntries(SvStream& rOutStr);
163 
164  bool IsModified()const override;
165 
166  virtual OUString GetCellText( sal_Int32 nRow, sal_uInt16 nColumn ) const override;
167  virtual void Resize() override;
168  virtual Size GetOptimalSize() const override;
169 };
170 
171 class SwAutoMarkDlg_Impl : public weld::GenericDialogController
172 {
173  OUString sAutoMarkURL;
174  bool bCreateMode;
175 
176  std::unique_ptr<weld::Button> m_xOKPB;
177  std::unique_ptr<weld::Container> m_xTable;
178  css::uno::Reference<css::awt::XWindow> m_xTableCtrlParent;
179  VclPtr<SwEntryBrowseBox> m_xEntriesBB;
180 
181  DECL_LINK(OkHdl, weld::Button&, void);
182 public:
183  SwAutoMarkDlg_Impl(weld::Window* pParent, const OUString& rAutoMarkURL,
184  bool bCreate);
185  virtual ~SwAutoMarkDlg_Impl() override;
186 };
187 
188 }
189 
190 sal_uInt16 CurTOXType::GetFlatIndex() const
191 {
192  return static_cast< sal_uInt16 >( (eType == TOX_USER && nIndex)
193  ? TOX_AUTHORITIES + nIndex : eType );
194 }
195 
197  SwWrtShell &rShell, SwTOXBase* pCurTOX,
198  sal_uInt16 nToxType, bool bGlobal)
199  : SfxTabDialogController(pParent, "modules/swriter/ui/tocdialog.ui", "TocDialog", &rSet)
200  , m_pMgr( new SwTOXMgr( &rShell ) )
201  , m_rWrtShell(rShell)
202  , m_pParamTOXBase(pCurTOX)
203  , m_sUserDefinedIndex(SwResId(STR_USER_DEFINED_INDEX))
204  , m_nInitialTOXType(nToxType)
205  , m_bEditTOX(false)
206  , m_bExampleCreated(false)
207  , m_bGlobalFlag(bGlobal)
208  , m_xShowExampleCB(m_xBuilder->weld_check_button("showexample"))
209 {
212 
213  const sal_uInt16 nUserTypeCount = m_rWrtShell.GetTOXTypeCount(TOX_USER);
214  m_vTypeData.resize(nUserTypeCount + 6);
215  //the standard user index is on position TOX_USER
216  //all user indexes follow after position TOX_AUTHORITIES
217  if(pCurTOX)
218  {
219  m_bEditTOX = true;
220  }
221  for(int i = m_vTypeData.size() - 1; i > -1; i--)
222  {
223  m_vTypeData[i].m_pxIndexSections.reset(new SwIndexSections_Impl);
224  if(pCurTOX)
225  {
226  m_eCurrentTOXType.eType = pCurTOX->GetType();
227  sal_uInt16 nArrayIndex = static_cast< sal_uInt16 >(m_eCurrentTOXType.eType);
229  {
230  //which user type is it?
231  for(sal_uInt16 nUser = 0; nUser < nUserTypeCount; nUser++)
232  {
233  const SwTOXType* pTemp = m_rWrtShell.GetTOXType(TOX_USER, nUser);
234  if(pCurTOX->GetTOXType() == pTemp)
235  {
236  m_eCurrentTOXType.nIndex = nUser;
237  nArrayIndex = static_cast< sal_uInt16 >(nUser > 0 ? TOX_AUTHORITIES + nUser : TOX_USER);
238  break;
239  }
240  }
241  }
242  m_vTypeData[nArrayIndex].m_pForm.reset(new SwForm(pCurTOX->GetTOXForm()));
243  m_vTypeData[nArrayIndex].m_pDescription = CreateTOXDescFromTOXBase(pCurTOX);
245  {
246  const SwAuthorityFieldType* pFType = static_cast<const SwAuthorityFieldType*>(
248  if(pFType)
249  {
250  OUString sBrackets;
251  if(pFType->GetPrefix())
252  sBrackets += OUStringChar(pFType->GetPrefix());
253  if(pFType->GetSuffix())
254  sBrackets += OUStringChar(pFType->GetSuffix());
255  m_vTypeData[nArrayIndex].m_pDescription->SetAuthBrackets(sBrackets);
256  m_vTypeData[nArrayIndex].m_pDescription->SetAuthSequence(pFType->IsSequence());
257  }
258  else
259  {
260  m_vTypeData[nArrayIndex].m_pDescription->SetAuthBrackets("[]");
261  }
262  }
263  }
264  }
266  AddTabPage("index", SwTOXSelectTabPage::Create, nullptr);
267  AddTabPage("styles", SwTOXStylesTabPage::Create, nullptr);
268  AddTabPage("columns", SwColumnPage::Create, nullptr);
269  AddTabPage("background", pFact->GetTabPageCreatorFunc(RID_SVXPAGE_BKG), nullptr);
270  AddTabPage("entries", SwTOXEntryTabPage::Create, nullptr);
271  if (!pCurTOX)
272  SetCurPageId("index");
273 
274  m_xShowExampleCB->connect_toggled(LINK(this, SwMultiTOXTabDialog, ShowPreviewHdl));
275  m_xShowExampleCB->set_active(SW_MOD()->GetModuleConfig()->IsShowIndexPreview());
276 
277  ShowPreviewHdl(*m_xShowExampleCB);
278 }
279 
281 {
282  SW_MOD()->GetModuleConfig()->SetShowIndexPreview(m_xShowExampleCB->get_active());
283 }
284 
285 void SwMultiTOXTabDialog::PageCreated(const OString& rId, SfxTabPage &rPage)
286 {
287  if (rId == "background")
288  {
289  SfxAllItemSet aSet(*(GetInputSetImpl()->GetPool()));
290  aSet.Put (SfxUInt32Item(SID_FLAG_TYPE, static_cast<sal_uInt32>(SvxBackgroundTabFlags::SHOW_SELECTOR)));
291  rPage.PageCreated(aSet);
292  }
293  else if (rId == "columns")
294  {
296 
297  static_cast<SwColumnPage&>(rPage).SetPageWidth(rSize.GetWidth());
298  }
299  else if (rId == "entries")
300  static_cast<SwTOXEntryTabPage&>(rPage).SetWrtShell(m_rWrtShell);
301  else if (rId == "index")
302  {
303  static_cast<SwTOXSelectTabPage&>(rPage).SetWrtShell(m_rWrtShell);
304  if(USHRT_MAX != m_nInitialTOXType)
305  static_cast<SwTOXSelectTabPage&>(rPage).SelectType(static_cast<TOXTypes>(m_nInitialTOXType));
306  }
307 }
308 
310 {
311  short nRet = SfxTabDialogController::Ok();
314 
315  const sal_uInt16 nIndex = m_eCurrentTOXType.GetFlatIndex();
316  if(m_vTypeData[nIndex].m_pForm)
317  {
318  rDesc.SetForm(*m_vTypeData[nIndex].m_pForm);
319  aNewDef.SetTOXForm(*m_vTypeData[nIndex].m_pForm);
320  }
321  rDesc.ApplyTo(aNewDef);
322  if(!m_bGlobalFlag)
323  m_pMgr->UpdateOrInsertTOX(
324  rDesc, nullptr, GetOutputItemSet());
325  else if(m_bEditTOX)
326  m_pMgr->UpdateOrInsertTOX(
327  rDesc, &m_pParamTOXBase, GetOutputItemSet());
328 
331 
332  return nRet;
333 }
334 
336 {
337  const sal_uInt16 nIndex = eType.GetFlatIndex();
338  if(!m_vTypeData[nIndex].m_pForm)
339  m_vTypeData[nIndex].m_pForm.reset(new SwForm(eType.eType));
340  return m_vTypeData[nIndex].m_pForm.get();
341 }
342 
344 {
345  const sal_uInt16 nIndex = eType.GetFlatIndex();
346  if(!m_vTypeData[nIndex].m_pDescription)
347  {
348  const SwTOXBase* pDef = m_rWrtShell.GetDefaultTOXBase( eType.eType );
349  if(pDef)
350  m_vTypeData[nIndex].m_pDescription = CreateTOXDescFromTOXBase(pDef);
351  else
352  {
353  m_vTypeData[nIndex].m_pDescription.reset(new SwTOXDescription(eType.eType));
354  if(eType.eType == TOX_USER)
355  m_vTypeData[nIndex].m_pDescription->SetTitle(m_sUserDefinedIndex);
356  else
357  m_vTypeData[nIndex].m_pDescription->SetTitle(
358  m_rWrtShell.GetTOXType(eType.eType, 0)->GetTypeName());
359  }
360  if(TOX_AUTHORITIES == eType.eType)
361  {
362  const SwAuthorityFieldType* pFType = static_cast<const SwAuthorityFieldType*>(
364  if(pFType)
365  {
366  m_vTypeData[nIndex].m_pDescription->SetAuthBrackets(OUStringChar(pFType->GetPrefix()) +
367  OUStringChar(pFType->GetSuffix()));
368  m_vTypeData[nIndex].m_pDescription->SetAuthSequence(pFType->IsSequence());
369  }
370  else
371  {
372  m_vTypeData[nIndex].m_pDescription->SetAuthBrackets("[]");
373  }
374  }
375  else if(TOX_INDEX == eType.eType)
376  m_vTypeData[nIndex].m_pDescription->SetMainEntryCharStyle(SwResId(STR_POOLCHR_IDX_MAIN_ENTRY));
377 
378  }
379  return *m_vTypeData[nIndex].m_pDescription;
380 }
381 
382 std::unique_ptr<SwTOXDescription> SwMultiTOXTabDialog::CreateTOXDescFromTOXBase(
383  const SwTOXBase*pCurTOX)
384 {
385  std::unique_ptr<SwTOXDescription> pDesc(new SwTOXDescription(pCurTOX->GetType()));
386  for(sal_uInt16 i = 0; i < MAXLEVEL; i++)
387  pDesc->SetStyleNames(pCurTOX->GetStyleNames(i), i);
388  pDesc->SetAutoMarkURL(m_rWrtShell.GetTOIAutoMarkURL());
389  pDesc->SetTitle(pCurTOX->GetTitle());
390 
391  pDesc->SetContentOptions(pCurTOX->GetCreateType());
392  if(pDesc->GetTOXType() == TOX_INDEX)
393  pDesc->SetIndexOptions(pCurTOX->GetOptions());
394  pDesc->SetMainEntryCharStyle(pCurTOX->GetMainEntryCharStyle());
395  if(pDesc->GetTOXType() != TOX_INDEX)
396  pDesc->SetLevel(static_cast<sal_uInt8>(pCurTOX->GetLevel()));
397  pDesc->SetCreateFromObjectNames(pCurTOX->IsFromObjectNames());
398  pDesc->SetSequenceName(pCurTOX->GetSequenceName());
399  pDesc->SetCaptionDisplay(pCurTOX->GetCaptionDisplay());
400  pDesc->SetFromChapter(pCurTOX->IsFromChapter());
401  pDesc->SetReadonly(pCurTOX->IsProtected());
402  pDesc->SetOLEOptions(pCurTOX->GetOLEOptions());
403  pDesc->SetLevelFromChapter(pCurTOX->IsLevelFromChapter());
404  pDesc->SetLanguage(pCurTOX->GetLanguage());
405  pDesc->SetSortAlgorithm(pCurTOX->GetSortAlgorithm());
406  return pDesc;
407 }
408 
410 {
411  if (m_xShowExampleCB->get_active())
412  {
413  if(!m_xExampleFrame && !m_bExampleCreated)
414  {
415  m_bExampleCreated = true;
416  OUString sTemplate("internal/idxexample.odt");
417 
418  SvtPathOptions aOpt;
419  bool bExist = aOpt.SearchFile( sTemplate, SvtPathOptions::Paths::Template );
420 
421  if(!bExist)
422  {
423  OUString sInfo(SwResId(STR_FILE_NOT_FOUND));
424  sInfo = sInfo.replaceFirst( "%1", sTemplate );
425  sInfo = sInfo.replaceFirst( "%2", aOpt.GetTemplatePath() );
426  std::unique_ptr<weld::MessageDialog> xInfoBox(Application::CreateMessageDialog(m_xDialog.get(),
427  VclMessageType::Info, VclButtonsType::Ok,
428  sInfo));
429  xInfoBox->run();
430  }
431  else
432  {
433  Link<SwOneExampleFrame&,void> aLink(LINK(this, SwMultiTOXTabDialog, CreateExample_Hdl));
434  m_xExampleFrame.reset(new SwOneExampleFrame(EX_SHOW_ONLINE_LAYOUT | EX_LOCALIZE_TOC_STRINGS, &aLink, &sTemplate));
435  m_xExampleFrameWin.reset(new weld::CustomWeld(*m_xBuilder, "example", *m_xExampleFrame));
436  }
437  m_xShowExampleCB->set_visible(m_xExampleFrame != nullptr);
438  }
439  }
440 
441  if (m_xExampleFrame)
442  {
443  const bool bSetViewWindow = m_xShowExampleCB->get_active();
444  if (bSetViewWindow)
445  m_xExampleFrame->Show();
446  else
447  m_xExampleFrame->Hide();
448  }
449 
450  m_xDialog->resize_to_request();
451 }
452 
453 bool SwMultiTOXTabDialog::IsNoNum(SwWrtShell& rSh, const OUString& rName)
454 {
455  SwTextFormatColl* pColl = rSh.GetParaStyle(rName);
456  if(pColl && ! pColl->IsAssignedToListLevelOfOutlineStyle())
457  return true;
458 
459  const sal_uInt16 nId = SwStyleNameMapper::GetPoolIdFromUIName(
461  return nId != USHRT_MAX &&
463 }
464 
465 namespace {
466 
467 class SwAddStylesDlg_Impl : public SfxDialogController
468 {
469  OUString* pStyleArr;
470 
471  std::unique_ptr<weld::Button> m_xOk;
472  std::unique_ptr<weld::Button> m_xLeftPB;
473  std::unique_ptr<weld::Button> m_xRightPB;
474  std::unique_ptr<weld::TreeView> m_xHeaderTree;
475 
476  DECL_LINK(OkHdl, weld::Button&, void);
477  DECL_LINK(LeftRightHdl, weld::Button&, void);
478  DECL_LINK(KeyInput, const KeyEvent&, bool);
479  DECL_LINK(TreeSizeAllocHdl, const Size&, void);
480  DECL_LINK(RadioToggleOnHdl, const weld::TreeView::iter_col&, void);
481 
482 public:
483  SwAddStylesDlg_Impl(weld::Window* pParent, SwWrtShell const & rWrtSh, OUString rStringArr[]);
484 };
485 
486 }
487 
488 SwAddStylesDlg_Impl::SwAddStylesDlg_Impl(weld::Window* pParent,
489  SwWrtShell const & rWrtSh, OUString rStringArr[])
490  : SfxDialogController(pParent, "modules/swriter/ui/assignstylesdialog.ui", "AssignStylesDialog")
491  , pStyleArr(rStringArr)
492  , m_xOk(m_xBuilder->weld_button("ok"))
493  , m_xLeftPB(m_xBuilder->weld_button("left"))
494  , m_xRightPB(m_xBuilder->weld_button("right"))
495  , m_xHeaderTree(m_xBuilder->weld_tree_view("styles"))
496 {
497  m_xOk->connect_clicked(LINK(this, SwAddStylesDlg_Impl, OkHdl));
498  m_xLeftPB->connect_clicked(LINK(this, SwAddStylesDlg_Impl, LeftRightHdl));
499  m_xRightPB->connect_clicked(LINK(this, SwAddStylesDlg_Impl, LeftRightHdl));
500 
501  m_xHeaderTree->connect_size_allocate(LINK(this, SwAddStylesDlg_Impl, TreeSizeAllocHdl));
502  m_xHeaderTree->enable_toggle_buttons(weld::ColumnToggleType::Radio);
503  m_xHeaderTree->connect_toggled(LINK(this, SwAddStylesDlg_Impl, RadioToggleOnHdl));
504 
505  std::vector<int> aWidths;
506  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::Toggleable&,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::Toggleable&, 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  STR_AUTH_FIELD_LOCAL_URL,
1764  };
1765 }
1766 
1768  : SfxTabPage(pPage, pController, "modules/swriter/ui/tocentriespage.ui", "TocEntriesPage", &rAttrSet)
1769  , sDelimStr(SwResId(STR_DELIM))
1770  , sNoCharStyle(SwResId(STR_NO_CHAR_STYLE))
1771  , m_pCurrentForm(nullptr)
1772  , bInLevelHdl(false)
1773  , m_xTypeFT(m_xBuilder->weld_label("typeft"))
1774  , m_xLevelFT(m_xBuilder->weld_label("levelft"))
1775  , m_xLevelLB(m_xBuilder->weld_tree_view("level"))
1776  , m_xAllLevelsPB(m_xBuilder->weld_button("all"))
1777  , m_xEntryNoPB(m_xBuilder->weld_button("chapterno"))
1778  , m_xEntryPB(m_xBuilder->weld_button("entrytext"))
1779  , m_xTabPB(m_xBuilder->weld_button("tabstop"))
1780  , m_xChapterInfoPB(m_xBuilder->weld_button("chapterinfo"))
1781  , m_xPageNoPB(m_xBuilder->weld_button("pageno"))
1782  , m_xHyperLinkPB(m_xBuilder->weld_button("hyperlink"))
1783  , m_xAuthFieldsLB(m_xBuilder->weld_combo_box("authfield"))
1784  , m_xAuthInsertPB(m_xBuilder->weld_button("insert"))
1785  , m_xAuthRemovePB(m_xBuilder->weld_button("remove"))
1786  , m_xCharStyleLB(m_xBuilder->weld_combo_box("charstyle"))
1787  , m_xEditStylePB(m_xBuilder->weld_button("edit"))
1788  , m_xChapterEntryFT(m_xBuilder->weld_label("chapterentryft"))
1789  , m_xChapterEntryLB(m_xBuilder->weld_combo_box("chapterentry"))
1790  , m_xNumberFormatFT(m_xBuilder->weld_label("numberformatft"))
1791  , m_xNumberFormatLB(m_xBuilder->weld_combo_box("numberformat"))
1792  , m_xEntryOutlineLevelFT(m_xBuilder->weld_label("entryoutlinelevelft"))
1793  , m_xEntryOutlineLevelNF(m_xBuilder->weld_spin_button("entryoutlinelevel"))
1794  , m_xFillCharFT(m_xBuilder->weld_label("fillcharft"))
1795  , m_xFillCharCB(m_xBuilder->weld_combo_box("fillchar"))
1796  , m_xTabPosFT(m_xBuilder->weld_label("tabstopposft"))
1797  , m_xTabPosMF(m_xBuilder->weld_metric_spin_button("tabstoppos", FieldUnit::CM))
1798  , m_xAutoRightCB(m_xBuilder->weld_check_button("alignright"))
1799  , m_xFormatFrame(m_xBuilder->weld_widget("formatframe"))
1800  , m_xMainEntryStyleFT(m_xBuilder->weld_label("mainstyleft"))
1801  , m_xMainEntryStyleLB(m_xBuilder->weld_combo_box("mainstyle"))
1802  , m_xAlphaDelimCB(m_xBuilder->weld_check_button("alphadelim"))
1803  , m_xCommaSeparatedCB(m_xBuilder->weld_check_button("commasep"))
1804  , m_xRelToStyleCB(m_xBuilder->weld_check_button("reltostyle"))
1805  , m_xSortingFrame(m_xBuilder->weld_widget("sortingframe"))
1806  , m_xSortDocPosRB(m_xBuilder->weld_radio_button("sortpos"))
1807  , m_xSortContentRB(m_xBuilder->weld_radio_button("sortcontents"))
1808  , m_xSortKeyFrame(m_xBuilder->weld_widget("sortkeyframe"))
1809  , m_xFirstKeyLB(m_xBuilder->weld_combo_box("key1lb"))
1810  , m_xFirstSortUpRB(m_xBuilder->weld_radio_button("up1cb"))
1811  , m_xFirstSortDownRB(m_xBuilder->weld_radio_button("down1cb"))
1812  , m_xSecondKeyLB(m_xBuilder->weld_combo_box("key2lb"))
1813  , m_xSecondSortUpRB(m_xBuilder->weld_radio_button("up2cb"))
1814  , m_xSecondSortDownRB(m_xBuilder->weld_radio_button("down2cb"))
1815  , m_xThirdKeyLB(m_xBuilder->weld_combo_box("key3lb"))
1816  , m_xThirdSortUpRB(m_xBuilder->weld_radio_button("up3cb"))
1817  , m_xThirdSortDownRB(m_xBuilder->weld_radio_button("down3cb"))
1818  , m_xTokenWIN(new SwTokenWindow(m_xBuilder->weld_container("token")))
1819 {
1820  const OUString sNoCharSortKey(SwResId(STR_NOSORTKEY));
1821 
1822  sAuthTypeStr = m_xTypeFT->get_label();
1823  sLevelStr = m_xLevelFT->get_label();
1824  m_xAuthFieldsLB->make_sorted();
1825  m_xTokenWIN->SetTabPage(this);
1826 
1827  aLastTOXType.eType = TOXTypes(USHRT_MAX);
1828  aLastTOXType.nIndex = 0;
1829 
1831  m_xEntryNoPB->connect_clicked(LINK(this, SwTOXEntryTabPage, InsertTokenHdl));
1832  m_xEntryPB->connect_clicked(LINK(this, SwTOXEntryTabPage, InsertTokenHdl));
1833  m_xChapterInfoPB->connect_clicked(LINK(this, SwTOXEntryTabPage, InsertTokenHdl));
1834  m_xPageNoPB->connect_clicked(LINK(this, SwTOXEntryTabPage, InsertTokenHdl));
1835  m_xTabPB->connect_clicked(LINK(this, SwTOXEntryTabPage, InsertTokenHdl));
1836  m_xHyperLinkPB->connect_clicked(LINK(this, SwTOXEntryTabPage, InsertTokenHdl));
1837  m_xEditStylePB->connect_clicked(LINK(this, SwTOXEntryTabPage, EditStyleHdl));
1838  m_xLevelLB->connect_changed(LINK(this, SwTOXEntryTabPage, LevelHdl));
1839  m_xTokenWIN->SetButtonSelectedHdl(LINK(this, SwTOXEntryTabPage, TokenSelectedHdl));
1840  m_xTokenWIN->SetModifyHdl(LINK(this, SwTOXEntryTabPage, ModifyHdl));
1841  m_xCharStyleLB->connect_changed(LINK(this, SwTOXEntryTabPage, StyleSelectHdl));
1842  m_xCharStyleLB->append_text(sNoCharStyle);
1843  m_xChapterEntryLB->connect_changed(LINK(this, SwTOXEntryTabPage, ChapterInfoHdl));
1844  m_xEntryOutlineLevelNF->connect_value_changed(LINK(this, SwTOXEntryTabPage, ChapterInfoOutlineHdl));
1845  m_xNumberFormatLB->connect_changed(LINK(this, SwTOXEntryTabPage, NumberFormatHdl));
1846 
1847  m_xTabPosMF->connect_value_changed(LINK(this, SwTOXEntryTabPage, TabPosHdl));
1848  m_xFillCharCB->connect_changed(LINK(this, SwTOXEntryTabPage, FillCharHdl));
1849  m_xAutoRightCB->connect_toggled(LINK(this, SwTOXEntryTabPage, AutoRightHdl));
1850  m_xAuthInsertPB->connect_clicked(LINK(this, SwTOXEntryTabPage, RemoveInsertAuthHdl));
1851  m_xAuthRemovePB->connect_clicked(LINK(this, SwTOXEntryTabPage, RemoveInsertAuthHdl));
1852  m_xSortDocPosRB->connect_toggled(LINK(this, SwTOXEntryTabPage, SortKeyHdl));
1853  m_xSortContentRB->connect_toggled(LINK(this, SwTOXEntryTabPage, SortKeyHdl));
1854  m_xAllLevelsPB->connect_clicked(LINK(this, SwTOXEntryTabPage, AllLevelsHdl));
1855 
1856  m_xAlphaDelimCB->connect_toggled(LINK(this, SwTOXEntryTabPage, ModifyClickHdl));
1857  m_xCommaSeparatedCB->connect_toggled(LINK(this, SwTOXEntryTabPage, ModifyClickHdl));
1858  m_xRelToStyleCB->connect_toggled(LINK(this, SwTOXEntryTabPage, ModifyClickHdl));
1859 
1860  FieldUnit aMetric = ::GetDfltMetric(false);
1861  ::SetFieldUnit(*m_xTabPosMF, aMetric);
1862 
1863  m_xSortDocPosRB->set_active(true);
1864 
1865  m_xFillCharCB->set_entry_max_length(1);
1866  m_xFillCharCB->append_text(OUString(' '));
1867  m_xFillCharCB->append_text(OUString('.'));
1868  m_xFillCharCB->append_text(OUString('-'));
1869  m_xFillCharCB->append_text(OUString('_'));
1870  m_xFillCharCB->append_text(OUString(u'\x2024')); // ONE DOT LEADER
1871  m_xFillCharCB->append_text(OUString(u'\x2025')); // TWO DOT LEADER
1872  m_xFillCharCB->append_text(OUString(u'\x2026')); // HORIZONTAL ELLIPSIS
1873 
1874  m_xEditStylePB->set_sensitive(false);
1875 
1876  //fill the types in
1877  for (sal_uInt16 i = 0; i < AUTH_FIELD_END; ++i)
1878  {
1879  OUString sId(OUString::number(i));
1880  m_xAuthFieldsLB->append(sId, SwResId(STR_AUTH_FIELD_ARY[i]));
1881  }
1882 
1883  m_xFirstKeyLB->append(OUString::number(USHRT_MAX), sNoCharSortKey);
1884  m_xSecondKeyLB->append(OUString::number(USHRT_MAX), sNoCharSortKey);
1885  m_xThirdKeyLB->append(OUString::number(USHRT_MAX), sNoCharSortKey);
1886 
1887  for (sal_uInt16 i = 0; i < AUTH_FIELD_END; ++i)
1888  {
1889  const OUString sTmp(m_xAuthFieldsLB->get_text(i));
1890  const OUString sEntryData(m_xAuthFieldsLB->get_id(i));
1891  m_xFirstKeyLB->append(sEntryData, sTmp);
1892  m_xSecondKeyLB->append(sEntryData, sTmp);
1893  m_xThirdKeyLB->append(sEntryData, sTmp);
1894  }
1895  m_xFirstKeyLB->set_active(0);
1896  m_xSecondKeyLB->set_active(0);
1897  m_xThirdKeyLB->set_active(0);
1898 
1899  //lock size
1900  Size aPrefSize(m_xContainer->get_preferred_size());
1901  m_xContainer->set_size_request(aPrefSize.Width(), aPrefSize.Height());
1902 }
1903 
1905 {
1906  m_xTokenWIN.reset();
1907 }
1908 
1910 {
1911  OnModify(true);
1912 }
1913 
1915 {
1916  OnModify(false);
1917 }
1918 
1919 // bAllLevels is used as signal to change all levels of the example
1920 void SwTOXEntryTabPage::OnModify(bool bAllLevels)
1921 {
1922  UpdateDescriptor();
1923 
1924  SwMultiTOXTabDialog* pTOXDlg = static_cast<SwMultiTOXTabDialog*>(GetDialogController());
1925  if (pTOXDlg)
1926  {
1927  sal_uInt16 nCurLevel = m_xLevelLB->get_selected_index() + 1;
1928  if (aLastTOXType.eType == TOX_CONTENT && bAllLevels)
1929  nCurLevel = USHRT_MAX;
1930  pTOXDlg->CreateOrUpdateExample(
1931  pTOXDlg->GetCurrentTOXType().eType, TOX_PAGE_ENTRY, nCurLevel);
1932  }
1933 }
1934 
1936 {
1937  // nothing to do
1938  return true;
1939 }
1940 
1942 {
1943  SwMultiTOXTabDialog* pTOXDlg = static_cast<SwMultiTOXTabDialog*>(GetDialogController());
1944  const CurTOXType aCurType = pTOXDlg->GetCurrentTOXType();
1945  m_pCurrentForm = pTOXDlg->GetForm(aCurType);
1946  if(TOX_INDEX == aCurType.eType)
1947  {
1948  SwTOXDescription& rDesc = pTOXDlg->GetTOXDescription(aCurType);
1949  const OUString& sMainEntryCharStyle = rDesc.GetMainEntryCharStyle();
1950  if(!sMainEntryCharStyle.isEmpty())
1951  {
1952  if (m_xMainEntryStyleLB->find_text(sMainEntryCharStyle) == -1)
1953  m_xMainEntryStyleLB->append_text(sMainEntryCharStyle);
1954  m_xMainEntryStyleLB->set_active_text(sMainEntryCharStyle);
1955  }
1956  else
1957  m_xMainEntryStyleLB->set_active_text(sNoCharStyle);
1958  m_xAlphaDelimCB->set_active( bool(rDesc.GetIndexOptions() & SwTOIOptions::AlphaDelimiter) );
1959  }
1960  m_xRelToStyleCB->set_active(m_pCurrentForm->IsRelTabPos());
1962 }
1963 
1965 {
1966  SwMultiTOXTabDialog* pTOXDlg = static_cast<SwMultiTOXTabDialog*>(GetDialogController());
1967  const CurTOXType aCurType = pTOXDlg->GetCurrentTOXType();
1968 
1969  m_pCurrentForm = pTOXDlg->GetForm(aCurType);
1970  if( !( aLastTOXType == aCurType ))
1971  {
1972  bool bToxIsAuthorities = TOX_AUTHORITIES == aCurType.eType;
1973  bool bToxIsIndex = TOX_INDEX == aCurType.eType;
1974  bool bToxIsContent = TOX_CONTENT == aCurType.eType;
1975  bool bToxSupportsLinks = TOX_CONTENT == aCurType.eType ||
1976  TOX_ILLUSTRATIONS == aCurType.eType ||
1977  TOX_TABLES == aCurType.eType ||
1978  TOX_OBJECTS == aCurType.eType ||
1979  TOX_USER == aCurType.eType;
1980 
1981  m_xLevelLB->clear();
1982  for(sal_uInt16 i = 1; i < m_pCurrentForm->GetFormMax(); i++)
1983  {
1984  if(bToxIsAuthorities)
1986  static_cast<ToxAuthorityType>(i - 1)) );
1987  else if( bToxIsIndex )
1988  {
1989  if(i == 1)
1990  m_xLevelLB->append_text( sDelimStr );
1991  else
1992  m_xLevelLB->append_text( OUString::number(i - 1) );
1993  }
1994  else
1995  m_xLevelLB->append_text(OUString::number(i));
1996  }
1997  if(bToxIsAuthorities)
1998  {
1999  SwWrtShell& rSh = pTOXDlg->GetWrtShell();
2000  const SwAuthorityFieldType* pFType = static_cast<const SwAuthorityFieldType*>(
2001  rSh.GetFieldType(SwFieldIds::TableOfAuthorities, OUString()));
2002  if(pFType)
2003  {
2004  if(pFType->IsSortByDocument())
2005  m_xSortDocPosRB->set_active(true);
2006  else
2007  {
2008  m_xSortContentRB->set_active(true);
2009  const sal_uInt16 nKeyCount = pFType->GetSortKeyCount();
2010  if(0 < nKeyCount)
2011  {
2012  const SwTOXSortKey* pKey = pFType->GetSortKey(0);
2013  m_xFirstKeyLB->set_active_id(OUString::number(pKey->eField));
2014  m_xFirstSortUpRB->set_active(pKey->bSortAscending);
2015  m_xFirstSortDownRB->set_active(!pKey->bSortAscending);
2016  }
2017  if(1 < nKeyCount)
2018  {
2019  const SwTOXSortKey* pKey = pFType->GetSortKey(1);
2020  m_xSecondKeyLB->set_active_id(OUString::number(pKey->eField));
2021  m_xSecondSortUpRB->set_active(pKey->bSortAscending);
2022  m_xSecondSortDownRB->set_active(!pKey->bSortAscending);
2023  }
2024  if(2 < nKeyCount)
2025  {
2026  const SwTOXSortKey* pKey = pFType->GetSortKey(2);
2027  m_xThirdKeyLB->set_active_id(OUString::number(pKey->eField));
2028  m_xThirdSortUpRB->set_active(pKey->bSortAscending);
2029  m_xThirdSortDownRB->set_active(!pKey->bSortAscending);
2030  }
2031  }
2032  }
2033  SortKeyHdl(m_xSortDocPosRB->get_active() ? *m_xSortDocPosRB : *m_xSortContentRB);
2034  m_xLevelFT->set_label(sAuthTypeStr);
2035  }
2036  else
2037  m_xLevelFT->set_label(sLevelStr);
2038 
2039  m_xLevelLB->select(bToxIsIndex ? 1 : 0);
2040 
2041  //show or hide controls
2042  m_xEntryNoPB->set_visible(bToxIsContent);
2043  m_xHyperLinkPB->set_visible(bToxSupportsLinks);
2044  m_xRelToStyleCB->set_visible(!bToxIsAuthorities);
2045  m_xChapterInfoPB->set_visible(!bToxIsContent && !bToxIsAuthorities);
2046  m_xEntryPB->set_visible(!bToxIsAuthorities);
2047  m_xPageNoPB->set_visible(!bToxIsAuthorities);
2048  m_xAuthFieldsLB->set_visible(bToxIsAuthorities);
2049  m_xAuthInsertPB->set_visible(bToxIsAuthorities);
2050  m_xAuthRemovePB->set_visible(bToxIsAuthorities);
2051 
2052  m_xFormatFrame->set_visible(!bToxIsAuthorities);
2053 
2054  m_xSortingFrame->set_visible(bToxIsAuthorities);
2055  m_xSortKeyFrame->set_visible(bToxIsAuthorities);
2056 
2057  m_xMainEntryStyleFT->set_visible(bToxIsIndex);
2058  m_xMainEntryStyleLB->set_visible(bToxIsIndex);
2059  m_xAlphaDelimCB->set_visible(bToxIsIndex);
2060  m_xCommaSeparatedCB->set_visible(bToxIsIndex);
2061  }
2062  aLastTOXType = aCurType;
2063 
2064  //invalidate PatternWindow
2065  m_xTokenWIN->SetInvalid();
2066  LevelHdl(*m_xLevelLB);
2067 }
2068 
2070 {
2071  WriteBackLevel();
2072  SwMultiTOXTabDialog* pTOXDlg = static_cast<SwMultiTOXTabDialog*>(GetDialogController());
2073  SwTOXDescription& rDesc = pTOXDlg->GetTOXDescription(aLastTOXType);
2075  {
2076  const OUString sTemp(m_xMainEntryStyleLB->get_active_text());
2077  rDesc.SetMainEntryCharStyle(sNoCharStyle == sTemp ? OUString(): sTemp);
2079  if (m_xAlphaDelimCB->get_active())
2080  nIdxOptions |= SwTOIOptions::AlphaDelimiter;
2081  rDesc.SetIndexOptions(nIdxOptions);
2082  }
2083  else if (TOX_AUTHORITIES == aLastTOXType.eType)
2084  {
2085  rDesc.SetSortByDocument(m_xSortDocPosRB->get_active());
2086  SwTOXSortKey aKey1, aKey2, aKey3;
2087  aKey1.eField = static_cast<ToxAuthorityField>(m_xFirstKeyLB->get_active_id().toInt32());
2088  aKey1.bSortAscending = m_xFirstSortUpRB->get_active();
2089  aKey2.eField = static_cast<ToxAuthorityField>(m_xSecondKeyLB->get_active_id().toInt32());
2090  aKey2.bSortAscending = m_xSecondSortUpRB->get_active();
2091  aKey3.eField = static_cast<ToxAuthorityField>(m_xThirdKeyLB->get_active_id().toInt32());
2092  aKey3.bSortAscending = m_xThirdSortUpRB->get_active();
2093 
2094  rDesc.SetSortKeys(aKey1, aKey2, aKey3);
2095  }
2096  SwForm* pCurrentForm = pTOXDlg->GetForm(aLastTOXType);
2097  if (m_xRelToStyleCB->get_visible())
2098  pCurrentForm->SetRelTabPos(m_xRelToStyleCB->get_active());
2099  if (m_xCommaSeparatedCB->get_visible())
2100  pCurrentForm->SetCommaSeparated(m_xCommaSeparatedCB->get_active());
2101 }
2102 
2104 {
2105  UpdateDescriptor();
2106  return DeactivateRC::LeavePage;
2107 }
2108 
2109 std::unique_ptr<SfxTabPage> SwTOXEntryTabPage::Create(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet* rAttrSet)
2110 {
2111  return std::make_unique<SwTOXEntryTabPage>(pPage, pController, *rAttrSet);
2112 }
2113 
2115 {
2116  if (m_xCharStyleLB->get_active() != -1)
2117  {
2118  SfxStringItem aStyle(SID_STYLE_EDIT, m_xCharStyleLB->get_active_text());
2119  SfxUInt16Item aFamily(SID_STYLE_FAMILY, sal_uInt16(SfxStyleFamily::Char));
2120  static_cast<SwMultiTOXTabDialog*>(GetDialogController())->GetWrtShell().
2121  GetView().GetViewFrame()->GetDispatcher()->ExecuteList(SID_STYLE_EDIT,
2122  SfxCallMode::SYNCHRON,
2123  { &aStyle, &aFamily });
2124  }
2125 }
2126 
2127 IMPL_LINK(SwTOXEntryTabPage, RemoveInsertAuthHdl, weld::Button&, rButton, void)
2128 {
2129  bool bInsert = &rButton == m_xAuthInsertPB.get();
2130  if(bInsert)
2131  {
2132  sal_Int32 nSelPos = m_xAuthFieldsLB->get_active();
2133  const OUString sToInsert(m_xAuthFieldsLB->get_active_text());
2134  SwFormToken aInsert(TOKEN_AUTHORITY);
2135  aInsert.nAuthorityField = m_xAuthFieldsLB->get_id(nSelPos).toUInt32();
2136  m_xTokenWIN->InsertAtSelection(aInsert);
2137  m_xAuthFieldsLB->remove_text(sToInsert);
2138  m_xAuthFieldsLB->set_active(nSelPos ? nSelPos - 1 : 0);
2139  }
2140  else
2141  {
2142  SwTOXWidget* pCtrl = m_xTokenWIN->GetActiveControl();
2143  OSL_ENSURE(WindowType::EDIT != pCtrl->GetType(), "Remove should be disabled");
2144  if (WindowType::EDIT != pCtrl->GetType())
2145  {
2146  //fill it into the ListBox
2147  const SwFormToken& rToken = static_cast<SwTOXButton*>(pCtrl)->GetFormToken();
2148  PreTokenButtonRemoved(rToken);
2149  m_xTokenWIN->RemoveControl(static_cast<SwTOXButton*>(pCtrl));
2150  }
2151  }
2152  ModifyHdl(nullptr);
2153 }
2154 
2156 {
2157  //fill it into the ListBox
2158  sal_uInt32 nData = rToken.nAuthorityField;
2159  m_xAuthFieldsLB->append(OUString::number(nData), SwResId(STR_AUTH_FIELD_ARY[nData]));
2160 }
2161 
2163 {
2164  m_xAllLevelsPB->grab_focus();
2165 }
2166 
2167 // This function initializes the default value in the Token
2168 // put here the UI dependent initializations
2169 IMPL_LINK(SwTOXEntryTabPage, InsertTokenHdl, weld::Button&, rBtn, void)
2170 {
2171  FormTokenType eTokenType = TOKEN_ENTRY_NO;
2172  OUString sCharStyle;
2173  sal_uInt16 nChapterFormat = CF_NUMBER; // i89791
2174  if (&rBtn == m_xEntryNoPB.get())
2175  {
2176  eTokenType = TOKEN_ENTRY_NO;
2177  }
2178  else if (&rBtn == m_xEntryPB.get())
2179  {
2180  if( TOX_CONTENT == m_pCurrentForm->GetTOXType() )
2181  {
2182  eTokenType = TOKEN_ENTRY_TEXT;
2183  }
2184  else
2185  {
2186  eTokenType = TOKEN_ENTRY;
2187  }
2188  }
2189  else if (&rBtn == m_xChapterInfoPB.get())
2190  {
2191  eTokenType = TOKEN_CHAPTER_INFO;
2192  nChapterFormat = CF_NUM_NOPREPST_TITLE; // i89791
2193  }
2194  else if (&rBtn == m_xPageNoPB.get())
2195  {
2196  eTokenType = TOKEN_PAGE_NUMS;
2197  }
2198  else if (&rBtn == m_xHyperLinkPB.get())
2199  {
2200  eTokenType = TOKEN_LINK_START;
2201  sCharStyle = SwResId(STR_POOLCHR_TOXJUMP);
2202  }
2203  else if (&rBtn == m_xTabPB.get())
2204  {
2205  eTokenType = TOKEN_TAB_STOP;
2206  }
2207  SwFormToken aInsert(eTokenType);
2208  aInsert.sCharStyleName = sCharStyle;
2209  aInsert.nTabStopPosition = 0;
2210  aInsert.nChapterFormat = nChapterFormat; // i89791
2211  m_xTokenWIN->InsertAtSelection(aInsert);
2212  ModifyHdl(nullptr);
2213 }
2214 
2216 {
2217  //get current level
2218  //write it into all levels
2219  if(m_xTokenWIN->IsValid())
2220  {
2221  const OUString sNewToken = m_xTokenWIN->GetPattern();
2222  for(sal_uInt16 i = 1; i < m_pCurrentForm->GetFormMax(); i++)
2223  m_pCurrentForm->SetPattern(i, sNewToken);
2224 
2225  OnModify(true);
2226  }
2227 }
2228 
2230 {
2231  if(m_xTokenWIN->IsValid())
2232  {
2233  const OUString sNewToken = m_xTokenWIN->GetPattern();
2234  const sal_uInt16 nLastLevel = m_xTokenWIN->GetLastLevel();
2235  if(nLastLevel != USHRT_MAX)
2236  m_pCurrentForm->SetPattern(nLastLevel + 1, sNewToken);
2237  }
2238 }
2239 
2241 {
2242  if(bInLevelHdl)
2243  return;
2244  bInLevelHdl = true;
2245  WriteBackLevel();
2246 
2247  const sal_uInt16 nLevel = rBox.get_selected_index();
2248  m_xTokenWIN->SetForm(*m_pCurrentForm, nLevel);
2249  if(TOX_AUTHORITIES == m_pCurrentForm->GetTOXType())
2250  {
2251  //fill the types in
2252  m_xAuthFieldsLB->clear();
2253  for( sal_uInt32 i = 0; i < AUTH_FIELD_END; i++)
2254  {
2255  m_xAuthFieldsLB->append(OUString::number(i), SwResId(STR_AUTH_FIELD_ARY[i]));
2256  }
2257 
2258  // #i21237#
2259  SwFormTokens aPattern = m_pCurrentForm->GetPattern(nLevel + 1);
2260 
2261  for(const auto& aToken : aPattern)
2262  {
2263  if(TOKEN_AUTHORITY == aToken.eTokenType)
2264  {
2265  sal_uInt32 nSearch = aToken.nAuthorityField;
2266  int nLstBoxPos = m_xAuthFieldsLB->find_id(OUString::number(nSearch));
2267  OSL_ENSURE(nLstBoxPos != -1, "Entry not found?");
2268  m_xAuthFieldsLB->remove(nLstBoxPos);
2269  }
2270  }
2271  m_xAuthFieldsLB->set_active(0);
2272  }
2273  bInLevelHdl = false;
2274  rBox.grab_focus();
2275 }
2276 
2278 {
2279  bool bEnable = m_xSortContentRB->get_active();
2280  m_xSortKeyFrame->set_sensitive(bEnable);
2281 }
2282 
2283 IMPL_LINK(SwTOXEntryTabPage, TokenSelectedHdl, SwFormToken&, rToken, void)
2284 {
2285  if (!rToken.sCharStyleName.isEmpty())
2286  m_xCharStyleLB->set_active_text(rToken.sCharStyleName);
2287  else
2288  m_xCharStyleLB->set_active_text(sNoCharStyle);
2289 
2290  const OUString sEntry = m_xCharStyleLB->get_active_text();
2291  m_xEditStylePB->set_sensitive(sEntry != sNoCharStyle);
2292 
2293  if(rToken.eTokenType == TOKEN_CHAPTER_INFO)
2294  {
2295 //---> i89791
2296  switch(rToken.nChapterFormat)
2297  {
2298  default:
2299  m_xChapterEntryLB->set_active(-1);//to alert the user
2300  break;
2301  case CF_NUM_NOPREPST_TITLE:
2302  m_xChapterEntryLB->set_active(0);
2303  break;
2304  case CF_TITLE:
2305  m_xChapterEntryLB->set_active(1);
2306  break;
2307  case CF_NUMBER_NOPREPST:
2308  m_xChapterEntryLB->set_active(2);
2309  break;
2310  }
2311 //i53420
2312 
2313  m_xEntryOutlineLevelNF->set_value(rToken.nOutlineLevel);
2314  }
2315 
2316 //i53420
2317  if(rToken.eTokenType == TOKEN_ENTRY_NO)
2318  {
2319  m_xEntryOutlineLevelNF->set_value(rToken.nOutlineLevel);
2320  const sal_uInt16 nFormat =
2321  rToken.nChapterFormat == CF_NUM_NOPREPST_TITLE ? 1 : 0;
2322  m_xNumberFormatLB->set_active(nFormat);
2323  }
2324 
2325  bool bTabStop = TOKEN_TAB_STOP == rToken.eTokenType;
2326  m_xFillCharFT->set_visible(bTabStop);
2327  m_xFillCharCB->set_visible(bTabStop);
2328  m_xTabPosFT->set_visible(bTabStop);
2329  m_xTabPosMF->set_visible(bTabStop);
2330  m_xAutoRightCB->set_visible(bTabStop);
2331  m_xAutoRightCB->set_sensitive(bTabStop);
2332  if(bTabStop)
2333  {
2334  m_xTabPosMF->set_value(m_xTabPosMF->normalize(rToken.nTabStopPosition), FieldUnit::TWIP);
2335  m_xAutoRightCB->set_active(SvxTabAdjust::End == rToken.eTabAlign);
2336  m_xFillCharCB->set_entry_text(OUString(rToken.cTabFillChar));
2337  m_xTabPosFT->set_sensitive(!m_xAutoRightCB->get_active());
2338  m_xTabPosMF->set_sensitive(!m_xAutoRightCB->get_active());
2339  }
2340  else
2341  {
2342  m_xTabPosMF->set_sensitive(false);
2343  }
2344 
2345  bool bIsChapterInfo = rToken.eTokenType == TOKEN_CHAPTER_INFO;
2346  bool bIsEntryNumber = rToken.eTokenType == TOKEN_ENTRY_NO;
2347  m_xChapterEntryFT->set_visible( bIsChapterInfo );
2348  m_xChapterEntryLB->set_visible( bIsChapterInfo );
2349  m_xEntryOutlineLevelFT->set_visible( bIsChapterInfo || bIsEntryNumber );
2350  m_xEntryOutlineLevelNF->set_visible( bIsChapterInfo || bIsEntryNumber );
2351  m_xNumberFormatFT->set_visible( bIsEntryNumber );
2352  m_xNumberFormatLB->set_visible( bIsEntryNumber );
2353 
2354  //now enable the visible buttons
2355  //- inserting the same type of control is not allowed
2356  //- some types of controls can only appear once (EntryText EntryNumber)
2357 
2358  if (m_xEntryNoPB->get_visible())
2359  {
2360  m_xEntryNoPB->set_sensitive(TOKEN_ENTRY_NO != rToken.eTokenType );
2361  }
2362  if (m_xEntryPB->get_visible())
2363  {
2364  m_xEntryPB->set_sensitive(TOKEN_ENTRY_TEXT != rToken.eTokenType &&
2365  !m_xTokenWIN->Contains(TOKEN_ENTRY_TEXT)
2366  && !m_xTokenWIN->Contains(TOKEN_ENTRY));
2367  }
2368 
2369  if (m_xChapterInfoPB->get_visible())
2370  {
2371  m_xChapterInfoPB->set_sensitive(TOKEN_CHAPTER_INFO != rToken.eTokenType);
2372  }
2373  if (m_xPageNoPB->get_visible())
2374  {
2375  m_xPageNoPB->set_sensitive(TOKEN_PAGE_NUMS != rToken.eTokenType &&
2376  !m_xTokenWIN->Contains(TOKEN_PAGE_NUMS));
2377  }
2378  if (m_xTabPB->get_visible())
2379  {
2380  m_xTabPB->set_sensitive(!bTabStop);
2381  }
2382  if (m_xHyperLinkPB->get_visible())
2383  {
2384  m_xHyperLinkPB->set_sensitive(TOKEN_LINK_START != rToken.eTokenType &&
2385  TOKEN_LINK_END != rToken.eTokenType);
2386  }
2387  //table of authorities
2388  if (m_xAuthInsertPB->get_visible())
2389  {
2390  bool bText = TOKEN_TEXT == rToken.eTokenType;
2391  m_xAuthInsertPB->set_sensitive(bText && !m_xAuthFieldsLB->get_active_text().isEmpty());
2392  m_xAuthRemovePB->set_sensitive(!bText);
2393  }
2394 }
2395 
2396 IMPL_LINK(SwTOXEntryTabPage, StyleSelectHdl, weld::ComboBox&, rBox, void)
2397 {
2398  OUString sEntry = rBox.get_active_text();
2399  const sal_uInt16 nId = rBox.get_active_id().toUInt32();
2400  const bool bEqualsNoCharStyle = sEntry == sNoCharStyle;
2401  m_xEditStylePB->set_sensitive(!bEqualsNoCharStyle);
2402  if (bEqualsNoCharStyle)
2403  sEntry.clear();
2404  SwTOXWidget* pCtrl = m_xTokenWIN->GetActiveControl();
2405  OSL_ENSURE(pCtrl, "no active control?");
2406  if(pCtrl)
2407  {
2408  if(WindowType::EDIT == pCtrl->GetType())
2409  static_cast<SwTOXEdit*>(pCtrl)->SetCharStyleName(sEntry, nId);
2410  else
2411  static_cast<SwTOXButton*>(pCtrl)->SetCharStyleName(sEntry, nId);
2412 
2413  }
2414  ModifyHdl(nullptr);
2415 }
2416 
2417 IMPL_LINK(SwTOXEntryTabPage, ChapterInfoHdl, weld::ComboBox&, rBox, void)
2418 {
2419  int nPos = rBox.get_active();
2420  if (nPos != -1)
2421  {
2422  SwTOXWidget* pCtrl = m_xTokenWIN->GetActiveControl();
2423  OSL_ENSURE(pCtrl, "no active control?");
2424  if(pCtrl && WindowType::EDIT != pCtrl->GetType())
2425  static_cast<SwTOXButton*>(pCtrl)->SetChapterInfo(nPos);
2426  ModifyHdl(nullptr);
2427  }
2428 }
2429 
2430 IMPL_LINK(SwTOXEntryTabPage, ChapterInfoOutlineHdl, weld::SpinButton&, rEdit, void)
2431 {
2432  const sal_uInt16 nLevel = rEdit.get_value();
2433 
2434  SwTOXWidget* pCtrl = m_xTokenWIN->GetActiveControl();
2435  OSL_ENSURE(pCtrl, "no active control?");
2436  if(pCtrl && WindowType::EDIT != pCtrl->GetType())
2437  static_cast<SwTOXButton*>(pCtrl)->SetOutlineLevel(nLevel);
2438 
2439  ModifyHdl(nullptr);
2440 }
2441 
2442 IMPL_LINK(SwTOXEntryTabPage, NumberFormatHdl, weld::ComboBox&, rBox, void)
2443 {
2444  const sal_Int32 nPos = rBox.get_active();
2445  if (nPos != -1)
2446  {
2447  SwTOXWidget* pCtrl = m_xTokenWIN->GetActiveControl();
2448  OSL_ENSURE(pCtrl, "no active control?");
2449  if(pCtrl && WindowType::EDIT != pCtrl->GetType())
2450  {
2451  static_cast<SwTOXButton*>(pCtrl)->SetEntryNumberFormat(nPos);//i89791
2452  }
2453  ModifyHdl(nullptr);
2454  }
2455 }
2456 
2458 {
2459  SwTOXWidget* pCtrl = m_xTokenWIN->GetActiveControl();
2460  OSL_ENSURE(pCtrl && WindowType::EDIT != pCtrl->GetType() &&
2461  TOKEN_TAB_STOP == static_cast<SwTOXButton*>(pCtrl)->GetFormToken().eTokenType,
2462  "no active style::TabStop control?");
2463  if( pCtrl && WindowType::EDIT != pCtrl->GetType() )
2464  {
2465  static_cast<SwTOXButton*>(pCtrl)->SetTabPosition( static_cast< SwTwips >(
2466  rEdit.denormalize(rEdit.get_value(FieldUnit::TWIP))));
2467  }
2468  ModifyHdl(nullptr);
2469 }
2470 
2471 IMPL_LINK(SwTOXEntryTabPage, FillCharHdl, weld::ComboBox&, rBox, void)
2472 {
2473  SwTOXWidget* pCtrl = m_xTokenWIN->GetActiveControl();
2474  OSL_ENSURE(pCtrl && WindowType::EDIT != pCtrl->GetType() &&
2475  TOKEN_TAB_STOP == static_cast<SwTOXButton*>(pCtrl)->GetFormToken().eTokenType,
2476  "no active style::TabStop control?");
2477  if (pCtrl && WindowType::EDIT != pCtrl->GetType())
2478  {
2479  sal_Unicode cSet;
2480  if (!rBox.get_active_text().isEmpty())
2481  cSet = rBox.get_active_text()[0];
2482  else
2483  cSet = ' ';
2484  static_cast<SwTOXButton*>(pCtrl)->SetFillChar( cSet );
2485  }
2486  ModifyHdl(nullptr);
2487 }
2488 
2489 IMPL_LINK(SwTOXEntryTabPage, AutoRightHdl, weld::Toggleable&, rBox, void)
2490 {
2491  //the most right style::TabStop is usually right aligned
2492  SwTOXWidget* pCurCtrl = m_xTokenWIN->GetActiveControl();
2493  OSL_ENSURE(WindowType::EDIT != pCurCtrl->GetType() &&
2494  static_cast<SwTOXButton*>(pCurCtrl)->GetFormToken().eTokenType == TOKEN_TAB_STOP,
2495  "no style::TabStop selected!");
2496 
2497  const SwFormToken& rToken = static_cast<SwTOXButton*>(pCurCtrl)->GetFormToken();
2498  bool bChecked = rBox.get_active();
2499  if(rToken.eTokenType == TOKEN_TAB_STOP)
2500  static_cast<SwTOXButton*>(pCurCtrl)->SetTabAlign(
2501  bChecked ? SvxTabAdjust::End : SvxTabAdjust::Left);
2502  m_xTabPosFT->set_sensitive(!bChecked);
2503  m_xTabPosMF->set_sensitive(!bChecked);
2504  ModifyHdl(nullptr);
2505 }
2506 
2508 {
2509  SwDocShell* pDocSh = rSh.GetView().GetDocShell();
2510  ::FillCharStyleListBox(*m_xCharStyleLB, pDocSh, true, true);
2511  const OUString sDefault(SwResId(STR_POOLCHR_STANDARD));
2512  for (int i = 0, nCount = m_xCharStyleLB->get_count(); i < nCount; ++i)
2513  {
2514  const OUString sEntry = m_xCharStyleLB->get_text(i);
2515  if(sDefault != sEntry)
2516  {
2517  m_xMainEntryStyleLB->append(m_xCharStyleLB->get_id(i), sEntry);
2518  }
2519  }
2521  RES_POOLCHR_IDX_MAIN_ENTRY, OUString()));
2522 }
2523 
2524 static const char* STR_TOKEN_ARY[] =
2525 {
2526  STR_TOKEN_ENTRY_NO,
2527  STR_TOKEN_ENTRY, //mapped from original STR_TOKEN_ENTRY_TEXT,
2528  STR_TOKEN_ENTRY,
2529  STR_TOKEN_TAB_STOP,
2530  nullptr,
2531  STR_TOKEN_PAGE_NUMS,
2532  STR_TOKEN_CHAPTER_INFO,
2533  STR_TOKEN_LINK_START,
2534  STR_TOKEN_LINK_END,
2535  STR_TOKEN_AUTHORITY
2536 };
2537 
2538 static const char* STR_TOKEN_HELP_ARY[] =
2539 {
2540  STR_TOKEN_HELP_ENTRY_NO,
2541  STR_TOKEN_HELP_ENTRY, // mapped from original STR_TOKEN_HELP_ENTRY_TEXT,
2542  STR_TOKEN_HELP_ENTRY,
2543  STR_TOKEN_HELP_TAB_STOP,
2544  STR_TOKEN_HELP_TEXT,
2545  STR_TOKEN_HELP_PAGE_NUMS,
2546  STR_TOKEN_HELP_CHAPTER_INFO,
2547  STR_TOKEN_HELP_LINK_START,
2548  STR_TOKEN_HELP_LINK_END,
2549  STR_TOKEN_HELP_AUTHORITY
2550 };
2551 
2552 SwTokenWindow::SwTokenWindow(std::unique_ptr<weld::Container> xParent)
2553  : m_pForm(nullptr)
2554  , m_nLevel(0)
2555  , m_bValid(false)
2556  , m_sCharStyle(SwResId(STR_CHARSTYLE))
2557  , m_pActiveCtrl(nullptr)
2558  , m_pParent(nullptr)
2559  , m_xParentWidget(std::move(xParent))
2560  , m_xBuilder(Application::CreateBuilder(m_xParentWidget.get(), "modules/swriter/ui/tokenwidget.ui"))
2561  , m_xContainer(m_xBuilder->weld_container("TokenWidget"))
2562  , m_xLeftScrollWin(m_xBuilder->weld_button("left"))
2563  , m_xCtrlParentWin(m_xBuilder->weld_container("ctrl"))
2564  , m_xScrollWin(m_xBuilder->weld_scrolled_window("scrollwin"))
2565  , m_xRightScrollWin(m_xBuilder->weld_button("right"))
2566 {
2567  m_xScrollWin->connect_hadjustment_changed(LINK(this, SwTokenWindow, ScrollHdl));
2568  m_xCtrlParentWin->connect_size_allocate(LINK(this, SwTokenWindow, AdjustPositionsHdl));
2569 
2570  for (sal_uInt32 i = 0; i < TOKEN_END; ++i)
2571  {
2572  const char* pTextId = STR_TOKEN_ARY[i];
2573  if (pTextId)
2574  m_aButtonTexts[i] = SwResId(pTextId);
2575 
2576  const char* pHelpId = STR_TOKEN_HELP_ARY[i];
2577  m_aButtonHelpTexts[i] = SwResId(pHelpId);
2578  }
2579 
2580  m_sAccessibleName = SwResId(STR_STRUCTURE);
2581  m_sAdditionalAccnameString1 = SwResId(STR_ADDITIONAL_ACCNAME_STRING1);
2582  m_sAdditionalAccnameString2 = SwResId(STR_ADDITIONAL_ACCNAME_STRING2);
2583  m_sAdditionalAccnameString3 = SwResId(STR_ADDITIONAL_ACCNAME_STRING3);
2584 
2585  Link<weld::Button&,void> aLink(LINK(this, SwTokenWindow, ScrollBtnHdl));
2586  m_xLeftScrollWin->connect_clicked(aLink);
2587  m_xRightScrollWin->connect_clicked(aLink);
2588 }
2589 
2591 {
2592 }
2593 
2594 void SwTokenWindow::SetForm(SwForm& rForm, sal_uInt16 nL)
2595 {
2596  SetActiveControl(nullptr);
2597  m_bValid = true;
2598 
2599  if (m_pForm)
2600  {
2601  //apply current level settings to the form
2602  m_aControlList.clear();
2603  }
2604 
2605  m_nLevel = nL;
2606  m_pForm = &rForm;
2607  //now the display
2608  if(m_nLevel < MAXLEVEL || rForm.GetTOXType() == TOX_AUTHORITIES)
2609  {
2610  // #i21237#
2611  SwFormTokens aPattern = m_pForm->GetPattern(m_nLevel + 1);
2612  bool bLastWasText = false; //assure alternating text - code - text
2613 
2614  SwTOXWidget* pSetActiveControl = nullptr;
2615  for (const auto& aToken : aPattern) // #i21237#
2616  {
2617  if(TOKEN_TEXT == aToken.eTokenType)
2618  {
2619  SAL_WARN_IF(bLastWasText, "sw", "text following text is invalid");
2620  SwTOXWidget* pCtrl = InsertItem(aToken.sText, aToken);
2621  bLastWasText = true;
2622  if (!GetActiveControl())
2623  SetActiveControl(pCtrl);
2624  }
2625  else
2626  {
2627  if( !bLastWasText )
2628  {
2629  SwFormToken aTemp(TOKEN_TEXT);
2630  SwTOXWidget* pCtrl = InsertItem(OUString(), aTemp);
2631  if(!pSetActiveControl)
2632  pSetActiveControl = pCtrl;
2633  }
2634 
2635  OUString sForm;
2636  switch( aToken.eTokenType )
2637  {
2638  case TOKEN_ENTRY_NO: sForm = SwForm::GetFormEntryNum(); break;
2639  case TOKEN_ENTRY_TEXT: sForm = SwForm::GetFormEntryText(); break;
2640  case TOKEN_ENTRY: sForm = SwForm::GetFormEntry(); break;
2641  case TOKEN_TAB_STOP: sForm = SwForm::GetFormTab(); break;
2642  case TOKEN_PAGE_NUMS: sForm = SwForm::GetFormPageNums(); break;
2643  case TOKEN_CHAPTER_INFO: sForm = SwForm::GetFormChapterMark(); break;
2644  case TOKEN_LINK_START: sForm = SwForm::GetFormLinkStt(); break;
2645  case TOKEN_LINK_END: sForm = SwForm::GetFormLinkEnd(); break;
2646  case TOKEN_AUTHORITY: sForm = SwForm::GetFormAuth(); break;
2647  default:; //prevent warning
2648  }
2649 
2650  InsertItem( sForm, aToken );
2651  bLastWasText = false;
2652  }
2653  }
2654  if(!bLastWasText)
2655  {
2656  SwFormToken aTemp(TOKEN_TEXT);
2657  SwTOXWidget* pCtrl = InsertItem(OUString(), aTemp);
2658  if(!pSetActiveControl)
2659  pSetActiveControl = pCtrl;
2660  }
2661  SetActiveControl(pSetActiveControl);
2662  }
2663  AdjustScrolling();
2664 }
2665 
2667 {
2668  if (pSet == m_pActiveCtrl)
2669  return;
2670 
2671  m_pActiveCtrl = pSet;
2672  if( !m_pActiveCtrl )
2673  return;
2674 
2676  //it must be a SwTOXEdit
2677  const SwFormToken* pFToken;
2678  if( WindowType::EDIT == m_pActiveCtrl->GetType() )
2679  pFToken = &static_cast<SwTOXEdit*>(m_pActiveCtrl)->GetFormToken();
2680  else
2681  pFToken = &static_cast<SwTOXButton*>(m_pActiveCtrl)->GetFormToken();
2682 
2683  SwFormToken aTemp( *pFToken );
2684  m_aButtonSelectedHdl.Call( aTemp );
2685 }
2686 
2687 SwTOXWidget* SwTokenWindow::InsertItem(const OUString& rText, const SwFormToken& rToken)
2688 {
2689  SwTOXWidget* pRet = nullptr;
2690 
2691  if (TOKEN_TEXT == rToken.eTokenType)
2692  {
2693  SwTOXEdit* pEdit = new SwTOXEdit(this, rToken);
2694  pEdit->set_grid_left_attach(m_aControlList.size());
2695 
2696  m_aControlList.emplace_back(pEdit);
2697 
2698  pEdit->SetText(rText);
2699  sal_uInt32 nIndex = GetControlIndex( TOKEN_TEXT );
2700  OUString strName(m_sAccessibleName + OUString::number(nIndex));
2701  if ( nIndex == 1 )
2702  {
2703  /*Press left or right arrow to choose the structure controls*/
2704  strName += " (" + m_sAdditionalAccnameString2 + ", "
2705  /*Press Ctrl+Alt+A to move focus for more operations*/
2707  /*Press Ctrl+Alt+B to move focus back to the current structure control*/
2709  }
2710  pEdit->SetAccessibleName(strName);
2711  pEdit->AdjustSize();
2712  pEdit->SetModifyHdl(LINK(this, SwTokenWindow, EditResize ));
2713  pEdit->SetPrevNextLink(LINK(this, SwTokenWindow, NextItemHdl));
2714  pEdit->SetGetFocusHdl(LINK(this, SwTokenWindow, TbxFocusHdl));
2715  pEdit->Show();
2716  pRet = pEdit;
2717  }
2718  else
2719  {
2720  SwTOXButton* pButton = new SwTOXButton(this, rToken);
2721  pButton->set_grid_left_attach(m_aControlList.size());
2722 
2723  m_aControlList.emplace_back(pButton);
2724 
2725  pButton->SetPrevNextLink(LINK(this, SwTokenWindow, NextItemBtnHdl));
2726  pButton->SetGetFocusHdl(LINK(this, SwTokenWindow, TbxFocusBtnHdl));
2727 
2728  if(TOKEN_AUTHORITY != rToken.eTokenType)
2729  pButton->SetText(m_aButtonTexts[rToken.eTokenType]);
2730  else
2731  {
2732  //use the first two chars as symbol
2734  static_cast<ToxAuthorityField>(rToken.nAuthorityField)));
2735  pButton->SetText(sTmp.copy(0, 2));
2736  }
2737 
2738  sal_uInt32 nIndex = GetControlIndex( rToken.eTokenType );
2739  OUString sAccName = m_aButtonHelpTexts[rToken.eTokenType];
2740  if ( nIndex )
2741  {
2742  sAccName += " " + OUString::number(nIndex);
2743  }
2744  pButton->SetAccessibleName( sAccName );
2745 
2746  pButton->Show();
2747  pRet = pButton;
2748  }
2749 
2750  return pRet;
2751 }
2752 
2754 {
2755  OSL_ENSURE(m_pActiveCtrl, "no active control!");
2756 
2757  if(!m_pActiveCtrl)
2758  return;
2759 
2760  SwFormToken aToInsertToken(rToken);
2761 
2762  if(TOKEN_LINK_START == aToInsertToken.eTokenType)
2763  {
2764  //determine if start or end of hyperlink is appropriate
2765  //eventually change a following link start into a link end
2766  // groups of LS LE should be ignored
2767  // <insert>
2768  //LS <insert>
2769  //LE <insert>
2770  //<insert> LS
2771  //<insert> LE
2772  //<insert>
2773  bool bPreStartLinkFound = false;
2774  bool bPreEndLinkFound = false;
2775 
2776  const SwTOXWidget* pControl = nullptr;
2777  const SwTOXWidget* pExchange = nullptr;
2778 
2779  auto it = m_aControlList.cbegin();
2780  for( ; it != m_aControlList.cend() && m_pActiveCtrl != it->get(); ++it )
2781  {
2782  pControl = it->get();
2783 
2784  if( WindowType::EDIT != pControl->GetType())
2785  {
2786  const SwFormToken& rNewToken =
2787  static_cast<const SwTOXButton*>(pControl)->GetFormToken();
2788 
2789  if( TOKEN_LINK_START == rNewToken.eTokenType )
2790  {
2791  bPreStartLinkFound = true;
2792  pExchange = nullptr;
2793  }
2794  else if(TOKEN_LINK_END == rNewToken.eTokenType)
2795  {
2796  if( bPreStartLinkFound )
2797  bPreStartLinkFound = false;
2798  else
2799  {
2800  bPreEndLinkFound = false;
2801  pExchange = pControl;
2802  }
2803  }
2804  }
2805  }
2806 
2807  bool bPostLinkStartFound = false;
2808 
2809  if(!bPreStartLinkFound && !bPreEndLinkFound)
2810  {
2811  for( ; it != m_aControlList.cend(); ++it )
2812  {
2813  pControl = it->get();
2814 
2815  if( pControl != m_pActiveCtrl &&
2816  WindowType::EDIT != pControl->GetType())
2817  {
2818  const SwFormToken& rNewToken =
2819  static_cast<const SwTOXButton*>(pControl)->GetFormToken();
2820 
2821  if( TOKEN_LINK_START == rNewToken.eTokenType )
2822  {
2823  if(bPostLinkStartFound)
2824  break;
2825  bPostLinkStartFound = true;
2826  pExchange = pControl;
2827  }
2828  else if(TOKEN_LINK_END == rNewToken.eTokenType )
2829  {
2830  if(bPostLinkStartFound)
2831  {
2832  bPostLinkStartFound = false;
2833  pExchange = nullptr;
2834  }
2835  break;
2836  }
2837  }
2838  }
2839  }
2840 
2841  if(bPreStartLinkFound)
2842  {
2843  aToInsertToken.eTokenType = TOKEN_LINK_END;
2844  aToInsertToken.sText = m_aButtonTexts[TOKEN_LINK_END];
2845  }
2846 
2847  if(bPostLinkStartFound)
2848  {
2849  OSL_ENSURE(pExchange, "no control to exchange?");
2850  if(pExchange)
2851  {
2852  const_cast<SwTOXButton*>(static_cast<const SwTOXButton*>(pExchange))->SetLinkEnd();
2853  const_cast<SwTOXButton*>(static_cast<const SwTOXButton*>(pExchange))->SetText(m_aButtonTexts[TOKEN_LINK_END]);
2854  }
2855  }
2856 
2857  if(bPreEndLinkFound)
2858  {
2859  OSL_ENSURE(pExchange, "no control to exchange?");
2860 
2861  if(pExchange)
2862  {
2863  const_cast<SwTOXButton*>(static_cast<const SwTOXButton*>(pExchange))->SetLinkStart();
2864  const_cast<SwTOXButton*>(static_cast<const SwTOXButton*>(pExchange))->SetText(m_aButtonTexts[TOKEN_LINK_START]);
2865  }
2866  }
2867  }
2868 
2869  //if the active control is text then insert a new button at the selection
2870  //else replace the button
2871  auto iterActive = std::find_if(m_aControlList.begin(), m_aControlList.end(),
2872  [this](const auto& rControl)
2873  {
2874  SwTOXWidget* pCtrl = rControl.get();
2875  return pCtrl == m_pActiveCtrl;
2876  });
2877 
2878  assert(iterActive != m_aControlList.end());
2879  if (iterActive == m_aControlList.end())
2880  return;
2881 
2882  if (WindowType::EDIT == m_pActiveCtrl->GetType())
2883  {
2884  ++iterActive;
2885 
2886  int nStartPos, nEndPos;
2887  static_cast<SwTOXEdit*>(m_pActiveCtrl)->get_selection_bounds(nStartPos, nEndPos);
2888 
2889  const OUString sEditText = static_cast<SwTOXEdit*>(m_pActiveCtrl)->GetText();
2890  const OUString sLeft = sEditText.copy( 0, std::min(nStartPos, nEndPos) );
2891  const OUString sRight = sEditText.copy( std::max(nStartPos, nEndPos) );
2892 
2893  static_cast<SwTOXEdit*>(m_pActiveCtrl)->SetText(sLeft);
2894  static_cast<SwTOXEdit*>(m_pActiveCtrl)->AdjustSize();
2895 
2896  SwFormToken aTmpToken(TOKEN_TEXT);
2897  SwTOXEdit* pEdit = new SwTOXEdit(this, aTmpToken);
2898  iterActive = m_aControlList.emplace(iterActive, pEdit);
2899 
2900  pEdit->SetText(sRight);
2901  sal_uInt32 nIndex = GetControlIndex( TOKEN_TEXT );
2902  OUString strName(m_sAccessibleName + OUString::number(nIndex));
2903  if ( nIndex == 1)
2904  {
2905  /*Press left or right arrow to choose the structure controls*/
2906  strName += " (" + m_sAdditionalAccnameString2 + ", "
2907  /*Press Ctrl+Alt+A to move focus for more operations*/
2909  /*Press Ctrl+Alt+B to move focus back to the current structure control*/
2911  }
2912  pEdit->SetAccessibleName(strName);
2913  pEdit->AdjustSize();
2914  pEdit->SetModifyHdl(LINK(this, SwTokenWindow, EditResize ));
2915  pEdit->SetPrevNextLink(LINK(this, SwTokenWindow, NextItemHdl));
2916  pEdit->SetGetFocusHdl(LINK(this, SwTokenWindow, TbxFocusHdl));
2917  pEdit->Show();
2918  }
2919  else
2920  {
2921  m_pActiveCtrl->Hide();
2922  m_pActiveCtrl = nullptr;
2923  iterActive = m_aControlList.erase(iterActive);
2924  }
2925 
2926  //now the new button
2927  SwTOXButton* pButton = new SwTOXButton(this, aToInsertToken);
2928  m_aControlList.emplace(iterActive, pButton);
2929 
2930  pButton->SetPrevNextLink(LINK(this, SwTokenWindow, NextItemBtnHdl));
2931  pButton->SetGetFocusHdl(LINK(this, SwTokenWindow, TbxFocusBtnHdl));
2932 
2933  if (TOKEN_AUTHORITY != aToInsertToken.eTokenType)
2934  {
2935  pButton->SetText(m_aButtonTexts[aToInsertToken.eTokenType]);
2936  }
2937  else
2938  {
2939  //use the first two chars as symbol
2941  static_cast<ToxAuthorityField>(aToInsertToken.nAuthorityField)));
2942  pButton->SetText(sTmp.copy(0, 2));
2943  }
2944 
2945  pButton->Check();
2946  pButton->Show();
2947  SetActiveControl(pButton);
2948 
2949  AdjustPositions();
2950 }
2951 
2952 void SwTokenWindow::RemoveControl(const SwTOXButton* pDel, bool bInternalCall)
2953 {
2954  if (bInternalCall && TOX_AUTHORITIES == m_pForm->GetTOXType())
2956 
2957  auto it = std::find_if(m_aControlList.begin(), m_aControlList.end(),
2958  [pDel](const auto& rControl)
2959  {
2960  SwTOXWidget* pCtrl = rControl.get();
2961  return pCtrl == pDel;
2962  });
2963  assert(it != m_aControlList.end()); //Control does not exist!
2964  if (it == m_aControlList.end())
2965  return;
2966 
2967  // the two neighbours of the box must be merged
2968  // the properties of the right one will be lost
2969  assert(it != m_aControlList.begin() && it != m_aControlList.end() - 1); //Button at first or last position?
2970  if (it == m_aControlList.begin() || it == m_aControlList.end() - 1)
2971  return;
2972 
2973  auto itLeft = it, itRight = it;
2974  --itLeft;
2975  ++itRight;
2976  SwTOXWidget* pLeftEdit = itLeft->get();
2977  SwTOXWidget* pRightEdit = itRight->get();
2978 
2979  static_cast<SwTOXEdit*>(pLeftEdit)->SetText(static_cast<SwTOXEdit*>(pLeftEdit)->GetText() +
2980  static_cast<SwTOXEdit*>(pRightEdit)->GetText());
2981  static_cast<SwTOXEdit*>(pLeftEdit)->AdjustSize();
2982 
2983  m_pActiveCtrl->Hide();
2984  m_pActiveCtrl = nullptr;
2985 
2986  m_aControlList.erase(itRight);
2987  m_aControlList.erase(it);
2988 
2989  SetActiveControl(pLeftEdit);
2990  AdjustPositions();
2991  m_aModifyHdl.Call(nullptr);
2992 }
2993 
2994 IMPL_LINK_NOARG(SwTokenWindow, AdjustPositionsHdl, const Size&, void)
2995 {
2996  AdjustScrolling();
2997 }
2998 
3000 {
3001  for (size_t i = 0; i < m_aControlList.size(); ++i)
3002  m_aControlList[i]->set_grid_left_attach(i);
3003  AdjustScrolling();
3004 }
3005 
3007 {
3008  m_xScrollWin->hadjustment_set_value(nOffset);
3009 }
3010 
3012 {
3013  AdjustScrolling();
3014 }
3015 
3017 {
3018  if (m_aControlList.size() <= 1)
3019  return;
3020 
3021  //validate scroll buttons
3022 
3023  auto nLeft = m_xScrollWin->hadjustment_get_value();
3024  auto nSpace = m_xScrollWin->hadjustment_get_page_size();
3025  auto nWidth = m_xScrollWin->hadjustment_get_upper();
3026 
3027  bool bEnable = nWidth > nSpace;
3028 
3029  //the active control must be visible
3030  if (bEnable && m_pActiveCtrl)
3031  {
3032  int x, y, width, height;
3033  m_pActiveCtrl->get_extents_relative_to(*m_xCtrlParentWin, x, y, width, height);
3034 
3035  if (x < nLeft || x + width > nLeft + nSpace)
3036  {
3037  MoveControls(x);
3038  nLeft = x;
3039  }
3040 
3041  m_xLeftScrollWin->set_sensitive(nLeft > 0);
3042  m_xRightScrollWin->set_sensitive(nLeft + nSpace < nWidth);
3043  }
3044  else
3045  {
3046  //if the control fits into the space then the first control must be at position 0
3047  m_xRightScrollWin->set_sensitive(false);
3048  m_xLeftScrollWin->set_sensitive(false);
3049  }
3050 }
3051 
3052 IMPL_LINK(SwTokenWindow, ScrollBtnHdl, weld::Button&, rBtn, void)
3053 {
3054  if (m_aControlList.empty())
3055  return;
3056 
3057  const auto nSpace = m_xScrollWin->hadjustment_get_page_size();
3058  const auto nWidth = m_xScrollWin->hadjustment_get_upper();
3059  const auto nLeft = m_xScrollWin->hadjustment_get_value();
3060 
3061  tools::Long nMove = nLeft;
3062  if (&rBtn == m_xLeftScrollWin.get())
3063  {
3064  //find the first completely visible control (left edge visible)
3065  auto it = std::find_if(m_aControlList.begin(), m_aControlList.end(),
3066  [this, nLeft](const auto& rControl)
3067  {
3068  SwTOXWidget* pCtrl = rControl.get();
3069 
3070  int x, y, width, height;
3071  pCtrl->get_extents_relative_to(*m_xCtrlParentWin, x, y, width, height);
3072 
3073  return x >= nLeft;
3074  });
3075  if (it != m_aControlList.end())
3076  {
3077  if (it == m_aControlList.begin())
3078  {
3079  nMove = 0;
3080  }
3081  else
3082  {
3083  //move the left neighbor to the start position
3084  auto itLeft = it;
3085  --itLeft;
3086  SwTOXWidget* pLeft = itLeft->get();
3087 
3088  int x, y, width, height;
3089  pLeft->get_extents_relative_to(*m_xCtrlParentWin, x, y, width, height);
3090 
3091  nMove = x;
3092  }
3093  }
3094  }
3095  else
3096  {
3097  //find the first completely visible control (right edge visible)
3098  auto it = std::find_if(m_aControlList.rbegin(), m_aControlList.rend(),
3099  [this, nLeft, nSpace](const auto& rControl) {
3100  SwTOXWidget* pCtrl = rControl.get();
3101 
3102  int x, y, width, height;
3103  pCtrl->get_extents_relative_to(*m_xCtrlParentWin, x, y, width, height);
3104 
3105  auto nXPos = x + width;
3106  return nXPos <= nLeft + nSpace;
3107  });
3108  if (it != m_aControlList.rend() && it != m_aControlList.rbegin())
3109  {
3110  //move the right neighbor to the right edge right aligned
3111  auto itRight = it;
3112  --itRight;
3113  SwTOXWidget* pRight = itRight->get();
3114 
3115  int x, y, width, height;
3116  pRight->get_extents_relative_to(*m_xCtrlParentWin, x, y, width, height);
3117 
3118  nMove = x + width - nSpace;
3119  }
3120 
3121  //move it left until it's completely visible
3122  }
3123 
3124  if (nMove != nLeft)
3125  {
3126  // move the complete list
3127  MoveControls(nMove);
3128  m_xLeftScrollWin->set_sensitive(nMove > 0);
3129  m_xRightScrollWin->set_sensitive(nMove + nSpace < nWidth);
3130  }
3131 }
3132 
3134 {
3135  OUStringBuffer sRet;
3136 
3137  for (const auto& elem : m_aControlList)
3138  {
3139  const SwTOXWidget* pCtrl = elem.get();
3140 
3141  const SwFormToken &rNewToken = pCtrl->GetType() == WindowType::EDIT
3142  ? const_cast<SwTOXEdit*>(static_cast<const SwTOXEdit*>(pCtrl))->GetFormToken()
3143  : static_cast<const SwTOXButton*>(pCtrl)->GetFormToken();
3144 
3145  //TODO: prevent input of TOX_STYLE_DELIMITER in KeyInput
3146  sRet.append(rNewToken.GetString());
3147  }
3148 
3149  return sRet.makeStringAndClear();
3150 }
3151 
3152 // Check if a control of the specified TokenType is already contained in the list
3154 {
3155  bool bRet = false;
3156 
3157  for (const auto& elem : m_aControlList)
3158  {
3159  const SwTOXWidget* pCtrl = elem.get();
3160  const SwFormToken &rNewToken = pCtrl->GetType() == WindowType::EDIT
3161  ? const_cast<SwTOXEdit*>(static_cast<const SwTOXEdit*>(pCtrl))->GetFormToken()
3162  : static_cast<const SwTOXButton*>(pCtrl)->GetFormToken();
3163 
3164  if (eSearchFor == rNewToken.eTokenType)
3165  {
3166  bRet = true;
3167  break;
3168  }
3169  }
3170 
3171  return bRet;
3172 }
3173 
3175 {
3176  OUString sEntry;
3177  if (rToken.eTokenType != TOKEN_AUTHORITY)
3178  sEntry = m_aButtonHelpTexts[rToken.eTokenType];
3179  else
3180  {
3182  static_cast<ToxAuthorityField>(rToken.nAuthorityField));
3183  }
3184 
3185  if (rToken.eTokenType != TOKEN_TAB_STOP)
3186  {
3187  if (!rToken.sCharStyleName.isEmpty())
3188  {
3189  sEntry += " " + m_sCharStyle + rToken.sCharStyleName;
3190  }
3191  }
3192 
3193  return sEntry;
3194 }
3195 
3196 IMPL_LINK(SwTokenWindow, EditResize, SwTOXEdit&, rEdit, void)
3197 {
3198  rEdit.AdjustSize();
3199  AdjustPositions();
3200  m_aModifyHdl.Call(nullptr);
3201 }
3202 
3203 IMPL_LINK(SwTokenWindow, NextItemHdl, SwTOXEdit&, rEdit, void)
3204 {
3205  auto it = std::find_if(m_aControlList.begin(), m_aControlList.end(),
3206  [&rEdit](const auto& rControl)
3207  {
3208  SwTOXWidget* pCtrl = rControl.get();
3209  return pCtrl == &rEdit;
3210  });
3211 
3212  if (it == m_aControlList.end())
3213  return;
3214 
3215  auto itTest = it;
3216  ++itTest;
3217 
3218  if ((it != m_aControlList.begin() && !rEdit.IsNextControl()) ||
3219  (itTest != m_aControlList.end() && rEdit.IsNextControl()))
3220  {
3221  auto iterFocus = it;
3222  rEdit.IsNextControl() ? ++iterFocus : --iterFocus;
3223 
3224  SwTOXWidget *pCtrlFocus = iterFocus->get();
3225  pCtrlFocus->GrabFocus();
3226  static_cast<SwTOXButton*>(pCtrlFocus)->Check();
3227 
3228  AdjustScrolling();
3229  }
3230 }
3231 
3232 IMPL_LINK(SwTokenWindow, TbxFocusHdl, SwTOXWidget&, rControl, void)
3233 {
3234  SwTOXEdit* pEdit = static_cast<SwTOXEdit*>(&rControl);
3235  for (const auto& aControl : m_aControlList)
3236  {
3237  SwTOXWidget* pCtrl = aControl.get();
3238  if (pCtrl && pCtrl->GetType() != WindowType::EDIT)
3239  static_cast<SwTOXButton*>(pCtrl)->Check(false);
3240  }
3241 
3242  SetActiveControl(pEdit);
3243 }
3244 
3245 IMPL_LINK(SwTokenWindow, NextItemBtnHdl, SwTOXButton&, rBtn, void )
3246 {
3247  auto it = std::find_if(m_aControlList.begin(), m_aControlList.end(),
3248  [&rBtn](const auto& rControl)
3249  {
3250  SwTOXWidget* pCtrl = rControl.get();
3251  return pCtrl == &rBtn;
3252  });
3253 
3254  if (it == m_aControlList.end())
3255  return;
3256 
3257  auto itTest = it;
3258  ++itTest;
3259 
3260  if (rBtn.IsNextControl() && (itTest == m_aControlList.end() || !rBtn.IsNextControl()))
3261  return;
3262 
3263  bool isNext = rBtn.IsNextControl();
3264 
3265  auto iterFocus = it;
3266  isNext ? ++iterFocus : --iterFocus;
3267 
3268  SwTOXWidget* pCtrlFocus = iterFocus->get();
3269  pCtrlFocus->GrabFocus();
3270  int nStartPos(0), nEndPos(0);
3271 
3272  if (!isNext)
3273  {
3274  const sal_Int32 nLen = static_cast<SwTOXEdit*>(pCtrlFocus)->GetText().getLength();
3275 
3276  nStartPos = nLen;
3277  nEndPos = nLen;
3278  }
3279 
3280  static_cast<SwTOXEdit*>(pCtrlFocus)->select_region(nStartPos, nEndPos);
3281 
3282  rBtn.Check(false);
3283 
3284  AdjustScrolling();
3285 }
3286 
3287 IMPL_LINK(SwTokenWindow, TbxFocusBtnHdl, SwTOXWidget&, rControl, void)
3288 {
3289  SwTOXButton* pBtn = static_cast<SwTOXButton*>(&rControl);
3290  for (const auto& aControl : m_aControlList)
3291  {
3292  SwTOXWidget* pControl = aControl.get();
3293 
3294  if (pControl && WindowType::EDIT != pControl->GetType())
3295  static_cast<SwTOXButton*>(pControl)->Check(pBtn == pControl);
3296  }
3297 
3298  SetActiveControl(pBtn);
3299 }
3300 
3302 {
3303  if (m_pParent)
3304  {
3306  }
3307 }
3308 
3310 {
3311  //there are only one entry-text button and only one page-number button,
3312  //so we need not add index for these two buttons.
3313  if ( eType == TOKEN_ENTRY_TEXT || eType == TOKEN_PAGE_NUMS )
3314  {
3315  return 0;
3316  }
3317 
3318  sal_uInt32 nIndex = 0;
3319  for (const auto& elem : m_aControlList)
3320  {
3321  const SwTOXWidget* pControl = elem.get();
3322 
3323  const SwFormToken& rNewToken = WindowType::EDIT == pControl->GetType()
3324  ? const_cast<SwTOXEdit*>(static_cast<const SwTOXEdit*>(pControl))->GetFormToken()
3325  : static_cast<const SwTOXButton*>(pControl)->GetFormToken();
3326 
3327  if(eType == rNewToken.eTokenType)
3328  {
3329  ++nIndex;
3330  }
3331  }
3332 
3333  return nIndex;
3334 }
3335 
3337  : SfxTabPage(pPage, pController, "modules/swriter/ui/tocstylespage.ui", "TocStylesPage", &rAttrSet)
3338  , m_xLevelLB(m_xBuilder->weld_tree_view("levels"))
3339  , m_xAssignBT(m_xBuilder->weld_button("assign"))
3340  , m_xParaLayLB(m_xBuilder->weld_tree_view("styles"))
3341  , m_xStdBT(m_xBuilder->weld_button("default"))
3342  , m_xEditStyleBT(m_xBuilder->weld_button("edit"))
3343 {
3344  m_xParaLayLB->make_sorted();
3345  auto nHeight = m_xLevelLB->get_height_rows(16);
3346  m_xLevelLB->set_size_request(-1, nHeight);
3347  m_xParaLayLB->set_size_request(-1, nHeight);
3348 
3350 
3351  m_xEditStyleBT->connect_clicked(LINK(this, SwTOXStylesTabPage, EditStyleHdl));
3352  m_xAssignBT->connect_clicked(LINK(this, SwTOXStylesTabPage, AssignHdl));
3353  m_xStdBT->connect_clicked(LINK(this, SwTOXStylesTabPage, StdHdl));
3354  m_xParaLayLB->connect_changed(LINK(this, SwTOXStylesTabPage, EnableSelectHdl));
3355  m_xLevelLB->connect_changed(LINK(this, SwTOXStylesTabPage, EnableSelectHdl));
3356  m_xParaLayLB->connect_row_activated(LINK(this, SwTOXStylesTabPage, DoubleClickHdl));
3357 }
3358 
3360 {
3361 }
3362 
3364 {
3365  return true;
3366 }
3367 
3369 {
3370  ActivatePage(*rSet);
3371 }
3372 
3374 {
3375  m_pCurrentForm.reset(new SwForm(GetForm()));
3376 
3377  // not hyperlink for user directories
3378  const sal_uInt16 nSize = m_pCurrentForm->GetFormMax();
3379 
3380  // display form pattern without title
3381 
3382  m_xLevelLB->freeze();
3383  m_xLevelLB->clear();
3384  // display 1st TemplateEntry
3385  OUString aStr( SwResId( STR_TITLE ));
3386  if( !m_pCurrentForm->GetTemplate( 0 ).isEmpty() )
3387  {
3388  aStr += " " + OUStringChar(aDeliStart)
3389  + m_pCurrentForm->GetTemplate( 0 )
3390  + OUStringChar(aDeliEnd);
3391  }
3392  m_xLevelLB->append_text(aStr);
3393 
3394  for( sal_uInt16 i=1; i < nSize; ++i )
3395  {
3396  if( TOX_INDEX == m_pCurrentForm->GetTOXType() &&
3397  FORM_ALPHA_DELIMITER == i )
3398  {
3399  aStr = SwResId(STR_ALPHA);
3400  }
3401  else
3402  {
3403  aStr = SwResId(STR_LEVEL) + OUString::number(
3404  TOX_INDEX == m_pCurrentForm->GetTOXType() ? i - 1 : i );
3405  }
3406  if( !m_pCurrentForm->GetTemplate( i ).isEmpty() )
3407  {
3408  aStr += " " + OUStringChar(aDeliStart)
3409  + m_pCurrentForm->GetTemplate( i )
3410  + OUStringChar(aDeliEnd);
3411  }
3412  m_xLevelLB->append_text(aStr);
3413  }
3414  m_xLevelLB->thaw();
3415 
3416  // initialise templates
3417  SwWrtShell& rSh = static_cast<SwMultiTOXTabDialog*>(GetDialogController())->GetWrtShell();
3418  const sal_uInt16 nSz = rSh.GetTextFormatCollCount();
3419 
3420  m_xParaLayLB->freeze();
3421  m_xParaLayLB->clear();
3422  for( sal_uInt16 i = 0; i < nSz; ++i )
3423  {
3424  const SwTextFormatColl *pColl = &rSh.GetTextFormatColl( i );
3425  if( !pColl->IsDefault() )
3426  m_xParaLayLB->append_text( pColl->GetName() );
3427  }
3428 
3429  // query pool collections and set them for the directory
3430  for( sal_uInt16 i = 0; i < m_pCurrentForm->GetFormMax(); ++i )
3431  {
3432  aStr = m_pCurrentForm->GetTemplate( i );
3433  if (!aStr.isEmpty() && m_xParaLayLB->find_text(aStr) == -1)
3434  m_xParaLayLB->append_text(aStr);
3435  }
3436  m_xParaLayLB->thaw();
3437 
3438  EnableSelectHdl(*m_xParaLayLB);
3439 }
3440 
3442 {
3443  GetForm() = *m_pCurrentForm;
3444  return DeactivateRC::LeavePage;
3445 }
3446 
3447 std::unique_ptr<SfxTabPage> SwTOXStylesTabPage::Create(weld::Container* pPage, weld::DialogController* pController,
3448  const SfxItemSet* rAttrSet)
3449 {
3450  return std::make_unique<SwTOXStylesTabPage>(pPage, pController, *rAttrSet);
3451 }
3452 
3454 {
3455  if (m_xParaLayLB->get_selected_index() != -1)
3456  {
3457  SfxStringItem aStyle(SID_STYLE_EDIT, m_xParaLayLB->get_selected_text());
3458  SfxUInt16Item aFamily(SID_STYLE_FAMILY, sal_uInt16(SfxStyleFamily::Para));
3459  SwWrtShell& rSh = static_cast<SwMultiTOXTabDialog*>(GetDialogController())->GetWrtShell();
3460  rSh.GetView().GetViewFrame()->GetDispatcher()->ExecuteList(SID_STYLE_EDIT,
3461  SfxCallMode::SYNCHRON,
3462  { &aStyle, &aFamily });
3463  }
3464 }
3465 
3466 // allocate templates
3468 {
3469  auto nLevPos = m_xLevelLB->get_selected_index();
3470  auto nTemplPos = m_xParaLayLB->get_selected_index();
3471  if (nLevPos == -1 || nTemplPos == -1)
3472  return;
3473 
3474  const OUString aStr(m_xLevelLB->get_text(nLevPos).getToken(0, aDeliStart)
3475  + OUStringChar(aDeliStart)
3476  + m_xParaLayLB->get_selected_text()
3477  + OUStringChar(aDeliEnd));
3478 
3479  m_pCurrentForm->SetTemplate(nLevPos, m_xParaLayLB->get_selected_text());
3480 
3481  m_xLevelLB->remove(nLevPos);
3482  m_xLevelLB->insert_text(nLevPos, aStr);
3483  m_xLevelLB->select_text(aStr);
3484  Modify();
3485 }
3486 
3488 {
3489  const auto nPos = m_xLevelLB->get_selected_index();
3490  if (nPos != -1)
3491  {
3492  const OUString aStr(m_xLevelLB->get_text(nPos).getToken(0, aDeliStart));
3493  m_xLevelLB->remove(nPos);
3494  m_xLevelLB->insert_text(nPos, aStr);
3495  m_xLevelLB->select_text(aStr);
3496  m_pCurrentForm->SetTemplate(nPos, OUString());
3497  Modify();
3498  }
3499 }
3500 
3502 {
3503  const OUString aTmpName(m_xParaLayLB->get_selected_text());
3504  SwWrtShell& rSh = static_cast<SwMultiTOXTabDialog*>(GetDialogController())->GetWrtShell();
3505 
3506  if(m_xParaLayLB->get_selected_index() != -1 &&
3507  (m_xLevelLB->get_selected_index() == 0 || SwMultiTOXTabDialog::IsNoNum(rSh, aTmpName)))
3508  AssignHdl(*m_xAssignBT);
3509 
3510  return true;
3511 }
3512 
3513 // enable only when selected
3515 {
3516  m_xStdBT->set_sensitive(m_xLevelLB->get_selected_index() != -1);
3517 
3518  SwWrtShell& rSh = static_cast<SwMultiTOXTabDialog*>(GetDialogController())->GetWrtShell();
3519  const OUString aTmpName(m_xParaLayLB->get_selected_text());
3520  m_xAssignBT->set_sensitive(m_xParaLayLB->get_selected_index() != -1 &&
3521  m_xLevelLB->get_selected_index() != -1 &&
3522  (m_xLevelLB->get_selected_index() == 0 || SwMultiTOXTabDialog::IsNoNum(rSh, aTmpName)));
3523  m_xEditStyleBT->set_sensitive(m_xParaLayLB->get_selected_index() != -1);
3524 }
3525 
3527 {
3528  SwMultiTOXTabDialog* pTOXDlg = static_cast<SwMultiTOXTabDialog*>(GetDialogController());
3529  if (pTOXDlg)
3530  {
3531  GetForm() = *m_pCurrentForm;
3533  }
3534 }
3535 
3536 #define ITEM_SEARCH 1
3537 #define ITEM_ALTERNATIVE 2
3538 #define ITEM_PRIM_KEY 3
3539 #define ITEM_SEC_KEY 4
3540 #define ITEM_COMMENT 5
3541 #define ITEM_CASE 6
3542 #define ITEM_WORDONLY 7
3543 
3544 SwEntryBrowseBox::SwEntryBrowseBox(const css::uno::Reference<css::awt::XWindow> &rParent)
3550  BrowserMode::HLINES |
3551  BrowserMode::VLINES |
3554  , m_aCellEdit(VclPtr<svt::EditControl>::Create(&GetDataWindow()))
3555  , m_aCellCheckBox(VclPtr<svt::CheckBoxControl>::Create(&GetDataWindow()))
3556  , m_nCurrentRow(0)
3557  , m_bModified(false)
3558 {
3559  OUString sSearch = SwResId(STR_AUTOMARK_SEARCHTERM);
3560  OUString sAlternative = SwResId(STR_AUTOMARK_ALTERNATIVE);
3561  OUString sPrimKey = SwResId(STR_AUTOMARK_KEY1);
3562  OUString sSecKey = SwResId(STR_AUTOMARK_KEY2);
3563  OUString sComment = SwResId(STR_AUTOMARK_COMMENT);
3564  OUString sCaseSensitive = SwResId(STR_AUTOMARK_CASESENSITIVE);
3565  OUString sWordOnly = SwResId(STR_AUTOMARK_WORDONLY);
3566  m_sYes = SwResId(STR_AUTOMARK_YES);
3567  m_sNo = SwResId(STR_AUTOMARK_NO);
3568 
3569  m_aCellCheckBox->EnableTriState(false);
3570  m_xController = new ::svt::EditCellController(m_aCellEdit.get());
3571  m_xCheckController = new ::svt::CheckBoxCellController(m_aCellCheckBox.get());
3572 
3573  // HACK: BrowseBox doesn't invalidate its children, how it should be.
3574  // That's why WB_CLIPCHILDREN is reset in order to enforce the
3575  // children' invalidation
3576  WinBits aStyle = GetStyle();
3577  if( aStyle & WB_CLIPCHILDREN )
3578  {
3579  aStyle &= ~WB_CLIPCHILDREN;
3580  SetStyle( aStyle );
3581  }
3582 
3583  const OUString* aTitles[7] =
3584  {
3585  &sSearch,
3586  &sAlternative,
3587  &sPrimKey,
3588  &sSecKey,
3589  &sComment,
3590  &sCaseSensitive,
3591  &sWordOnly
3592  };
3593 
3594  tools::Long nWidth = GetSizePixel().Width();
3595  nWidth /=7;
3596  --nWidth;
3597  for(sal_uInt16 i = 1; i < 8; i++)
3598  InsertDataColumn( i, *aTitles[i - 1], nWidth );
3599 }
3600 
3601 SwEntryBrowseBox::~SwEntryBrowseBox()
3602 {
3603  disposeOnce();
3604 }
3605 
3607 {
3608  m_aCellEdit.disposeAndClear();
3609  m_aCellCheckBox.disposeAndClear();
3611 }
3612 
3613 void SwEntryBrowseBox::Resize()
3614 {
3616 
3617  tools::Long nWidth = GetSizePixel().Width();
3618  std::vector<tools::Long> aWidths = GetOptimalColWidths();
3619  tools::Long nNaturalWidth(std::accumulate(aWidths.begin(), aWidths.end(), 0));
3620  tools::Long nExcess = ((nWidth - nNaturalWidth) / aWidths.size()) - 1;
3621 
3622  for (size_t i = 0; i < aWidths.size(); ++i)
3623  SetColumnWidth(i+1, aWidths[i] + nExcess);
3624 }
3625 
3626 std::vector<tools::Long> SwEntryBrowseBox::GetOptimalColWidths() const
3627 {
3628  std::vector<tools::Long> aWidths;
3629 
3630  tools::Long nStandardColMinWidth = approximate_digit_width() * 15;
3631  tools::Long nYesNoWidth = approximate_digit_width() * 5;
3632  nYesNoWidth = std::max(nYesNoWidth, GetTextWidth(m_sYes));
3633  nYesNoWidth = std::max(nYesNoWidth, GetTextWidth(m_sNo));
3634  for (sal_uInt16 i = 1; i < 6; i++)
3635  {
3636  tools::Long nColWidth = std::max(nStandardColMinWidth,
3637  GetTextWidth(GetColumnTitle(i)));
3638  nColWidth += 12;
3639  aWidths.push_back(nColWidth);
3640  }
3641 
3642  for (sal_uInt16 i = 6; i < 8; i++)
3643  {
3644  tools::Long nColWidth = std::max(nYesNoWidth,
3645  GetTextWidth(GetColumnTitle(i)));
3646  nColWidth += 12;
3647  aWidths.push_back(nColWidth);
3648  }
3649 
3650  return aWidths;
3651 }
3652 
3653 Size SwEntryBrowseBox::GetOptimalSize() const
3654 {
3655  Size aSize = LogicToPixel(Size(276 , 175), MapMode(MapUnit::MapAppFont));
3656 
3657  std::vector<tools::Long> aWidths = GetOptimalColWidths();
3658 
3659  tools::Long nWidth(std::accumulate(aWidths.begin(), aWidths.end(), 0));
3660 
3661  aSize.setWidth( std::max(aSize.Width(), nWidth) );
3662 
3663  return aSize;
3664 }
3665 
3666 bool SwEntryBrowseBox::SeekRow( sal_Int32 nRow )
3667 {
3668  m_nCurrentRow = nRow;
3669  return true;
3670 }
3671 
3672 OUString SwEntryBrowseBox::GetCellText(sal_Int32 nRow, sal_uInt16 nColumn) const
3673 {
3674  OUString pRet;
3675  if (o3tl::make_unsigned(nRow) < m_Entries.size())
3676  {
3677  const AutoMarkEntry* pEntry = m_Entries[ nRow ].get();
3678  switch(nColumn)
3679  {
3680  case ITEM_SEARCH : pRet = pEntry->sSearch; break;
3681  case ITEM_ALTERNATIVE : pRet = pEntry->sAlternative; break;
3682  case ITEM_PRIM_KEY : pRet = pEntry->sPrimKey; break;
3683  case ITEM_SEC_KEY : pRet = pEntry->sSecKey; break;
3684  case ITEM_COMMENT : pRet = pEntry->sComment; break;
3685  case ITEM_CASE : pRet = pEntry->bCase ? m_sYes : m_sNo; break;
3686  case ITEM_WORDONLY : pRet = pEntry->bWord ? m_sYes : m_sNo; break;
3687  }
3688  }
3689  return pRet;
3690 }
3691 
3692 void SwEntryBrowseBox::PaintCell(OutputDevice& rDev,
3693  const tools::Rectangle& rRect, sal_uInt16 nColumnId) const
3694 {
3695  const DrawTextFlags nStyle = DrawTextFlags::Clip | DrawTextFlags::Center;
3696  rDev.DrawText( rRect, GetCellText( m_nCurrentRow, nColumnId ), nStyle );
3697 }
3698 
3699 ::svt::CellController* SwEntryBrowseBox::GetController(sal_Int32 /*nRow*/, sal_uInt16 nCol)
3700 {
3701  return nCol < ITEM_CASE ? m_xController.get() : m_xCheckController.get();
3702 }
3703 
3704 bool SwEntryBrowseBox::SaveModified()
3705 {
3706  m_bModified = true;
3707  const size_t nRow = GetCurRow();
3708  const sal_uInt16 nCol = GetCurColumnId();
3709 
3710  OUString sNew;
3711  bool bVal = false;
3712  ::svt::CellController* pController = nullptr;
3713  if(nCol < ITEM_CASE)
3714  {
3715  pController = m_xController.get();
3716  sNew = static_cast< ::svt::EditCellController*>(pController)->GetEditImplementation()->GetText( LINEEND_LF );
3717  }
3718  else
3719  {
3720  pController = m_xCheckController.get();
3721  bVal = static_cast< ::svt::CheckBoxCellController*>(pController)->GetCheckBox().get_active();
3722  }
3723  const bool bAddEntry = nRow >= m_Entries.size();
3724  std::unique_ptr<AutoMarkEntry> xNewEntry(bAddEntry ? new AutoMarkEntry : nullptr);
3725  AutoMarkEntry* pEntry = bAddEntry ? xNewEntry.get() : m_Entries[nRow].get();
3726  switch(nCol)
3727  {
3728  case ITEM_SEARCH : pEntry->sSearch = sNew; break;
3729  case ITEM_ALTERNATIVE : pEntry->sAlternative = sNew; break;
3730  case ITEM_PRIM_KEY : pEntry->sPrimKey = sNew; break;
3731  case ITEM_SEC_KEY : pEntry->sSecKey = sNew; break;
3732  case ITEM_COMMENT : pEntry->sComment = sNew; break;
3733  case ITEM_CASE : pEntry->bCase = bVal; break;
3734  case ITEM_WORDONLY : pEntry->bWord = bVal; break;
3735  }
3736  if (bAddEntry)
3737  {
3738  m_Entries.push_back(std::move(xNewEntry));
3739  RowInserted(nRow, 1, true, true);
3740  if(nCol < ITEM_WORDONLY)
3741  {
3742  pController->SaveValue();
3743  GoToRow( nRow );
3744  }
3745  }
3746  return true;
3747 }
3748 
3749 void SwEntryBrowseBox::InitController(
3750  ::svt::CellControllerRef& rController, sal_Int32 nRow, sal_uInt16 nCol)
3751 {
3752  const OUString rText = GetCellText( nRow, nCol );
3753  if(nCol < ITEM_CASE)
3754  {
3755  rController = m_xController;
3756  ::svt::CellController* pController = m_xController.get();
3757  static_cast< ::svt::EditCellController*>(pController)->GetEditImplementation()->SetText( rText );
3758  }
3759  else
3760  {
3761  rController = m_xCheckController;
3762  ::svt::CellController* pController = m_xCheckController.get();
3763  static_cast< ::svt::CheckBoxCellController*>(pController)->GetCheckBox().set_active(
3764  rText == m_sYes );
3765  }
3766 }
3767 
3768 void SwEntryBrowseBox::ReadEntries(SvStream& rInStr)
3769 {
3770  AutoMarkEntry* pToInsert = nullptr;
3771  rtl_TextEncoding eTEnc = osl_getThreadTextEncoding();
3772  while (rInStr.good())
3773  {
3774  OUString sLine;
3775  rInStr.ReadByteStringLine( sLine, eTEnc );
3776 
3777  // # -> comment
3778  // ; -> delimiter between entries ->
3779  // Format: TextToSearchFor;AlternativeString;PrimaryKey;SecondaryKey
3780  // Leading and trailing blanks are ignored
3781  if( !sLine.isEmpty() )
3782  {
3783  //comments are contained in separate lines but are put into the struct of the following data
3784  //line (if available)
3785  if( '#' != sLine[0] )
3786  {
3787  if( !pToInsert )
3788  pToInsert = new AutoMarkEntry;
3789 
3790  sal_Int32 nSttPos = 0;
3791  pToInsert->sSearch = sLine.getToken(0, ';', nSttPos );
3792  pToInsert->sAlternative = sLine.getToken(0, ';', nSttPos );
3793  pToInsert->sPrimKey = sLine.getToken(0, ';', nSttPos );
3794  pToInsert->sSecKey = sLine.getToken(0, ';', nSttPos );
3795 
3796  OUString sStr = sLine.getToken(0, ';', nSttPos );
3797  pToInsert->bCase = !sStr.isEmpty() && sStr != "0";
3798 
3799  sStr = sLine.getToken(0, ';', nSttPos );
3800  pToInsert->bWord = !sStr.isEmpty() && sStr != "0";
3801 
3802  m_Entries.push_back(std::unique_ptr<AutoMarkEntry>(pToInsert));
3803  pToInsert = nullptr;
3804  }
3805  else
3806  {
3807  if(pToInsert)
3808  m_Entries.push_back(std::unique_ptr<AutoMarkEntry>(pToInsert));
3809  pToInsert = new AutoMarkEntry;
3810  pToInsert->sComment = sLine.copy(1);
3811  }
3812  }
3813  }
3814  if( pToInsert )
3815  m_Entries.push_back(std::unique_ptr<AutoMarkEntry>(pToInsert));
3816  RowInserted(0, m_Entries.size() + 1);
3817 }
3818 
3819 void SwEntryBrowseBox::WriteEntries(SvStream& rOutStr)
3820 {
3821  //check if the current controller is modified
3822  const sal_uInt16 nCol = GetCurColumnId();
3823  ::svt::CellController* pController;
3824  if(nCol < ITEM_CASE)
3825  pController = m_xController.get();
3826  else
3827  pController = m_xCheckController.get();
3828  if (pController->IsValueChangedFromSaved())
3829  GoToColumnId(nCol + (nCol < ITEM_CASE ? 1 : -1 ));
3830 
3831  rtl_TextEncoding eTEnc = osl_getThreadTextEncoding();
3832  for(const std::unique_ptr<AutoMarkEntry> & rpEntry : m_Entries)
3833  {
3834  AutoMarkEntry* pEntry = rpEntry.get();
3835  if(!pEntry->sComment.isEmpty())
3836  {
3837  rOutStr.WriteByteStringLine( OUString("#" + pEntry->sComment), eTEnc );
3838  }
3839 
3840  OUString sWrite( pEntry->sSearch + ";" +
3841  pEntry->sAlternative + ";" +
3842  pEntry->sPrimKey + ";" +
3843  pEntry->sSecKey + ";" +
3844  (pEntry->bCase ? OUStringLiteral(u"1") : OUStringLiteral(u"0")) + ";" +
3845  (pEntry->bWord ? OUStringLiteral(u"1") : OUStringLiteral(u"0")) );
3846 
3847  if( sWrite.getLength() > 5 )
3848  rOutStr.WriteByteStringLine( sWrite, eTEnc );
3849  }
3850 }
3851 
3852 bool SwEntryBrowseBox::IsModified()const
3853 {
3854  if(m_bModified)
3855  return true;
3856 
3857  //check if the current controller is modified
3858  const sal_uInt16 nCol = GetCurColumnId();
3859  ::svt::CellController* pController;
3860  if(nCol < ITEM_CASE)
3861  pController = m_xController.get();
3862  else
3863  pController = m_xCheckController.get();
3864  return pController->IsValueChangedFromSaved();
3865 }
3866 
3867 SwAutoMarkDlg_Impl::SwAutoMarkDlg_Impl(weld::Window* pParent, const OUString& rAutoMarkURL,
3868  bool bCreate)
3869  : GenericDialogController(pParent, "modules/swriter/ui/createautomarkdialog.ui", "CreateAutomarkDialog")
3870  , sAutoMarkURL(rAutoMarkURL)
3871  , bCreateMode(bCreate)
3872  , m_xOKPB(m_xBuilder->weld_button("ok"))
3873  , m_xTable(m_xBuilder->weld_container("area"))
3874  , m_xTableCtrlParent(m_xTable->CreateChildFrame())
3875  , m_xEntriesBB(VclPtr<SwEntryBrowseBox>::Create(m_xTableCtrlParent))
3876 {
3877  m_xEntriesBB->Show();
3878  m_xOKPB->connect_clicked(LINK(this, SwAutoMarkDlg_Impl, OkHdl));
3879 
3880  m_xDialog->set_title(m_xDialog->get_title() + ": " + sAutoMarkURL);
3881  bool bError = false;
3882  if( bCreateMode )
3883  m_xEntriesBB->RowInserted(0);
3884  else
3885  {
3886  SfxMedium aMed( sAutoMarkURL, StreamMode::STD_READ );
3887  if( aMed.GetInStream() && !aMed.GetInStream()->GetError() )
3888  m_xEntriesBB->ReadEntries( *aMed.GetInStream() );
3889  else
3890  bError = true;
3891  }
3892 
3893  Size aPrefSize = m_xEntriesBB->GetOptimalSize();
3894  m_xTable->set_size_request(aPrefSize.Width(), aPrefSize.Height());
3895 
3896  if (bError)
3897  m_xDialog->response(RET_CANCEL);
3898 }
3899 
3900 SwAutoMarkDlg_Impl::~SwAutoMarkDlg_Impl()
3901 {
3902  m_xEntriesBB.disposeAndClear();
3903  m_xTableCtrlParent->dispose();
3904  m_xTableCtrlParent.clear();
3905 }
3906 
3907 IMPL_LINK_NOARG(SwAutoMarkDlg_Impl, OkHdl, weld::Button&, void)
3908 {
3909  bool bError = false;
3910  if (m_xEntriesBB->IsModified() || bCreateMode)
3911  {
3912  SfxMedium aMed( sAutoMarkURL,
3913  bCreateMode ? StreamMode::WRITE
3914  : StreamMode::WRITE| StreamMode::TRUNC );
3915  SvStream* pStrm = aMed.GetOutStream();
3916  pStrm->SetStreamCharSet( RTL_TEXTENCODING_MS_1253 );
3917  if( !pStrm->GetError() )
3918  {
3919  m_xEntriesBB->WriteEntries( *pStrm );
3920  aMed.Commit();
3921  }
3922  else
3923  bError = true;
3924  }
3925  if (!bError)
3926  m_xDialog->response(RET_OK);
3927 }
3928 
3929 /* 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:694
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:289
std::unique_ptr< weld::ComboBox > m_xAuthFieldsLB
Definition: swuicnttab.hxx:326
sal_uInt16 m_nInitialTOXType
Definition: swuicnttab.hxx:73
std::unique_ptr< weld::ScrolledWindow > m_xScrollWin
Definition: swuicnttab.hxx:248
bool IsNextControl() const
Definition: cnttab.cxx: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
bool SearchFile(OUString &rIniFile, Paths ePath=Paths::UserConfig)
FieldUnit
void OnModify(bool bAllLevels)
Definition: cnttab.cxx:1920
SwTOIOptions
Definition: tox.hxx:390
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:56
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:717
OUString m_sAdditionalAccnameString2
Definition: swuicnttab.hxx:237
void PreTokenButtonRemoved(const SwFormToken &rToken)
Definition: cnttab.cxx:2155
SwTOIOptions GetOptions() const
Definition: tox.hxx:756
std::unique_ptr< weld::Button > m_xRightScrollWin
Definition: swuicnttab.hxx:249
void SetMainEntryCharStyle(const OUString &rSet)
Definition: toxmgr.hxx:116
bool IsDefault() const
Definition: format.hxx:113
virtual void set_grid_left_attach(int nPos) override
Definition: cnttab.cxx: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:937
std::unique_ptr< weld::Button > m_xAddStylesPB
Definition: swuicnttab.hxx:146
DECL_LINK(KeyInputHdl, const KeyEvent &, bool)
std::unique_ptr< weld::Button > m_xEntryPB
Definition: swuicnttab.hxx:321
std::unique_ptr< weld::ComboBox > m_xTypeLB
Definition: swuicnttab.hxx:133
std::unique_ptr< weld::ComboBox > m_xFirstKeyLB
Definition: swuicnttab.hxx:352
SwTokenWindow * m_pParent
Definition: cnttab.cxx:1386
bool IsProtected() const
Definition: tox.hxx:547
SW_DLLPUBLIC void FillCharStyleListBox(weld::ComboBox &rToFill, SwDocShell *pDocSh, bool bSorted=false, bool bWithDefault=false)
Definition: uitool.cxx:791
sal_uInt16 nOutlineLevel
Definition: tox.hxx:255
virtual bool FillItemSet(SfxItemSet *) override
Definition: cnttab.cxx:3363
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:413
Definition: tox.hxx:316
void SetSequenceName(const OUString &rSet)
Definition: toxmgr.hxx:125
const OUString & GetSequenceName() const
Definition: toxmgr.hxx:124
sal_uInt16 GetTextFormatCollCount() const
Definition: edfcol.cxx:692
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:519
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:1964
SwForm * GetForm(CurTOXType eType)
Definition: cnttab.cxx:335
#define TOX_STYLE_DELIMITER
Definition: tox.hxx:426
std::unique_ptr< weld::RadioButton > m_xSortDocPosRB
Definition: swuicnttab.hxx:349
#define ITEM_COMMENT
Definition: cnttab.cxx:3540
only chapter number without post-/prefix
Definition: chpfld.hxx:35
void CreateOrUpdateExample(TOXTypes nTOXIndex, sal_uInt16 nPage=0, sal_uInt16 nCurLevel=USHRT_MAX)
Definition: cntex.cxx:126
constexpr sal_uInt8 MAXLEVEL
Definition: swtypes.hxx:90
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:3373
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:2162
SfxItemSet * GetInputSetImpl()
OUString const & GetTOIAutoMarkURL() const
AutoMark file.
Definition: edtox.cxx:258
sal_uInt16 GetFormMax() const
Definition: tox.hxx:699
std::unique_ptr< weld::CheckButton > m_xFromFramesCB
Definition: swuicnttab.hxx:149
static OUString GetFormTab()
Definition: tox.cxx:517
virtual void get_extents_relative_to(weld::Widget &rRelative, int &x, int &y, int &width, int &height)=0
static OUString decode(std::u16string_view rText, DecodeMechanism eMechanism, rtl_TextEncoding eCharset=RTL_TEXTENCODING_UTF8)
void SetLevel(sal_uInt8 nSet)
Definition: toxmgr.hxx:118
void SetWrtShell(SwWrtShell &rSh)
Definition: cnttab.cxx:2507
std::unique_ptr< weld::RadioButton > m_xFirstSortUpRB
Definition: swuicnttab.hxx:353
sal_uInt16 nPoolId
Definition: tox.hxx:252
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:280
virtual void Reset(const SfxItemSet *) override
Definition: cnttab.cxx:3368
IMPL_LINK(SwAddStylesDlg_Impl, TreeSizeAllocHdl, const Size &, rSize, void)
Definition: cnttab.cxx:577
DrawTextFlags
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:257
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:348
Used by the UI to modify the document model.
Definition: wrtsh.hxx:93
constexpr tools::Long Width() const
virtual short Ok()
SwTextFormatColl & GetTextFormatColl(sal_uInt16 nTextFormatColl) const
Definition: edfcol.cxx:697
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:114
OUString m_sAdditionalAccnameString1
Definition: swuicnttab.hxx:236
const SwTOXSortKey * GetSortKey(sal_uInt16 nIdx) const
Definition: authfld.cxx:435
std::unique_ptr< weld::RadioButton > m_xSortContentRB
Definition: swuicnttab.hxx:350
const SwTOXType * GetTOXType() const
Definition: tox.hxx:714
OUString m_sAccessibleName
Definition: swuicnttab.hxx:235
std::unique_ptr< weld::CheckButton > m_xFromHeadingsCB
Definition: swuicnttab.hxx:143
const SwView & GetView() const
Definition: wrtsh.hxx:431
sal_Unicode GetPrefix() const
Definition: authfld.hxx:119
ErrCode GetError() const
virtual WindowType GetType() const override
Definition: cnttab.cxx: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
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:248
const OUString & GetName() const
Definition: format.hxx:115
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:1935
int nCount
virtual void Hide() override
Definition: cnttab.cxx:1579
bool IsLevelFromChapter() const
Definition: toxmgr.hxx:139
#define TO_USER
Definition: cnttab.hxx:34
static SW_DLLPUBLIC sal_uInt16 GetPoolIdFromUIName(const OUString &rName, SwGetPoolIdFromName)
void UpdateDescriptor()
Definition: cnttab.cxx:2069
SvStream * GetOutStream()
virtual void GrabFocus() override
Definition: cnttab.cxx:1414
static OUString GetFormEntry()
Definition: tox.cxx:516
std::unique_ptr< weld::Button > m_xLeftScrollWin
Definition: swuicnttab.hxx:246
void SetAuthBrackets(const OUString &rSet)
Definition: toxmgr.hxx:143
virtual short Ok() override
Definition: cnttab.cxx:309
OUString sAddStyleContent
Definition: swuicnttab.hxx:125
void SetTitle(const OUString &rSet)
Definition: toxmgr.hxx:100
const OUString & GetSequenceName() const
Definition: tox.hxx:550
std::unique_ptr< weld::Builder > m_xBuilder
Definition: cnttab.cxx:1545
#define ITEM_SEARCH
Definition: cnttab.cxx:3536
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:523
#define ITEM_ALTERNATIVE
Definition: cnttab.cxx:3537
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:2952
float y
Link< SwTOXWidget &, void > aGetFocusLink
Definition: cnttab.cxx:1368
bool IsFromChapter() const
Definition: toxmgr.hxx:131
static OUString GetFormEntryNum()
Definition: tox.cxx:521
#define SAL_N_ELEMENTS(arr)
OUString m_aButtonTexts[TOKEN_END]
Definition: swuicnttab.hxx:229
DocumentType eType
void SetFromChapter(bool bSet)
Definition: toxmgr.hxx:130
sal_Int32 m_nLevel
std::unique_ptr< weld::RadioButton > m_xFromCaptionsRB
Definition: swuicnttab.hxx:155
void SetText(const OUString &rText)
Definition: cnttab.cxx:1665
std::unique_ptr< weld::CheckButton > m_xUseFFCB
Definition: swuicnttab.hxx:170
weld::Window * GetFrameWeld(const SfxFrame *pFrame)
Definition: dialoghelp.cxx:19
OUString GetString() const
Definition: tox.cxx:663
SwTOXWidget * InsertItem(const OUString &rText, const SwFormToken &aToken)
Definition: cnttab.cxx:2687
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:3006
::svt::EditBrowseBox SwEntryBrowseBox_Base
Definition: cnttab.cxx:128
const SwFormToken & GetFormToken()
Definition: cnttab.cxx:1475
OUString GetPattern() const
Definition: cnttab.cxx:3133
const OUString & GetUserConfigPath() const
#define SW_MOD()
Definition: swmodule.hxx:256
Link< SwFormToken &, void > m_aButtonSelectedHdl
Definition: swuicnttab.hxx:232
sal_uInt8 GetLevel() const
Definition: toxmgr.hxx:119
std::unique_ptr< weld::Label > m_xLevelFT
Definition: swuicnttab.hxx:317
sal_uInt32 GetControlIndex(FormTokenType eType) const
Definition: cnttab.cxx:3309
bool Contains(FormTokenType) const
Definition: cnttab.cxx:3153
virtual void Reset(const SfxItemSet *) override
Definition: cnttab.cxx:1941
SW_DLLPUBLIC FieldUnit GetDfltMetric(bool bWeb)
Definition: uitool.cxx:766
bool m_bWaitingInitialSettings
Definition: swuicnttab.hxx:129
int i
const SwTOXBase * GetDefaultTOXBase(TOXTypes eTyp, bool bCreate=false)
Definition: edtox.cxx:111
static OUString const & GetAuthFieldName(ToxAuthorityField eType)
Definition: initui.cxx:242
SwTOXElement
Definition: tox.hxx:368
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:251
const SwFormTokens & GetPattern(sal_uInt16 nLevel) const
Definition: tox.cxx:951
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:249
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:541
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
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:120
std::unique_ptr< weld::ComboBox > m_xBracketLB
Definition: swuicnttab.hxx:183
float u
std::unique_ptr< SwTOXDescription > CreateTOXDescFromTOXBase(const SwTOXBase *pCurTOX)
Definition: cnttab.cxx:382
void SetAccessibleName(const OUString &rName)
Definition: cnttab.cxx: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:706
static OUString GetFormChapterMark()
Definition: tox.cxx:523
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
bool WriteByteStringLine(std::u16string_view rStr, rtl_TextEncoding eDestCharSet)
#define ITEM_SEC_KEY
Definition: cnttab.cxx:3539
std::unique_ptr< weld::CheckButton > m_xUseDashCB
Definition: swuicnttab.hxx:171
virtual DeactivateRC DeactivatePage(SfxItemSet *pSet) override
Definition: cnttab.cxx:2103
sal_uInt16 nChapterFormat
Definition: tox.hxx:254
SwForm * m_pForm
Definition: swuicnttab.hxx:226
void SetAccessibleName(const OUString &rName)
Definition: cnttab.cxx:1429
bool IsSequence() const
Definition: authfld.hxx:107
void SetSortAlgorithm(const OUString &rSet)
Definition: toxmgr.hxx:163
sal_uInt16 GetFlatIndex() const
Definition: cnttab.cxx:190
BrowserMode
sal_uInt16 nAuthorityField
Definition: tox.hxx:256
virtual bool FillItemSet(SfxItemSet *) override
Definition: cnttab.cxx:818
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:538
sal_uInt16 GetLevel() const
Definition: tox.hxx:750
virtual ~SwTOXEntryTabPage() override
Definition: cnttab.cxx:1904
OUString m_sAdditionalAccnameString3
Definition: swuicnttab.hxx:238
void SetCreateFromObjectNames(bool bSet)
Definition: toxmgr.hxx:121
const OUString & GetTitle() const
Definition: tox.hxx:720
void AdjustPositions()
Definition: cnttab.cxx:2999
bool bSortAscending
Definition: authfld.hxx:53
static std::unique_ptr< SfxTabPage > Create(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet *rAttrSet)
Definition: cnttab.cxx:3447
tools::Long SwTwips
Definition: swtypes.hxx:50
void SetCurrentTOXType(const CurTOXType &eSet)
Definition: swuicnttab.hxx:101
SwCaptionDisplay GetCaptionDisplay() const
Definition: tox.hxx:553
SwDocShell * GetDocShell()
Definition: view.cxx:1122
SwTOXStylesTabPage(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet &rAttrSet)
Definition: cnttab.cxx:3336
void SetForm(SwForm &rForm, sal_uInt16 nLevel)
Definition: cnttab.cxx:2594
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:1767
void SetDefaultTOXBase(const SwTOXBase &rBase)
Definition: edtox.cxx:116
const OUString & GetSortAlgorithm() const
Definition: tox.hxx:564
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:3538
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:3541
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:3542
void AdjustSize()
Definition: cnttab.cxx:1536
bool IsRelTabPos() const
Definition: tox.hxx:347
bool IsShift() const
const SwGetSetExpType GSE_SEQ
Sequence.
Definition: fldbas.hxx:204
void WriteBackLevel()
Definition: cnttab.cxx:2229
SwTokenWindow(std::unique_ptr< weld::Container > xParent)
Definition: cnttab.cxx:2552
void SetTabPosition(SwTwips nSet)
Definition: cnttab.cxx:1622
ToxAuthorityField eField
Definition: authfld.hxx:52
constexpr sal_uInt16 KEY_SUBTRACT
weld::Entry & rEdit
std::optional< OUString > const & GetTitle() const
Definition: toxmgr.hxx:101
SwTwips nTabStopPosition
Definition: tox.hxx:250
LanguageType GetLanguage() const
Definition: toxmgr.hxx:159
TOXTypes eType
Definition: cnttab.hxx:41
SwMultiTOXTabDialog(weld::Widget *pParent, const SfxItemSet &rSet, SwWrtShell &rShell, SwTOXBase *pCurTOX, sal_uInt16 nToxType, bool bGlobal)
Definition: cnttab.cxx:196
std::unique_ptr< weld::CheckButton > m_xFromGraphicsCB
Definition: swuicnttab.hxx:150
WindowType
std::unique_ptr< weld::Widget > m_xFormatFrame
Definition: swuicnttab.hxx:342
virtual OUString GetName() const
Only in derived classes.
Definition: fldbas.cxx:136
virtual DeactivateRC DeactivatePage(SfxItemSet *pSet) override
Definition: cnttab.cxx:3441
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
constexpr tools::Long Height() const
WinBits const WB_BORDER
void InsertAtSelection(const SwFormToken &aToken)
Definition: cnttab.cxx:2753
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:466
TOXTypes GetType() const
Definition: tox.hxx:741
OUString const & GetStyleNames(sal_uInt16 nLevel) const
Definition: tox.hxx:528
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:561
bool IsCommaSeparated() const
Definition: tox.hxx:350
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:448
void SetStreamCharSet(rtl_TextEncoding eCharSet)
std::unique_ptr< weld::RadioButton > m_xThirdSortUpRB
Definition: swuicnttab.hxx:359
void AddTabPage(const OString &rName, CreateTabPage pCreateFunc, GetTabPageRanges pRangesFunc)
std::unique_ptr< weld::CheckButton > m_xSequenceCB
Definition: swuicnttab.hxx:182
virtual void Hide()=0
Reference< XExecutableDialog > m_xDialog
#define FORM_ALPHA_DELIMITER
Definition: tox.hxx:210
static const OUString & GetUIName(const OUString &rName, SwGetPoolIdFromName)
static OUString GetFormLinkEnd()
Definition: tox.cxx:520
QPRO_FUNC_TYPE nType
std::unique_ptr< weld::Button > m_xAssignBT
Definition: swuicnttab.hxx:407
SfxOkDialogController * GetDialogController() const
static OUString GetFormEntryText()
Definition: tox.cxx:522
Sequence< sal_Int8 > aSeq
void AdjustScrolling()
Definition: cnttab.cxx:3016
SwTOXBase * m_pParamTOXBase
Definition: swuicnttab.hxx:68
OUString CreateQuickHelp(const SwFormToken &rToken)
Definition: cnttab.cxx:3174
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:203
std::unique_ptr< weld::Entry > m_xEntry
Definition: cnttab.cxx:1387
void SetText(const OUString &rText)
Definition: cnttab.cxx:1449
void SetLinkEnd()
Definition: cnttab.cxx:1670
virtual DeactivateRC DeactivatePage(SfxItemSet *pSet) override
Definition: cnttab.cxx:1152
const OUString & GetMainEntryCharStyle() const
Definition: tox.hxx:507
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:3301
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:2538
SvxTabAdjust eTabAlign
Definition: tox.hxx:253
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:588
void Show()
Definition: cnttab.cxx:1584
void SetCharStyleName(const OUString &rSet, sal_uInt16 nPoolId)
Definition: cnttab.cxx:1481
bool IsSortByDocument() const
Definition: authfld.hxx:122
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:810
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:2666
void SetContentOptions(SwTOXElement nSet)
Definition: toxmgr.hxx:109
static const char * STR_TOKEN_ARY[]
Definition: cnttab.cxx:2524
weld::Container * get_child_container()
Definition: swuicnttab.hxx:270
const OUString & GetStyleNames(sal_uInt16 nLvl) const
Definition: toxmgr.hxx:92
OUString sNoCharStyle
Definition: swuicnttab.hxx:310
std::unique_ptr< weld::Button > m_xChapterInfoPB
Definition: swuicnttab.hxx:323
static std::unique_ptr< SfxTabPage > Create(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet *rAttrSet)
Definition: cnttab.cxx:2109
sal_uInt16 nIndex
Definition: cnttab.hxx:42
void SetCommaSeparated(bool b)
Definition: tox.hxx:351
const SwForm & GetTOXForm() const
Definition: tox.hxx:732
#define TOX_PAGE_STYLES
Definition: cnttab.hxx:28
std::unique_ptr< weld::CheckButton > m_xLevelFromChapterCB
Definition: swuicnttab.hxx:152
std::unique_ptr< weld::CheckButton > m_xInitialCapsCB
Definition: swuicnttab.hxx:173
TriState
bool bNextControl
Definition: cnttab.cxx:1548
OUString SwResId(std::string_view aId)
Definition: swmodule.cxx:165
constexpr OUStringLiteral first