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