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