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