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