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