LibreOffice Module sw (master)  1
fldref.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 <swtypes.hxx>
21 #include <IMark.hxx>
22 #include <expfld.hxx>
23 #include <swmodule.hxx>
24 #include "fldref.hxx"
25 #include <reffld.hxx>
26 #include <wrtsh.hxx>
27 
28 #include <fldref.hrc>
29 #include <strings.hrc>
30 #include <SwNodeNum.hxx>
31 #include <IDocumentMarkAccess.hxx>
33 #include <unotools/charclass.hxx>
34 
35 #include <comphelper/string.hxx>
36 #include <o3tl/safeint.hxx>
37 
38 #define REFFLDFLAG 0x4000
39 #define REFFLDFLAG_BOOKMARK 0x4800
40 #define REFFLDFLAG_FOOTNOTE 0x5000
41 #define REFFLDFLAG_ENDNOTE 0x6000
42 // #i83479#
43 #define REFFLDFLAG_HEADING 0x7100
44 #define REFFLDFLAG_NUMITEM 0x7200
45 
46 static sal_uInt16 nFieldDlgFormatSel = 0;
47 
48 #define USER_DATA_VERSION_1 "1"
49 #define USER_DATA_VERSION USER_DATA_VERSION_1
50 
52  : SwFieldPage(pPage, pController, "modules/swriter/ui/fldrefpage.ui", "FieldRefPage", pCoreSet)
53  , maOutlineNodes()
54  , maNumItems()
55  , mpSavedSelectedTextNode(nullptr)
56  , mnSavedSelectedPos(0)
57  , m_xTypeLB(m_xBuilder->weld_tree_view("type"))
58  , m_xSelection(m_xBuilder->weld_widget("selectframe"))
59  , m_xSelectionLB(m_xBuilder->weld_tree_view("select"))
60  , m_xSelectionToolTipLB(m_xBuilder->weld_tree_view("selecttip"))
61  , m_xFormat(m_xBuilder->weld_widget("formatframe"))
62  , m_xFormatLB(m_xBuilder->weld_tree_view("format"))
63  , m_xNameFT(m_xBuilder->weld_label("nameft"))
64  , m_xNameED(m_xBuilder->weld_entry("name"))
65  , m_xValueED(m_xBuilder->weld_entry("value"))
66  , m_xFilterED(m_xBuilder->weld_entry("filter"))
67 {
68  m_xSelectionLB->make_sorted();
69  // #i83479#
70  for (size_t i = 0; i < SAL_N_ELEMENTS(FLD_REF_PAGE_TYPES); ++i)
71  {
72  m_xTypeLB->append_text(SwResId(FLD_REF_PAGE_TYPES[i]));
73  m_xFormatLB->append_text(SwResId(FLD_REF_PAGE_TYPES[i]));
74  }
75 
76  sBookmarkText = m_xTypeLB->get_text(0);
77  sFootnoteText = m_xTypeLB->get_text(1);
78  sEndnoteText = m_xTypeLB->get_text(2);
79  // #i83479#
80  sHeadingText = m_xTypeLB->get_text(3);
81  sNumItemText = m_xTypeLB->get_text(4);
82 
83  auto nHeight = m_xTypeLB->get_height_rows(8);
84  auto nWidth = m_xTypeLB->get_approximate_digit_width() * FIELD_COLUMN_WIDTH;
85  m_xTypeLB->set_size_request(nWidth, nHeight);
86  m_xFormatLB->set_size_request(nWidth, nHeight);
87  m_xSelection->set_size_request(nWidth * 2, nHeight);
88  nHeight = m_xTypeLB->get_height_rows(20);
89  m_xSelectionToolTipLB->set_size_request(nHeight, nWidth*2);
90 
91  m_xTypeLB->clear();
92 
93  m_xNameED->connect_changed(LINK(this, SwFieldRefPage, ModifyHdl));
94  m_xFilterED->connect_changed( LINK( this, SwFieldRefPage, ModifyHdl_Impl ) );
95 
96  m_xTypeLB->connect_row_activated(LINK(this, SwFieldRefPage, TreeViewInsertHdl));
97  m_xTypeLB->connect_changed(LINK(this, SwFieldRefPage, TypeHdl));
98  m_xSelectionLB->connect_changed(LINK(this, SwFieldRefPage, SubTypeListBoxHdl));
99  m_xSelectionLB->connect_row_activated(LINK(this, SwFieldRefPage, TreeViewInsertHdl));
100  m_xFormatLB->connect_row_activated(LINK(this, SwFieldRefPage, TreeViewInsertHdl));
101 
102  // #i83479#
103  m_xSelectionToolTipLB->connect_changed( LINK(this, SwFieldRefPage, SubTypeTreeListBoxHdl) );
104  m_xSelectionToolTipLB->connect_row_activated( LINK(this, SwFieldRefPage, TreeViewInsertHdl) );
105  m_xFilterED->grab_focus();
106 }
107 
109 {
110 }
111 
113 {
114  UpdateSubType(comphelper::string::strip(m_xFilterED->get_text(), ' '));
115 }
116 
117 // #i83479#
119 {
120  mpSavedSelectedTextNode = nullptr;
121  mnSavedSelectedPos = 0;
122  if ( !m_xSelectionToolTipLB->get_visible() )
123  return;
124 
125  int nEntry = m_xSelectionToolTipLB->get_selected_index();
126  if (nEntry == -1)
127  return;
128 
129  const sal_uInt16 nTypeId = m_xTypeLB->get_id(GetTypeSel()).toUInt32();
130 
131  if ( nTypeId == REFFLDFLAG_HEADING )
132  {
133  mnSavedSelectedPos = m_xSelectionToolTipLB->get_id(nEntry).toUInt32();
134  if ( mnSavedSelectedPos < maOutlineNodes.size() )
135  {
137  }
138  }
139  else if ( nTypeId == REFFLDFLAG_NUMITEM )
140  {
141  mnSavedSelectedPos = m_xSelectionToolTipLB->get_id(nEntry).toUInt32();
142  if ( mnSavedSelectedPos < maNumItems.size() )
143  {
145  }
146  }
147 }
148 
150 {
151  if (!IsFieldEdit())
152  {
153  SavePos(*m_xTypeLB);
154  // #i83479#
156  }
157  SetSelectionSel(-1);
158  SetTypeSel(-1);
159  Init(); // general initialisation
160 
161  // initialise TypeListBox
162  m_xTypeLB->freeze();
163  m_xTypeLB->clear();
164 
165  // fill Type-Listbox
166 
167  // set/insert reference
169 
170  for (short i = rRg.nStart; i < rRg.nEnd; ++i)
171  {
172  const SwFieldTypesEnum nTypeId = SwFieldMgr::GetTypeId(i);
173 
174  if (!IsFieldEdit() || nTypeId != SwFieldTypesEnum::SetRef)
175  {
176  m_xTypeLB->append(OUString::number(static_cast<sal_uInt16>(nTypeId)), SwFieldMgr::GetTypeStr(i));
177  }
178  }
179 
180  // #i83479#
181  // entries for headings and numbered items
182  m_xTypeLB->append(OUString::number(REFFLDFLAG_HEADING), sHeadingText);
183  m_xTypeLB->append(OUString::number(REFFLDFLAG_NUMITEM), sNumItemText);
184 
185  // fill up with the sequence types
186  SwWrtShell *pSh = GetWrtShell();
187  if (!pSh)
188  pSh = ::GetActiveWrtShell();
189 
190  if (!pSh)
191  return;
192 
193  const size_t nFieldTypeCnt = pSh->GetFieldTypeCount(SwFieldIds::SetExp);
194 
195  OSL_ENSURE( nFieldTypeCnt < o3tl::make_unsigned(REFFLDFLAG), "<SwFieldRefPage::Reset> - Item index will overlap flags!" );
196 
197  for (size_t n = 0; n < nFieldTypeCnt; ++n)
198  {
200 
201  if ((nsSwGetSetExpType::GSE_SEQ & pType->GetType()) && pType->HasWriterListeners() && pSh->IsUsed(*pType))
202  {
203  m_xTypeLB->append(OUString::number(REFFLDFLAG | n), pType->GetName());
204  }
205  }
206 
207  // text marks - now always (because of globaldocuments)
208  m_xTypeLB->append(OUString::number(REFFLDFLAG_BOOKMARK), sBookmarkText);
209 
210  // footnotes:
211  if( pSh->HasFootnotes() )
212  {
213  m_xTypeLB->append(OUString::number(REFFLDFLAG_FOOTNOTE), sFootnoteText);
214  }
215 
216  // endnotes:
217  if ( pSh->HasFootnotes(true) )
218  {
219  m_xTypeLB->append(OUString::number(REFFLDFLAG_ENDNOTE), sEndnoteText);
220  }
221 
222  m_xTypeLB->thaw();
223 
224  // select old Pos
225  if (!IsFieldEdit())
227 
228  nFieldDlgFormatSel = 0;
229 
230  sal_uInt16 nFormatBoxPosition = USHRT_MAX;
231  if( !IsRefresh() )
232  {
233  sal_Int32 nIdx{ 0 };
234  const OUString sUserData = GetUserData();
235  if(!IsRefresh() && sUserData.getToken(0, ';', nIdx).
237  {
238  const sal_uInt16 nVal = static_cast< sal_uInt16 >(sUserData.getToken(0, ';', nIdx).toInt32());
239  if(nVal != USHRT_MAX)
240  {
241  for(sal_Int32 i = 0, nEntryCount = m_xTypeLB->n_children(); i < nEntryCount; ++i)
242  {
243  if (nVal == m_xTypeLB->get_id(i).toUInt32())
244  {
245  m_xTypeLB->select(i);
246  break;
247  }
248  }
249  if (nIdx>=0 && nIdx<sUserData.getLength())
250  {
251  nFormatBoxPosition = static_cast< sal_uInt16 >(sUserData.getToken(0, ';', nIdx).toInt32());
252  }
253  }
254  }
255  }
256  TypeHdl(*m_xTypeLB);
257  if (nFormatBoxPosition < m_xFormatLB->n_children())
258  {
259  m_xFormatLB->select(nFormatBoxPosition);
260  }
261  if (IsFieldEdit())
262  {
263  m_xTypeLB->save_value();
264  m_xSelectionLB->save_value();
265  m_xFormatLB->save_value();
266  m_xNameED->save_value();
267  m_xValueED->save_value();
268  m_xFilterED->set_text(OUString());
269  }
270 }
271 
273 {
274  // save old ListBoxPos
275  const sal_Int32 nOld = GetTypeSel();
276 
277  // current ListBoxPos
278  SetTypeSel(m_xTypeLB->get_selected_index());
279 
280  if(GetTypeSel() == -1)
281  {
282  if (IsFieldEdit())
283  {
284  // select positions
285  OUString sName;
286  sal_uInt16 nFlag = 0;
287 
288  switch( GetCurField()->GetSubType() )
289  {
290  case REF_BOOKMARK:
291  {
292  // #i83479#
293  SwGetRefField* pRefField = dynamic_cast<SwGetRefField*>(GetCurField());
294  if ( pRefField &&
295  pRefField->IsRefToHeadingCrossRefBookmark() )
296  {
297  sName = sHeadingText;
298  nFlag = REFFLDFLAG_HEADING;
299  }
300  else if ( pRefField &&
301  pRefField->IsRefToNumItemCrossRefBookmark() )
302  {
303  sName = sNumItemText;
304  nFlag = REFFLDFLAG_NUMITEM;
305  }
306  else
307  {
308  sName = sBookmarkText;
309  nFlag = REFFLDFLAG_BOOKMARK;
310  }
311  }
312  break;
313 
314  case REF_FOOTNOTE:
315  sName = sFootnoteText;
316  nFlag = REFFLDFLAG_FOOTNOTE;
317  break;
318 
319  case REF_ENDNOTE:
320  sName = sEndnoteText;
321  nFlag = REFFLDFLAG_ENDNOTE;
322  break;
323 
324  case REF_SETREFATTR:
325  sName = SwResId(STR_GETREFFLD);
326  nFlag = REF_SETREFATTR;
327  break;
328 
329  case REF_SEQUENCEFLD:
330  sName = static_cast<SwGetRefField*>(GetCurField())->GetSetRefName();
331  nFlag = REFFLDFLAG;
332  break;
333  }
334 
335  if (m_xTypeLB->find_text(sName) == -1) // reference to deleted mark
336  {
337  m_xTypeLB->append(OUString::number(nFlag), sName);
338  }
339 
340  m_xTypeLB->select_text(sName);
341  SetTypeSel(m_xTypeLB->get_selected_index());
342  }
343  else
344  {
345  SetTypeSel(0);
346  m_xTypeLB->select(0);
347  }
348  }
349 
350  if (nOld == GetTypeSel())
351  return;
352 
353  sal_uInt16 nTypeId = m_xTypeLB->get_id(GetTypeSel()).toUInt32();
354 
355  // fill selection-ListBox
356  UpdateSubType(comphelper::string::strip(m_xFilterED->get_text(), ' '));
357 
358  bool bName = false;
359  nFieldDlgFormatSel = 0;
360 
361  if ( ( !IsFieldEdit() || m_xSelectionLB->n_children() ) &&
362  nOld != -1 )
363  {
364  m_xNameED->set_text(OUString());
365  m_xValueED->set_text(OUString());
366  m_xFilterED->set_text(OUString());
367  }
368 
369  switch (nTypeId)
370  {
371  case static_cast<sal_uInt16>(SwFieldTypesEnum::GetRef):
372  if (nOld != -1 && REFFLDFLAG & m_xTypeLB->get_id(nOld).toUInt32())
373  // the old one stays
374  nFieldDlgFormatSel = m_xFormatLB->get_selected_index();
375  bName = true;
376  break;
377 
378  case static_cast<sal_uInt16>(SwFieldTypesEnum::SetRef):
379  bName = true;
380  break;
381 
382  case REFFLDFLAG_BOOKMARK:
383  bName = true;
384  [[fallthrough]];
385  default:
386  if( REFFLDFLAG & nTypeId )
387  {
388  const sal_uInt16 nOldId = nOld != -1 ? m_xTypeLB->get_id(nOld).toUInt32() : 0;
389  if( nOldId & REFFLDFLAG || nOldId == static_cast<sal_uInt16>(SwFieldTypesEnum::GetRef) )
390  // then the old one stays
391  nFieldDlgFormatSel = m_xFormatLB->get_selected_index();
392  }
393  break;
394  }
395 
396  m_xNameED->set_sensitive(bName);
397  m_xNameFT->set_sensitive(bName);
398 
399  // fill Format-Listbox
400  sal_Int32 nSize = FillFormatLB(nTypeId);
401  bool bFormat = nSize != 0;
402  m_xFormat->set_sensitive(bFormat);
403 
404  SubTypeHdl();
405  ModifyHdl(*m_xNameED);
406  ModifyHdl(*m_xFilterED);
407 }
408 
409 IMPL_LINK_NOARG(SwFieldRefPage, SubTypeTreeListBoxHdl, weld::TreeView&, void)
410 {
411  SubTypeHdl();
412 }
413 
414 IMPL_LINK_NOARG(SwFieldRefPage, SubTypeListBoxHdl, weld::TreeView&, void)
415 {
416  SubTypeHdl();
417 }
418 
420 {
421  sal_uInt16 nTypeId = m_xTypeLB->get_id(GetTypeSel()).toUInt32();
422 
423  switch(nTypeId)
424  {
425  case static_cast<sal_uInt16>(SwFieldTypesEnum::GetRef):
426  if (!IsFieldEdit() || m_xSelectionLB->get_selected_index() != -1)
427  {
428  m_xNameED->set_text(m_xSelectionLB->get_selected_text());
429  ModifyHdl(*m_xNameED);
430  }
431  break;
432 
433  case static_cast<sal_uInt16>(SwFieldTypesEnum::SetRef):
434  {
435  SwWrtShell *pSh = GetWrtShell();
436  if(!pSh)
437  pSh = ::GetActiveWrtShell();
438  if(pSh)
439  {
440  m_xValueED->set_text(pSh->GetSelText());
441  }
442 
443  }
444  break;
445  // #i83479#
446  case REFFLDFLAG_HEADING:
447  case REFFLDFLAG_NUMITEM:
448  {
449  int nEntry = m_xSelectionToolTipLB->get_selected_index();
450  if (nEntry != -1)
451  m_xNameED->set_text(m_xSelectionToolTipLB->get_text(nEntry));
452  }
453  break;
454 
455  default:
456  if (!IsFieldEdit() || m_xSelectionLB->get_selected_index() != -1)
457  m_xNameED->set_text(m_xSelectionLB->get_selected_text());
458  break;
459  }
460 }
461 
462 // renew types in SelectionLB after filtering
463 void SwFieldRefPage::UpdateSubType(const OUString& filterString)
464 {
465  SwWrtShell *pSh = GetWrtShell();
466  if(!pSh)
467  pSh = ::GetActiveWrtShell();
468  SwGetRefField* pRefField = static_cast<SwGetRefField*>(GetCurField());
469  const sal_uInt16 nTypeId = m_xTypeLB->get_id(GetTypeSel()).toUInt32();
470 
471  OUString sOldSel;
472  // #i83479#
473  if ( m_xSelectionLB->get_visible() )
474  {
475  const sal_Int32 nSelectionSel = m_xSelectionLB->get_selected_index();
476  if (nSelectionSel != -1)
477  sOldSel = m_xSelectionLB->get_text(nSelectionSel);
478  }
479  if (IsFieldEdit() && sOldSel.isEmpty())
480  sOldSel = OUString::number( pRefField->GetSeqNo() + 1 );
481 
482  m_xSelectionLB->freeze();
483  m_xSelectionLB->clear();
484 
485  if (REFFLDFLAG & nTypeId)
486  {
487  if (nTypeId == REFFLDFLAG_FOOTNOTE || nTypeId == REFFLDFLAG_ENDNOTE)
488  {
489  m_xSelectionLB->thaw();
490  m_xSelectionLB->make_unsorted();
491  m_xSelectionLB->freeze();
492  }
493  // #i83479#
494  else if (nTypeId != REFFLDFLAG_HEADING && nTypeId != REFFLDFLAG_NUMITEM)
495  {
496  m_xSelectionLB->thaw();
497  m_xSelectionLB->make_sorted();
498  m_xSelectionLB->freeze();
499  }
500  }
501 
502  // #i83479#
503  m_xSelectionToolTipLB->freeze();
504  m_xSelectionToolTipLB->clear();
505  OUString m_sSelectionToolTipLBId;
506  bool bShowSelectionToolTipLB( false );
507 
508  if( REFFLDFLAG & nTypeId )
509  {
510  if (nTypeId == REFFLDFLAG_BOOKMARK) // text marks!
511  {
512  // get all text marks
513  IDocumentMarkAccess* const pMarkAccess = pSh->getIDocumentMarkAccess();
514  for(IDocumentMarkAccess::const_iterator_t ppMark = pMarkAccess->getBookmarksBegin();
515  ppMark != pMarkAccess->getBookmarksEnd();
516  ++ppMark)
517  {
518  const ::sw::mark::IMark* pBkmk = *ppMark;
520  {
521  bool isSubstring = MatchSubstring(pBkmk->GetName(), filterString);
522  if(isSubstring)
523  {
524  m_xSelectionLB->append_text( pBkmk->GetName() );
525  }
526  }
527  }
528  if (IsFieldEdit())
529  sOldSel = pRefField->GetSetRefName();
530  }
531  else if (nTypeId == REFFLDFLAG_FOOTNOTE)
532  {
534  const size_t nCnt = pSh->GetSeqFootnoteList( aArr );
535 
536  for( size_t n = 0; n < nCnt; ++n )
537  {
538  bool isSubstring = MatchSubstring(aArr[ n ].sDlgEntry, filterString);
539  if(isSubstring)
540  {
541  m_xSelectionLB->append_text( aArr[ n ].sDlgEntry );
542  }
543  if (IsFieldEdit() && pRefField->GetSeqNo() == aArr[ n ].nSeqNo)
544  sOldSel = aArr[n].sDlgEntry;
545  }
546  }
547  else if (nTypeId == REFFLDFLAG_ENDNOTE)
548  {
550  const size_t nCnt = pSh->GetSeqFootnoteList( aArr, true );
551 
552  for( size_t n = 0; n < nCnt; ++n )
553  {
554  bool isSubstring = MatchSubstring(aArr[ n ].sDlgEntry, filterString);
555  if(isSubstring)
556  {
557  m_xSelectionLB->append_text( aArr[ n ].sDlgEntry );
558  }
559  if (IsFieldEdit() && pRefField->GetSeqNo() == aArr[ n ].nSeqNo)
560  sOldSel = aArr[n].sDlgEntry;
561  }
562  }
563  // #i83479#
564  else if ( nTypeId == REFFLDFLAG_HEADING )
565  {
566  bShowSelectionToolTipLB = true;
567 
570  bool bCertainTextNodeSelected( false );
571  for ( size_t nOutlIdx = 0; nOutlIdx < maOutlineNodes.size(); ++nOutlIdx )
572  {
573  if (!pIDoc->isOutlineInLayout(nOutlIdx, *pSh->GetLayout()))
574  {
575  continue; // skip it
576  }
577  bool isSubstring = MatchSubstring(pIDoc->getOutlineText(nOutlIdx, pSh->GetLayout(), true, true, false), filterString);
578  if(isSubstring)
579  {
580  OUString sId(OUString::number(nOutlIdx));
581  m_xSelectionToolTipLB->append(sId,
582  pIDoc->getOutlineText(nOutlIdx, pSh->GetLayout(), true, true, false));
583  if ( ( IsFieldEdit() &&
584  pRefField->GetReferencedTextNode() == maOutlineNodes[nOutlIdx] ) ||
586  {
587  m_sSelectionToolTipLBId = sId;
588  sOldSel.clear();
589  bCertainTextNodeSelected = true;
590  }
591  else if ( !bCertainTextNodeSelected && mnSavedSelectedPos == nOutlIdx )
592  {
593  m_sSelectionToolTipLBId = sId;
594  sOldSel.clear();
595  }
596  }
597  }
598  }
599  else if ( nTypeId == REFFLDFLAG_NUMITEM )
600  {
601  bShowSelectionToolTipLB = true;
602 
603  const IDocumentListItems* pIDoc( pSh->getIDocumentListItemsAccess() );
604  pIDoc->getNumItems( maNumItems );
605  bool bCertainTextNodeSelected( false );
606  for ( size_t nNumItemIdx = 0; nNumItemIdx < maNumItems.size(); ++nNumItemIdx )
607  {
608  if (!pIDoc->isNumberedInLayout(*maNumItems[nNumItemIdx], *pSh->GetLayout()))
609  {
610  continue; // skip it
611  }
612  bool isSubstring = MatchSubstring(pIDoc->getListItemText(*maNumItems[nNumItemIdx], *pSh->GetLayout()), filterString);
613  if(isSubstring)
614  {
615  OUString sId(OUString::number(nNumItemIdx));
616  m_xSelectionToolTipLB->append(sId,
617  pIDoc->getListItemText(*maNumItems[nNumItemIdx], *pSh->GetLayout()));
618  if ( ( IsFieldEdit() &&
619  pRefField->GetReferencedTextNode() == maNumItems[nNumItemIdx]->GetTextNode() ) ||
620  mpSavedSelectedTextNode == maNumItems[nNumItemIdx]->GetTextNode() )
621  {
622  m_sSelectionToolTipLBId = sId;
623  sOldSel.clear();
624  bCertainTextNodeSelected = true;
625  }
626  else if ( !bCertainTextNodeSelected && mnSavedSelectedPos == nNumItemIdx )
627  {
628  m_sSelectionToolTipLBId = sId;
629  sOldSel.clear();
630  }
631  }
632  }
633  }
634  else
635  {
636  // get the fields to Seq-FieldType:
637 
638  SwSetExpFieldType* pType = static_cast<SwSetExpFieldType*>(pSh->GetFieldType(
639  nTypeId & ~REFFLDFLAG, SwFieldIds::SetExp ));
640  if( pType )
641  {
643  // old selection should be kept in non-edit mode
644  if(IsFieldEdit())
645  sOldSel.clear();
646 
647  const size_t nCnt = pType->GetSeqFieldList(aArr, pSh->GetLayout());
648  for( size_t n = 0; n < nCnt; ++n )
649  {
650  bool isSubstring = MatchSubstring(aArr[ n ].sDlgEntry, filterString);
651  if(isSubstring)
652  {
653  m_xSelectionLB->append_text( aArr[ n ].sDlgEntry );
654  }
655  if (IsFieldEdit() && sOldSel.isEmpty() &&
656  aArr[ n ].nSeqNo == pRefField->GetSeqNo())
657  sOldSel = aArr[ n ].sDlgEntry;
658  }
659 
660  if (IsFieldEdit() && sOldSel.isEmpty())
661  sOldSel = OUString::number( pRefField->GetSeqNo() + 1);
662  }
663  }
664  }
665  else
666  {
667  std::vector<OUString> aLst;
668  GetFieldMgr().GetSubTypes(static_cast<SwFieldTypesEnum>(nTypeId), aLst);
669  for(const OUString & i : aLst)
670  {
671  bool isSubstring = MatchSubstring( i , filterString );
672  if(isSubstring)
673  {
674  m_xSelectionLB->append_text(i);
675  }
676  }
677 
678  if (IsFieldEdit())
679  sOldSel = pRefField->GetSetRefName();
680  }
681 
682  // #i83479#
683  m_xSelectionLB->thaw();
684  m_xSelectionToolTipLB->thaw();
685  if (!m_sSelectionToolTipLBId.isEmpty())
686  m_xSelectionToolTipLB->select_id(m_sSelectionToolTipLBId);
687  m_xSelectionToolTipLB->set_visible( bShowSelectionToolTipLB );
688  m_xSelectionLB->set_visible( !bShowSelectionToolTipLB );
689  if ( bShowSelectionToolTipLB )
690  {
691  bool bEnable = m_xSelectionToolTipLB->n_children() != 0;
692  m_xSelection->set_sensitive( bEnable );
693 
694  int nEntry = m_xSelectionToolTipLB->get_selected_index();
695  if (nEntry != -1)
696  m_xSelectionToolTipLB->scroll_to_row(nEntry);
697 
698  if (IsFieldEdit() && nEntry == -1)
699  {
700  m_xNameED->set_text(sOldSel);
701  }
702  }
703  else
704  {
705  // enable or disable
706  bool bEnable = m_xSelectionLB->n_children() != 0;
707  m_xSelection->set_sensitive( bEnable );
708 
709  if ( bEnable )
710  {
711  m_xSelectionLB->select_text(sOldSel);
712  if (m_xSelectionLB->get_selected_index() == -1 && !IsFieldEdit())
713  m_xSelectionLB->select(0);
714  }
715 
716  if (IsFieldEdit() && m_xSelectionLB->get_selected_index() == -1) // in case the reference was already deleted...
717  m_xNameED->set_text(sOldSel);
718  }
719 }
720 
721 bool SwFieldRefPage::MatchSubstring( const OUString& rListString, const OUString& rSubstr )
722 {
723  if(rSubstr.isEmpty())
724  return true;
725  OUString aListString = GetAppCharClass().lowercase(rListString);
726  OUString aSubstr = GetAppCharClass().lowercase(rSubstr);
727  return aListString.indexOf(aSubstr) >= 0;
728 }
729 
730 namespace {
731 
733 {
734  FMT_REF_PAGE_IDX = 0,
735  FMT_REF_CHAPTER_IDX = 1,
736  FMT_REF_TEXT_IDX = 2,
737  FMT_REF_UPDOWN_IDX = 3,
738  FMT_REF_PAGE_PGDSC_IDX = 4,
739  FMT_REF_ONLYNUMBER_IDX = 5,
740  FMT_REF_ONLYCAPTION_IDX = 6,
741  FMT_REF_ONLYSEQNO_IDX = 7,
742  FMT_REF_NUMBER_IDX = 8,
743  FMT_REF_NUMBER_NO_CONTEXT_IDX = 9,
744  FMT_REF_NUMBER_FULL_CONTEXT_IDX = 10
745 };
746 
747 }
748 
749 static const char* FMT_REF_ARY[] =
750 {
751  FMT_REF_PAGE,
752  FMT_REF_CHAPTER,
753  FMT_REF_TEXT,
754  FMT_REF_UPDOWN,
755  FMT_REF_PAGE_PGDSC,
756  FMT_REF_ONLYNUMBER,
757  FMT_REF_ONLYCAPTION,
758  FMT_REF_ONLYSEQNO,
759  FMT_REF_NUMBER,
760  FMT_REF_NUMBER_NO_CONTEXT,
761  FMT_REF_NUMBER_FULL_CONTEXT
762 };
763 
764 sal_Int32 SwFieldRefPage::FillFormatLB(sal_uInt16 nTypeId)
765 {
766  OUString sOldSel;
767 
768  sal_Int32 nFormatSel = m_xFormatLB->get_selected_index();
769  if (nFormatSel != -1)
770  sOldSel = m_xFormatLB->get_text(nFormatSel);
771 
772  // fill Format-Listbox
773  m_xFormatLB->clear();
774 
775  // reference has less that the annotation
776  sal_uInt16 nSize( 0 );
777  bool bAddCrossRefFormats( false );
778  switch (nTypeId)
779  {
780  // #i83479#
781  case REFFLDFLAG_HEADING:
782  case REFFLDFLAG_NUMITEM:
783  bAddCrossRefFormats = true;
784  [[fallthrough]];
785 
786  case static_cast<sal_uInt16>(SwFieldTypesEnum::GetRef):
787  case REFFLDFLAG_BOOKMARK:
788  case REFFLDFLAG_FOOTNOTE:
789  case REFFLDFLAG_ENDNOTE:
790  nSize = FMT_REF_PAGE_PGDSC_IDX + 1;
791  break;
792 
793  default:
794  // #i83479#
795 
796  if ( REFFLDFLAG & nTypeId )
797  {
798  nSize = FMT_REF_ONLYSEQNO_IDX + 1;
799  }
800  else
801  {
802  nSize = GetFieldMgr().GetFormatCount( static_cast<SwFieldTypesEnum>(nTypeId), IsFieldDlgHtmlMode() );
803  }
804  break;
805  }
806 
807  if (REFFLDFLAG & nTypeId)
808  nTypeId = static_cast<sal_uInt16>(SwFieldTypesEnum::GetRef);
809 
810  SwFieldTypesEnum nFieldType = static_cast<SwFieldTypesEnum>(nTypeId);
811  for (sal_uInt16 i = 0; i < nSize; i++)
812  {
813  OUString sId(OUString::number(GetFieldMgr().GetFormatId( nFieldType, i )));
814  m_xFormatLB->append(sId, GetFieldMgr().GetFormatStr(nFieldType, i));
815  }
816  // #i83479#
817 
818  sal_uInt16 nExtraSize( 0 );
819  if ( bAddCrossRefFormats )
820  {
821  sal_uInt16 nFormat = FMT_REF_NUMBER_IDX;
822  OUString sId(OUString::number(GetFieldMgr().GetFormatId(nFieldType, nFormat)));
823  m_xFormatLB->append(sId, GetFieldMgr().GetFormatStr( nFieldType, nFormat ));
824  nFormat = FMT_REF_NUMBER_NO_CONTEXT_IDX;
825  sId = OUString::number(GetFieldMgr().GetFormatId(nFieldType, nFormat));
826  m_xFormatLB->append(sId, GetFieldMgr().GetFormatStr( nFieldType, nFormat ));
827  nFormat = FMT_REF_NUMBER_FULL_CONTEXT_IDX;
828  sId = OUString::number(GetFieldMgr().GetFormatId(nFieldType, nFormat));
829  m_xFormatLB->append(sId, GetFieldMgr().GetFormatStr( nFieldType, nFormat ));
830  nExtraSize = 3;
831  }
832 
833  // extra list items optionally, depending from reference-language
834  SvtSysLocaleOptions aSysLocaleOptions;
835  static const LanguageTag& rLang = aSysLocaleOptions.GetRealLanguageTag();
836 
837  if (rLang.getLanguage() == "hu")
838  {
839  for (sal_uInt16 i = 0; i < nSize; i++)
840  {
841  OUString sId(OUString::number(GetFieldMgr().GetFormatId( nFieldType, i + SAL_N_ELEMENTS(FMT_REF_ARY))));
842  m_xFormatLB->append(sId, SwResId(FMT_REF_WITH_LOWERCASE_HU_ARTICLE) + GetFieldMgr().GetFormatStr( nFieldType, i ));
843  }
844  nExtraSize += nSize;
845 
846  if ( bAddCrossRefFormats )
847  {
848  sal_uInt16 nFormat = FMT_REF_NUMBER_IDX + SAL_N_ELEMENTS(FMT_REF_ARY);
849  OUString sId(OUString::number(GetFieldMgr().GetFormatId(nFieldType, nFormat)));
850  m_xFormatLB->append(sId, SwResId(FMT_REF_WITH_LOWERCASE_HU_ARTICLE) + GetFieldMgr().GetFormatStr( nFieldType, nFormat % SAL_N_ELEMENTS(FMT_REF_ARY)));
851  nFormat = FMT_REF_NUMBER_NO_CONTEXT_IDX + SAL_N_ELEMENTS(FMT_REF_ARY);
852  sId = OUString::number(GetFieldMgr().GetFormatId(nFieldType, nFormat));
853  m_xFormatLB->append(sId, SwResId(FMT_REF_WITH_LOWERCASE_HU_ARTICLE) + GetFieldMgr().GetFormatStr( nFieldType, nFormat % SAL_N_ELEMENTS(FMT_REF_ARY)));
854  nFormat = FMT_REF_NUMBER_FULL_CONTEXT_IDX + SAL_N_ELEMENTS(FMT_REF_ARY);
855  sId = OUString::number(GetFieldMgr().GetFormatId(nFieldType, nFormat));
856  m_xFormatLB->append(sId, SwResId(FMT_REF_WITH_LOWERCASE_HU_ARTICLE) + GetFieldMgr().GetFormatStr( nFieldType, nFormat % SAL_N_ELEMENTS(FMT_REF_ARY)));
857  nExtraSize += 3;
858  }
859  // uppercase article
860  for (sal_uInt16 i = 0; i < nSize; i++)
861  {
862  OUString sId(OUString::number(GetFieldMgr().GetFormatId( nFieldType, i + 2 * SAL_N_ELEMENTS(FMT_REF_ARY))));
863  m_xFormatLB->append(sId, SwResId(FMT_REF_WITH_UPPERCASE_HU_ARTICLE) + GetFieldMgr().GetFormatStr( nFieldType, i ));
864  }
865  nExtraSize += nSize;
866  if ( bAddCrossRefFormats )
867  {
868  sal_uInt16 nFormat = FMT_REF_NUMBER_IDX + 2 * SAL_N_ELEMENTS(FMT_REF_ARY);
869  OUString sId(OUString::number(GetFieldMgr().GetFormatId(nFieldType, nFormat)));
870  m_xFormatLB->append(sId, SwResId(FMT_REF_WITH_UPPERCASE_HU_ARTICLE) + GetFieldMgr().GetFormatStr( nFieldType, nFormat % SAL_N_ELEMENTS(FMT_REF_ARY)));
871  nFormat = FMT_REF_NUMBER_NO_CONTEXT_IDX + 2 * SAL_N_ELEMENTS(FMT_REF_ARY);
872  sId = OUString::number(GetFieldMgr().GetFormatId(nFieldType, nFormat));
873  m_xFormatLB->append(sId, SwResId(FMT_REF_WITH_UPPERCASE_HU_ARTICLE) + GetFieldMgr().GetFormatStr( nFieldType, nFormat % SAL_N_ELEMENTS(FMT_REF_ARY)));
874  nFormat = FMT_REF_NUMBER_FULL_CONTEXT_IDX + 2 * SAL_N_ELEMENTS(FMT_REF_ARY);
875  sId = OUString::number(GetFieldMgr().GetFormatId(nFieldType, nFormat));
876  m_xFormatLB->append(sId, SwResId(FMT_REF_WITH_UPPERCASE_HU_ARTICLE) + GetFieldMgr().GetFormatStr( nFieldType, nFormat % SAL_N_ELEMENTS(FMT_REF_ARY)));
877  nExtraSize += 3;
878  }
879  }
880 
881  nSize += nExtraSize;
882 
883  // select a certain entry
884  if (nSize)
885  {
886  if (!IsFieldEdit())
887  m_xFormatLB->select_text(sOldSel);
888  else
889  m_xFormatLB->select_text(SwResId(FMT_REF_ARY[GetCurField()->GetFormat() % SAL_N_ELEMENTS(FMT_REF_ARY)]));
890 
891  if (m_xFormatLB->get_selected_index() == -1)
892  {
893  if (nFieldDlgFormatSel < m_xFormatLB->n_children())
895  else
896  m_xFormatLB->select(0);
897  }
898  }
899 
900  return nSize;
901 }
902 
903 // Modify
905 {
906  OUString aName(m_xNameED->get_text());
907  const bool bEmptyName = aName.isEmpty();
908 
909  bool bEnable = true;
910  sal_uInt16 nTypeId = m_xTypeLB->get_id(GetTypeSel()).toUInt32();
911 
912  if ((nTypeId == static_cast<sal_uInt16>(SwFieldTypesEnum::SetRef) && !GetFieldMgr().CanInsertRefMark(aName)) ||
913  (bEmptyName && (nTypeId == static_cast<sal_uInt16>(SwFieldTypesEnum::GetRef) || nTypeId == static_cast<sal_uInt16>(SwFieldTypesEnum::SetRef) ||
914  nTypeId == REFFLDFLAG_BOOKMARK)))
915  bEnable = false;
916 
917  EnableInsert(bEnable);
918 
919  m_xSelectionLB->select_text(aName);
920 }
921 
923 {
924  bool bModified = false;
925  sal_uInt16 nTypeId = m_xTypeLB->get_id(GetTypeSel()).toUInt32();
926 
927  sal_uInt16 nSubType = 0;
928  const sal_Int32 nEntryPos = m_xFormatLB->get_selected_index();
929  const sal_uLong nFormat = (nEntryPos == -1)
930  ? 0 : m_xFormatLB->get_id(nEntryPos).toUInt32();
931 
932  OUString aVal(m_xValueED->get_text());
933  OUString aName(m_xNameED->get_text());
934 
935  switch(nTypeId)
936  {
937  case static_cast<sal_uInt16>(SwFieldTypesEnum::GetRef):
938  nSubType = REF_SETREFATTR;
939  break;
940 
941  case static_cast<sal_uInt16>(SwFieldTypesEnum::SetRef):
942  {
944 
945  if(!pType) // Only insert when the name doesn't exist yet
946  {
947  m_xSelectionLB->append_text(aName);
948  m_xSelection->set_sensitive(true);
949  }
950  break;
951  }
952  }
953 
954  SwGetRefField* pRefField = static_cast<SwGetRefField*>(GetCurField());
955 
956  if (REFFLDFLAG & nTypeId)
957  {
958  SwWrtShell *pSh = GetWrtShell();
959  if(!pSh)
960  {
961  pSh = ::GetActiveWrtShell();
962  }
963  if (nTypeId == REFFLDFLAG_BOOKMARK) // text marks!
964  {
965  aName = m_xNameED->get_text();
966  nTypeId = static_cast<sal_uInt16>(SwFieldTypesEnum::GetRef);
967  nSubType = REF_BOOKMARK;
968  }
969  else if (REFFLDFLAG_FOOTNOTE == nTypeId) // footnotes
970  {
972  SeqFieldLstElem aElem( m_xSelectionLB->get_selected_text(), 0 );
973 
974  size_t nPos = 0;
975 
976  nTypeId = static_cast<sal_uInt16>(SwFieldTypesEnum::GetRef);
977  nSubType = REF_FOOTNOTE;
978  aName.clear();
979 
980  if (pSh->GetSeqFootnoteList(aArr) && aArr.SeekEntry(aElem, &nPos))
981  {
982  aVal = OUString::number( aArr[nPos].nSeqNo );
983 
984  if (IsFieldEdit() && aArr[nPos].nSeqNo == pRefField->GetSeqNo())
985  bModified = true; // can happen with fields of which the references were deleted
986  }
987  else if (IsFieldEdit())
988  aVal = OUString::number( pRefField->GetSeqNo() );
989  }
990  else if (REFFLDFLAG_ENDNOTE == nTypeId) // endnotes
991  {
993  SeqFieldLstElem aElem( m_xSelectionLB->get_selected_text(), 0 );
994 
995  size_t nPos = 0;
996 
997  nTypeId = static_cast<sal_uInt16>(SwFieldTypesEnum::GetRef);
998  nSubType = REF_ENDNOTE;
999  aName.clear();
1000 
1001  if (pSh->GetSeqFootnoteList(aArr, true) && aArr.SeekEntry(aElem, &nPos))
1002  {
1003  aVal = OUString::number( aArr[nPos].nSeqNo );
1004 
1005  if (IsFieldEdit() && aArr[nPos].nSeqNo == pRefField->GetSeqNo())
1006  bModified = true; // can happen with fields of which the reference was deleted
1007  }
1008  else if (IsFieldEdit())
1009  aVal = OUString::number( pRefField->GetSeqNo() );
1010  }
1011  // #i83479#
1012  else if ( nTypeId == REFFLDFLAG_HEADING )
1013  {
1014  int nEntry = m_xSelectionToolTipLB->get_selected_index();
1015  OSL_ENSURE( nEntry != -1,
1016  "<SwFieldRefPage::FillItemSet(..)> - no entry selected in selection tool tip listbox!" );
1017  if (nEntry != -1)
1018  {
1019  const size_t nOutlIdx(m_xSelectionToolTipLB->get_id(nEntry).toUInt32());
1021  if ( nOutlIdx < maOutlineNodes.size() )
1022  {
1023  ::sw::mark::IMark const * const pMark = pSh->getIDocumentMarkAccess()->getMarkForTextNode(
1024  *(maOutlineNodes[nOutlIdx]),
1026  aName = pMark->GetName();
1027  nTypeId = static_cast<sal_uInt16>(SwFieldTypesEnum::GetRef);
1028  nSubType = REF_BOOKMARK;
1029  }
1030  }
1031  }
1032  else if ( nTypeId == REFFLDFLAG_NUMITEM )
1033  {
1034  int nEntry = m_xSelectionToolTipLB->get_selected_index();
1035  OSL_ENSURE( nEntry != -1,
1036  "<SwFieldRefPage::FillItemSet(..)> - no entry selected in selection tool tip listbox!" );
1037  if (nEntry != -1)
1038  {
1039  const size_t nNumItemIdx(m_xSelectionToolTipLB->get_id(nEntry).toUInt32());
1041  if ( nNumItemIdx < maNumItems.size() )
1042  {
1043  ::sw::mark::IMark const * const pMark = pSh->getIDocumentMarkAccess()->getMarkForTextNode(
1044  *(maNumItems[nNumItemIdx]->GetTextNode()),
1046  aName = pMark->GetName();
1047  nTypeId = static_cast<sal_uInt16>(SwFieldTypesEnum::GetRef);
1048  nSubType = REF_BOOKMARK;
1049  }
1050  }
1051  }
1052  else // SequenceFields
1053  {
1054  // get fields for Seq-FieldType:
1055  SwSetExpFieldType* pType = static_cast<SwSetExpFieldType*>(pSh->GetFieldType(
1056  nTypeId & ~REFFLDFLAG, SwFieldIds::SetExp ));
1057  if( pType )
1058  {
1060  SeqFieldLstElem aElem( m_xSelectionLB->get_selected_text(), 0 );
1061 
1062  size_t nPos = 0;
1063 
1064  nTypeId = static_cast<sal_uInt16>(SwFieldTypesEnum::GetRef);
1065  nSubType = REF_SEQUENCEFLD;
1066  aName = pType->GetName();
1067 
1068  if (pType->GetSeqFieldList(aArr, pSh->GetLayout())
1069  && aArr.SeekEntry(aElem, &nPos))
1070  {
1071  aVal = OUString::number( aArr[nPos].nSeqNo );
1072 
1073  if (IsFieldEdit() && aArr[nPos].nSeqNo == pRefField->GetSeqNo())
1074  bModified = true; // can happen with fields of which the reference was deleted
1075  }
1076  else if (IsFieldEdit())
1077  aVal = OUString::number( pRefField->GetSeqNo() );
1078  }
1079  }
1080  }
1081 
1082  if (IsFieldEdit() && nTypeId == static_cast<sal_uInt16>(SwFieldTypesEnum::GetRef))
1083  {
1084  aVal = OUString::number(nSubType) + "|" + aVal;
1085  }
1086 
1087  if (!IsFieldEdit() || bModified ||
1088  m_xNameED->get_value_changed_from_saved() ||
1089  m_xValueED->get_value_changed_from_saved() ||
1090  m_xTypeLB->get_value_changed_from_saved() ||
1091  m_xSelectionLB->get_value_changed_from_saved() ||
1092  m_xFormatLB->get_value_changed_from_saved())
1093  {
1094  InsertField( static_cast<SwFieldTypesEnum>(nTypeId), nSubType, aName, aVal, nFormat );
1095  }
1096 
1097  ModifyHdl(*m_xNameED); // enable/disable insert if applicable
1098 
1099  return false;
1100 }
1101 
1102 std::unique_ptr<SfxTabPage> SwFieldRefPage::Create( weld::Container* pPage, weld::DialogController* pController,
1103  const SfxItemSet *const pAttrSet)
1104 {
1105  return std::make_unique<SwFieldRefPage>(pPage, pController, pAttrSet);
1106 }
1107 
1109 {
1110  return GRP_REF;
1111 }
1112 
1114 {
1115  const sal_Int32 nEntryPos = m_xTypeLB->get_selected_index();
1116  const sal_uInt16 nTypeSel = ( -1 == nEntryPos )
1117  ? USHRT_MAX
1118  : m_xTypeLB->get_id(nEntryPos).toUInt32();
1119  const sal_Int32 nFormatEntryPos = m_xFormatLB->get_selected_index();
1120  const sal_uInt32 nFormatSel = -1 == nFormatEntryPos ? USHRT_MAX : nFormatEntryPos;
1122  OUString::number( nTypeSel ) + ";" +
1123  OUString::number( nFormatSel ));
1124 }
1125 
1126 /* 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
SwFieldType * GetFieldType(SwFieldIds nResId, size_t nField=0) const
Definition: fldmgr.cxx:410
Instances of SwFields and those derived from it occur 0 to n times.
Definition: fldbas.hxx:240
virtual void getNumItems(IDocumentListItems::tSortedNodeNumList &orNodeNumList) const =0
get vector of all list items, which are numbered
IMPL_LINK_NOARG(SwFieldRefPage, ModifyHdl_Impl, weld::Entry &, void)
Definition: fldref.cxx:112
IDocumentListItems::tSortedNodeNumList maNumItems
Definition: fldref.hxx:39
virtual const OUString & GetName() const =0
OUString sNumItemText
Definition: fldref.hxx:36
void RestorePos(weld::TreeView &rLst1)
Definition: fldpage.cxx:284
virtual sal_uInt16 GetGroup() override
Definition: fldref.cxx:1108
std::unique_ptr< weld::Entry > m_xValueED
Definition: fldref.hxx:56
void SetUserData(const OUString &rString)
#define REFFLDFLAG_ENDNOTE
Definition: fldref.cxx:41
#define USER_DATA_VERSION
Definition: fldref.cxx:49
const IDocumentOutlineNodes * getIDocumentOutlineNodesAccess() const
Definition: viewsh.cxx:2689
wrapper iterator: wraps iterator of implementation while hiding MarkBase class; only IMark instances ...
sal_uIntPtr sal_uLong
Provides numbered items of a document.
static SW_DLLPUBLIC MarkType GetType(const ::sw::mark::IMark &rMark)
Returns the MarkType used to create the mark.
Definition: docbm.cxx:475
IDocumentOutlineNodes::tSortedOutlineNodeList maOutlineNodes
Definition: fldref.hxx:38
sal_Int64 n
SwWrtShell * GetActiveWrtShell()
Definition: swmodul1.cxx:107
Provides access to the marks of a document.
void SubTypeHdl()
Definition: fldref.cxx:419
void SaveSelectedTextNode()
Definition: fldref.cxx:118
std::unique_ptr< weld::Entry > m_xFilterED
Definition: fldref.hxx:57
bool HasWriterListeners() const
Definition: calbck.hxx:209
#define REFFLDFLAG
Definition: fldref.cxx:38
Used by the UI to modify the document model.
Definition: wrtsh.hxx:90
virtual ~SwFieldRefPage() override
Definition: fldref.cxx:108
static sal_uInt16 nFieldDlgFormatSel
Definition: fldref.cxx:46
SwFieldMgr & GetFieldMgr()
Definition: fldpage.hxx:81
std::unique_ptr< weld::Widget > m_xSelection
Definition: fldref.hxx:48
static SwFieldTypesEnum GetTypeId(sal_uInt16 nPos)
Definition: fldmgr.cxx:521
sal_uInt16 nEnd
Definition: fldmgr.hxx:64
OUString getLanguage() const
virtual void getOutlineNodes(IDocumentOutlineNodes::tSortedOutlineNodeList &orOutlineNodeList) const =0
bool SeekEntry(const SeqFieldLstElem &rNew, size_t *pPos) const
Definition: expfld.cxx:746
bool IsUsed(const sw::BroadcastingModify &) const
Query if the paragraph-/character-/frame-/page-style is used.
Definition: edfmt.cxx:139
const SwTextNode * mpSavedSelectedTextNode
Definition: fldref.hxx:43
virtual bool FillItemSet(SfxItemSet *rSet) override
Definition: fldref.cxx:922
void SetSelectionSel(sal_Int32 nSet)
Definition: fldpage.hxx:48
const OUString & GetUserData() const
sal_uInt16 GetFormatCount(SwFieldTypesEnum nTypeId, bool bHtmlMode) const
Definition: fldmgr.cxx:671
#define REFFLDFLAG_NUMITEM
Definition: fldref.cxx:44
bool IsFieldDlgHtmlMode() const
Definition: fldpage.hxx:49
const IDocumentMarkAccess * getIDocumentMarkAccess() const
Provides access to the document bookmark interface.
Definition: viewsh.cxx:2666
const char * sName
#define SAL_N_ELEMENTS(arr)
std::unique_ptr< weld::TreeView > m_xSelectionToolTipLB
Definition: fldref.hxx:51
virtual const_iterator_t getBookmarksEnd() const =0
returns a STL-like random access iterator to the end of the sequence of IBookmarks.
bool IsRefToNumItemCrossRefBookmark() const
Definition: reffld.cxx:386
int i
#define REFFLDFLAG_BOOKMARK
Definition: fldref.cxx:39
void SavePos(const weld::TreeView &rLst1)
Definition: fldpage.cxx:274
static bool MatchSubstring(const OUString &list_string, const OUString &substr)
Definition: fldref.cxx:721
SwFieldTypesEnum
List of FieldTypes at UI.
Definition: fldbas.hxx:93
void Init()
Definition: fldpage.cxx:63
const SvxPageUsage aArr[]
size_t GetFieldTypeCount(SwFieldIds nResId=SwFieldIds::Unknown) const
count field types with a ResId, if SwFieldIds::Unknown count all
Definition: edfld.cxx:43
bool IsRefresh() const
Definition: fldpage.hxx:50
constexpr std::enable_if_t< std::is_signed_v< T >, std::make_unsigned_t< T > > make_unsigned(T value)
void InsertField(SwFieldTypesEnum nTypeId, sal_uInt16 nSubType, const OUString &rPar1, const OUString &rPar2, sal_uInt32 nFormatId, sal_Unicode cDelim= ' ', bool bIsAutomaticLanguage=true)
Definition: fldpage.cxx:115
sal_Int32 GetTypeSel() const
Definition: fldpage.hxx:45
virtual void Reset(const SfxItemSet *rSet) override
Definition: fldref.cxx:149
size_t GetSeqFootnoteList(SwSeqFieldList &rList, bool bEndNotes=false)
Give a List of all footnotes and their beginning texts.
Definition: edattr.cxx:455
SwField * GetCurField()
Definition: fldpage.hxx:51
OUString SwResId(const char *pId)
Definition: swmodule.cxx:165
OUString lowercase(const OUString &rStr, sal_Int32 nPos, sal_Int32 nCount) const
void UpdateSubType(const OUString &filterString)
Definition: fldref.cxx:463
OUString sFootnoteText
Definition: fldref.hxx:32
#define FIELD_COLUMN_WIDTH
Definition: fldpage.hxx:25
virtual OUString GetName() const override
Only in derived classes.
Definition: expfld.cxx:527
FMT_REF_IDX
Definition: fldref.cxx:732
OUString sBookmarkText
Definition: fldref.hxx:31
sal_uInt16 nStart
Definition: fldmgr.hxx:63
const LanguageTag & GetRealLanguageTag() const
OUString sHeadingText
Definition: fldref.hxx:35
SwWrtShell * GetWrtShell()
Definition: fldpage.hxx:52
const SwGetSetExpType GSE_SEQ
Sequence.
Definition: fldbas.hxx:204
sal_uInt16 GetSeqNo() const
Get/set SequenceNo (of interest only for REF_SEQUENCEFLD).
Definition: reffld.hxx:133
bool equalsIgnoreAsciiCase(std::u16string_view s1, std::u16string_view s2)
virtual ::sw::mark::IMark * getMarkForTextNode(const SwTextNode &rTextNode, MarkType eMark)=0
Returns a mark in the document for a paragraph.
bool IsRefToHeadingCrossRefBookmark() const
Definition: reffld.cxx:380
const IDocumentListItems * getIDocumentListItemsAccess() const
Definition: viewsh.cxx:2684
bool HasFootnotes(bool bEndNotes=false) const
Definition: edattr.cxx:442
std::unique_ptr< weld::TreeView > m_xFormatLB
Definition: fldref.hxx:53
Provides outline nodes of a document.
const o3tl::enumarray< SvxAdjust, unsigned short > aSvxToUnoAdjust USHRT_MAX
Definition: unosett.cxx:254
OUString GetSelText() const
get selected text of a node at current cursor
Definition: crsrsh.cxx:2530
virtual const_iterator_t getBookmarksBegin() const =0
returns a STL-like random access iterator to the begin of the sequence the IBookmarks.
OUString aName
OString strip(const OString &rIn, char c)
virtual void FillUserData() override
Definition: fldref.cxx:1113
const OUString & GetSetRefName() const
Definition: reffld.hxx:108
std::unique_ptr< weld::TreeView > m_xTypeLB
Definition: fldref.hxx:47
static const char * FMT_REF_ARY[]
Definition: fldref.cxx:749
static OUString GetTypeStr(sal_uInt16 nPos)
Definition: fldmgr.cxx:527
OUString sId
bool IsFieldEdit() const
Definition: fldpage.hxx:62
#define REFFLDFLAG_HEADING
Definition: fldref.cxx:43
static std::unique_ptr< SfxTabPage > Create(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet *rAttrSet)
Definition: fldref.cxx:1102
sal_uInt16 GetType() const
Definition: expfld.hxx:193
static const SwFieldGroupRgn & GetGroupRange(bool bHtmlMode, sal_uInt16 nGrpId)
Definition: fldmgr.cxx:465
sal_Int32 FillFormatLB(sal_uInt16 nTypeId)
Definition: fldref.cxx:764
SwRootFrame * GetLayout() const
Definition: viewsh.cxx:2071
CharClass & GetAppCharClass()
Definition: init.cxx:708
OUString sEndnoteText
Definition: fldref.hxx:33
size_t mnSavedSelectedPos
Definition: fldref.hxx:45
#define REFFLDFLAG_FOOTNOTE
Definition: fldref.cxx:40
std::unique_ptr< weld::TreeView > m_xSelectionLB
Definition: fldref.hxx:49
const SwTextNode * GetReferencedTextNode() const
Definition: reffld.cxx:392
void SetTypeSel(sal_Int32 nSet)
Definition: fldpage.hxx:46
sal_uInt16 nPos
size_t GetSeqFieldList(SwSeqFieldList &rList, SwRootFrame const *pLayout)
Definition: expfld.cxx:614
void GetSubTypes(SwFieldTypesEnum nId, std::vector< OUString > &rToFill)
Definition: fldmgr.cxx:568
SwFieldRefPage(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet *pSet)
Definition: fldref.cxx:51
std::unique_ptr< weld::Entry > m_xNameED
Definition: fldref.hxx:55
#define USER_DATA_VERSION_1
Definition: fldref.cxx:48