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