Add Marathi autocorrect
[LibreOffice.git] / sw / source / ui / fldui / fldfunc.cxx
blob82a485698a2d7b1f9a0ed16e43b65b08a3cfe320
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #include <swtypes.hxx>
21 #include <strings.hrc>
22 #include <fldbas.hxx>
23 #include <docufld.hxx>
24 #include <wrtsh.hxx>
25 #include <swmodule.hxx>
26 #include "fldfunc.hxx"
27 #include "flddinf.hxx"
28 #include <flddropdown.hxx>
29 #include <o3tl/string_view.hxx>
31 #define USER_DATA_VERSION_1 "1"
32 #define USER_DATA_VERSION USER_DATA_VERSION_1
34 using namespace ::com::sun::star;
36 SwFieldFuncPage::SwFieldFuncPage(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet *const pCoreSet)
37 : SwFieldPage(pPage, pController, u"modules/swriter/ui/fldfuncpage.ui"_ustr, u"FieldFuncPage"_ustr, pCoreSet)
38 , m_nOldFormat(0)
39 , m_bDropDownLBChanged(false)
40 , m_xTypeLB(m_xBuilder->weld_tree_view(u"type"_ustr))
41 , m_xSelectionLB(m_xBuilder->weld_tree_view(u"select"_ustr))
42 , m_xFormat(m_xBuilder->weld_widget(u"formatframe"_ustr))
43 , m_xFormatLB(m_xBuilder->weld_tree_view(u"format"_ustr))
44 , m_xNameFT(m_xBuilder->weld_label(u"nameft"_ustr))
45 , m_xNameED(new ConditionEdit<weld::Entry>(m_xBuilder->weld_entry(u"condFunction"_ustr)))
46 , m_xValueGroup(m_xBuilder->weld_widget(u"valuegroup"_ustr))
47 , m_xValueFT(m_xBuilder->weld_label(u"valueft"_ustr))
48 , m_xValueED(m_xBuilder->weld_entry(u"value"_ustr))
49 , m_xCond1FT(m_xBuilder->weld_label(u"cond1ft"_ustr))
50 , m_xCond1ED(new ConditionEdit<weld::Entry>(m_xBuilder->weld_entry(u"cond1"_ustr)))
51 , m_xCond2FT(m_xBuilder->weld_label(u"cond2ft"_ustr))
52 , m_xCond2ED(new ConditionEdit<weld::Entry>(m_xBuilder->weld_entry(u"cond2"_ustr)))
53 , m_xMacroBT(m_xBuilder->weld_button(u"macro"_ustr))
54 , m_xListGroup(m_xBuilder->weld_widget(u"listgroup"_ustr))
55 , m_xListItemED(m_xBuilder->weld_entry(u"item"_ustr))
56 , m_xListAddPB(m_xBuilder->weld_button(u"add"_ustr))
57 , m_xListItemsLB(m_xBuilder->weld_tree_view(u"listitems"_ustr))
58 , m_xListRemovePB(m_xBuilder->weld_button(u"remove"_ustr))
59 , m_xListUpPB(m_xBuilder->weld_button(u"up"_ustr))
60 , m_xListDownPB(m_xBuilder->weld_button(u"down"_ustr))
61 , m_xListNameED(m_xBuilder->weld_entry(u"listname"_ustr))
63 FillFieldSelect(*m_xSelectionLB);
64 FillFieldSelect(*m_xFormatLB);
65 m_xListItemsLB->set_size_request(m_xListItemED->get_preferred_size().Width(),
66 m_xListItemsLB->get_height_rows(5));
68 auto nWidth = m_xTypeLB->get_approximate_digit_width() * FIELD_COLUMN_WIDTH;
69 auto nHeight = m_xTypeLB->get_height_rows(10);
70 m_xTypeLB->set_size_request(nWidth, nHeight);
71 m_xFormatLB->set_size_request(nWidth, nHeight);
73 m_xNameED->connect_changed(LINK(this, SwFieldFuncPage, ModifyHdl));
75 m_sOldValueFT = m_xValueFT->get_label();
76 m_sOldNameFT = m_xNameFT->get_label();
78 m_xCond1ED->ShowBrackets(false);
79 m_xCond2ED->ShowBrackets(false);
81 // uitests
82 m_xTypeLB->set_buildable_name(m_xTypeLB->get_buildable_name() + "-func");
83 m_xValueED->set_buildable_name(m_xValueED->get_buildable_name() + "-func");
84 m_xSelectionLB->set_buildable_name(m_xSelectionLB->get_buildable_name() + "-func");
85 m_xFormatLB->set_buildable_name(m_xFormatLB->get_buildable_name() + "-func");
88 SwFieldFuncPage::~SwFieldFuncPage()
92 void SwFieldFuncPage::Reset(const SfxItemSet* )
94 SavePos(*m_xTypeLB);
95 Init(); // general initialisation
97 m_xTypeLB->freeze();
98 m_xTypeLB->clear();
100 if (!IsFieldEdit())
102 // initialise TypeListBox
103 const SwFieldGroupRgn& rRg = SwFieldMgr::GetGroupRange(IsFieldDlgHtmlMode(), GetGroup());
105 // fill Typ-Listbox
106 for(sal_uInt16 i = rRg.nStart; i < rRg.nEnd; ++i)
108 const SwFieldTypesEnum nTypeId = SwFieldMgr::GetTypeId(i);
109 m_xTypeLB->append(OUString::number(static_cast<sal_uInt16>(nTypeId)), SwFieldMgr::GetTypeStr(i));
112 else
114 const SwFieldTypesEnum nTypeId = GetCurField()->GetTypeId();
115 m_xTypeLB->append(OUString::number(static_cast<sal_uInt16>(nTypeId)), SwFieldMgr::GetTypeStr(SwFieldMgr::GetPos(nTypeId)));
117 if (nTypeId == SwFieldTypesEnum::Macro)
119 GetFieldMgr().SetMacroPath(GetCurField()->GetPar1());
123 m_xTypeLB->connect_row_activated(LINK(this, SwFieldFuncPage, TreeViewInsertHdl));
124 m_xTypeLB->connect_selection_changed(LINK(this, SwFieldFuncPage, TypeHdl));
125 m_xSelectionLB->connect_selection_changed(LINK(this, SwFieldFuncPage, SelectHdl));
126 m_xSelectionLB->connect_row_activated(LINK(this, SwFieldFuncPage, InsertMacroHdl));
127 m_xFormatLB->connect_row_activated(LINK(this, SwFieldFuncPage, TreeViewInsertHdl));
128 m_xMacroBT->connect_clicked(LINK(this, SwFieldFuncPage, MacroHdl));
129 Link<weld::Button&,void> aListModifyLk( LINK(this, SwFieldFuncPage, ListModifyButtonHdl));
130 m_xListAddPB->connect_clicked(aListModifyLk);
131 m_xListRemovePB->connect_clicked(aListModifyLk);
132 m_xListUpPB->connect_clicked(aListModifyLk);
133 m_xListDownPB->connect_clicked(aListModifyLk);
134 m_xListItemED->connect_activate(LINK(this, SwFieldFuncPage, ListModifyReturnActionHdl));
135 Link<weld::Entry&,void> aListEnableLk = LINK(this, SwFieldFuncPage, ListEnableHdl);
136 m_xListItemED->connect_changed(aListEnableLk);
137 m_xListItemsLB->connect_selection_changed(LINK(this, SwFieldFuncPage, ListEnableListBoxHdl));
139 int nSelect = -1;
140 if( !IsRefresh() )
142 const OUString sUserData = GetUserData();
143 sal_Int32 nIdx{ 0 };
144 if(o3tl::equalsIgnoreAsciiCase(o3tl::getToken(sUserData, 0, ';', nIdx), u"" USER_DATA_VERSION_1))
146 const sal_uInt16 nVal = static_cast< sal_uInt16 >(o3tl::toInt32(o3tl::getToken(sUserData, 0, ';', nIdx)));
147 if(nVal != USHRT_MAX)
149 for (sal_Int32 i = 0, nEntryCount = m_xTypeLB->n_children(); i < nEntryCount; ++i)
151 if (nVal == m_xTypeLB->get_id(i).toUInt32())
153 nSelect = i;
154 break;
161 m_xTypeLB->thaw();
162 if (nSelect != -1)
163 m_xTypeLB->select(nSelect);
164 else
166 // select old Pos
167 RestorePos(*m_xTypeLB);
169 TypeHdl(*m_xTypeLB);
171 if (IsFieldEdit())
173 m_xNameED->save_value();
174 m_xValueED->save_value();
175 m_xCond1ED->save_value();
176 m_xCond2ED->save_value();
177 m_nOldFormat = GetCurField()->GetFormat();
181 const TranslateId FMT_MARK_ARY[] =
183 FMT_MARK_TEXT,
184 FMT_MARK_TABLE,
185 FMT_MARK_FRAME,
186 FMT_MARK_GRAFIC,
187 FMT_MARK_OLE
190 IMPL_LINK_NOARG(SwFieldFuncPage, TypeHdl, weld::TreeView&, void)
192 // save old ListBoxPos
193 const sal_Int32 nOld = GetTypeSel();
195 // current ListBoxPos
196 SetTypeSel(m_xTypeLB->get_selected_index());
198 if(GetTypeSel() == -1)
200 SetTypeSel(0);
201 m_xTypeLB->select(0);
204 if (nOld == GetTypeSel())
205 return;
207 const SwFieldTypesEnum nTypeId = static_cast<SwFieldTypesEnum>(m_xTypeLB->get_id(GetTypeSel()).toUInt32());
209 // fill Selection-Listbox
210 UpdateSubType();
212 // fill Format-Listbox
213 m_xFormatLB->clear();
215 const sal_uInt16 nSize = GetFieldMgr().GetFormatCount(nTypeId, IsFieldDlgHtmlMode());
217 for (sal_uInt16 i = 0; i < nSize; i++)
219 m_xFormatLB->append(OUString::number(GetFieldMgr().GetFormatId(nTypeId, i)),
220 GetFieldMgr().GetFormatStr(nTypeId, i));
223 if (nSize)
225 if (IsFieldEdit() && nTypeId == SwFieldTypesEnum::JumpEdit)
226 m_xFormatLB->select_text(SwResId(FMT_MARK_ARY[GetCurField()->GetFormat()]));
228 if (m_xFormatLB->get_selected_index() == -1)
229 m_xFormatLB->select(0);
232 bool bValue = false, bName = false, bMacro = false, bInsert = true;
233 bool bFormat = nSize != 0;
235 // two controls for conditional text
236 bool bDropDown = SwFieldTypesEnum::Dropdown == nTypeId;
237 bool bCondTextField = SwFieldTypesEnum::ConditionalText == nTypeId;
239 m_xCond1FT->set_visible(!bDropDown && bCondTextField);
240 m_xCond1ED->set_visible(!bDropDown && bCondTextField);
241 m_xCond2FT->set_visible(!bDropDown && bCondTextField);
242 m_xCond2ED->set_visible(!bDropDown && bCondTextField);
243 m_xValueGroup->set_visible(!bDropDown && !bCondTextField);
244 m_xMacroBT->set_visible(!bDropDown);
245 m_xNameED->set_visible(!bDropDown);
246 m_xNameFT->set_visible(!bDropDown);
248 m_xListGroup->set_visible(bDropDown);
250 m_xNameED->SetDropEnable(false);
252 if (IsFieldEdit())
254 if(bDropDown)
256 const SwDropDownField* pDrop = static_cast<const SwDropDownField*>(GetCurField());
257 const uno::Sequence<OUString> aItems = pDrop->GetItemSequence();
258 m_xListItemsLB->clear();
259 for (const OUString& rItem : aItems)
260 m_xListItemsLB->append_text(rItem);
261 m_xListItemsLB->select_text(pDrop->GetSelectedItem());
262 m_xListNameED->set_text(pDrop->GetPar2());
263 m_xListNameED->save_value();
264 m_bDropDownLBChanged = false;
266 else
268 m_xNameED->set_text(GetCurField()->GetPar1());
269 m_xValueED->set_text(GetCurField()->GetPar2());
272 else
274 m_xNameED->set_text(OUString());
275 m_xValueED->set_text(OUString());
277 if(bDropDown)
278 ListEnableHdl(*m_xListItemED);
280 if (m_xNameFT->get_label() != m_sOldNameFT)
281 m_xNameFT->set_label(m_sOldNameFT);
282 if (m_xValueFT->get_label() != m_sOldValueFT)
283 m_xValueFT->set_label(m_sOldValueFT);
285 switch (nTypeId)
287 case SwFieldTypesEnum::Macro:
288 bMacro = true;
289 if (!GetFieldMgr().GetMacroPath().isEmpty())
290 bValue = true;
291 else
292 bInsert = false;
294 m_xNameFT->set_label(SwResId(STR_MACNAME));
295 m_xValueFT->set_label(SwResId(STR_PROMPT));
296 m_xNameED->set_text(GetFieldMgr().GetMacroName());
297 m_xNameED->set_accessible_name(m_xNameFT->get_label());
298 m_xValueED->set_accessible_name(m_xValueFT->get_label());
299 break;
301 case SwFieldTypesEnum::HiddenParagraph:
302 m_xNameFT->set_label(SwResId(STR_COND));
303 m_xNameED->SetDropEnable(true);
304 bName = true;
305 m_xNameED->set_accessible_name(m_xNameFT->get_label());
306 m_xValueED->set_accessible_name(m_xValueFT->get_label());
307 break;
309 case SwFieldTypesEnum::HiddenText:
311 m_xNameFT->set_label(SwResId(STR_COND));
312 m_xNameED->SetDropEnable(true);
313 m_xValueFT->set_label(SwResId(STR_INSTEXT));
314 SwWrtShell* pSh = GetActiveWrtShell();
315 if (!IsFieldEdit() && pSh)
316 m_xValueED->set_text(pSh->GetSelText());
317 bName = bValue = true;
318 m_xNameED->set_accessible_name(m_xNameFT->get_label());
319 m_xValueED->set_accessible_name(m_xValueFT->get_label());
321 break;
323 case SwFieldTypesEnum::ConditionalText:
324 m_xNameFT->set_label(SwResId(STR_COND));
325 m_xNameED->SetDropEnable(true);
326 if (IsFieldEdit())
328 sal_Int32 nIdx{ 0 };
329 m_xCond1ED->set_text(GetCurField()->GetPar2().getToken(0, '|', nIdx));
330 m_xCond2ED->set_text(GetCurField()->GetPar2().getToken(0, '|', nIdx));
333 bName = bValue = true;
334 m_xNameED->set_accessible_name(m_xNameFT->get_label());
335 m_xValueED->set_accessible_name(m_xValueFT->get_label());
336 break;
338 case SwFieldTypesEnum::JumpEdit:
339 m_xNameFT->set_label(SwResId(STR_JUMPEDITFLD));
340 m_xValueFT->set_label(SwResId(STR_PROMPT));
341 bName = bValue = true;
342 m_xNameED->set_accessible_name(m_xNameFT->get_label());
343 m_xValueED->set_accessible_name(m_xValueFT->get_label());
344 break;
346 case SwFieldTypesEnum::Input:
347 m_xValueFT->set_label(SwResId(STR_PROMPT));
348 bValue = true;
349 m_xNameED->set_accessible_name(m_xNameFT->get_label());
350 m_xValueED->set_accessible_name(m_xValueFT->get_label());
351 break;
353 case SwFieldTypesEnum::CombinedChars:
355 m_xNameFT->set_label(SwResId(STR_COMBCHRS_FT));
356 m_xNameED->SetDropEnable(true);
357 bName = true;
359 const sal_Int32 nLen = m_xNameED->get_text().getLength();
360 if( !nLen || nLen > MAX_COMBINED_CHARACTERS )
361 bInsert = false;
362 m_xNameED->set_accessible_name(m_xNameFT->get_label());
363 m_xValueED->set_accessible_name(m_xValueFT->get_label());
365 break;
366 case SwFieldTypesEnum::Dropdown :
367 break;
368 default:
369 break;
372 m_xSelectionLB->hide();
374 m_xFormat->set_sensitive(bFormat);
375 m_xNameFT->set_sensitive(bName);
376 m_xNameED->set_sensitive(bName);
377 m_xValueGroup->set_sensitive(bValue);
378 m_xMacroBT->set_sensitive(bMacro);
380 EnableInsert(bInsert, IsCurrentPage());
383 IMPL_LINK_NOARG(SwFieldFuncPage, SelectHdl, weld::TreeView&, void)
385 const SwFieldTypesEnum nTypeId = static_cast<SwFieldTypesEnum>(m_xTypeLB->get_id(GetTypeSel()).toUInt32());
387 if( SwFieldTypesEnum::Macro == nTypeId )
388 m_xNameED->set_text( m_xSelectionLB->get_selected_text() );
391 IMPL_LINK_NOARG(SwFieldFuncPage, InsertMacroHdl, weld::TreeView&, bool)
393 SelectHdl(*m_xSelectionLB);
394 InsertHdl(nullptr);
395 return true;
398 IMPL_LINK(SwFieldFuncPage, ListModifyButtonHdl, weld::Button&, rControl, void)
400 ListModifyHdl(&rControl);
403 IMPL_LINK(SwFieldFuncPage, ListModifyReturnActionHdl, weld::Entry&, rControl, bool)
405 ListModifyHdl(&rControl);
406 return true;
409 void SwFieldFuncPage::ListModifyHdl(const weld::Widget* pControl)
411 if (pControl == m_xListAddPB.get() ||
412 (pControl == m_xListItemED.get() && m_xListAddPB->get_sensitive()))
414 const OUString sEntry(m_xListItemED->get_text());
415 m_xListItemsLB->append_text(sEntry);
416 m_xListItemsLB->select_text(sEntry);
418 else if (m_xListItemsLB->get_selected_index() != -1)
420 sal_Int32 nSelPos = m_xListItemsLB->get_selected_index();
421 if (pControl == m_xListRemovePB.get())
423 m_xListItemsLB->remove(nSelPos);
424 m_xListItemsLB->select(nSelPos ? nSelPos - 1 : 0);
426 else if (pControl == m_xListUpPB.get())
428 if(nSelPos)
430 const OUString sEntry = m_xListItemsLB->get_selected_text();
431 m_xListItemsLB->remove(nSelPos);
432 nSelPos--;
433 m_xListItemsLB->insert_text(nSelPos, sEntry);
434 m_xListItemsLB->select(nSelPos);
437 else if (pControl == m_xListDownPB.get())
439 if( nSelPos < m_xListItemsLB->n_children() - 1)
441 const OUString sEntry = m_xListItemsLB->get_selected_text();
442 m_xListItemsLB->remove(nSelPos);
443 nSelPos++;
444 m_xListItemsLB->insert_text(nSelPos, sEntry);
445 m_xListItemsLB->select(nSelPos);
449 m_bDropDownLBChanged = true;
450 ListEnableHdl(*m_xListItemED);
453 IMPL_LINK_NOARG(SwFieldFuncPage, ListEnableListBoxHdl, weld::TreeView&, void)
455 ListEnableHdl(*m_xListItemED);
458 IMPL_LINK_NOARG(SwFieldFuncPage, ListEnableHdl, weld::Entry&, void)
460 //enable "Add" button when text is in the Edit that's not already member of the box
461 m_xListAddPB->set_sensitive(!m_xListItemED->get_text().isEmpty() &&
462 -1 == m_xListItemsLB->find_text(m_xListItemED->get_text()));
463 bool bEnableButtons = m_xListItemsLB->get_selected_index() != -1;
464 m_xListRemovePB->set_sensitive(bEnableButtons);
465 m_xListUpPB->set_sensitive(bEnableButtons && (m_xListItemsLB->get_selected_index() > 0));
466 m_xListDownPB->set_sensitive(bEnableButtons &&
467 (m_xListItemsLB->get_selected_index() < (m_xListItemsLB->n_children() - 1)));
470 // renew types in SelectionBox
471 void SwFieldFuncPage::UpdateSubType()
473 const SwFieldTypesEnum nTypeId = static_cast<SwFieldTypesEnum>(m_xTypeLB->get_id(GetTypeSel()).toUInt32());
475 // fill Selection-Listbox
476 m_xSelectionLB->freeze();
477 m_xSelectionLB->clear();
479 std::vector<OUString> aLst;
480 GetFieldMgr().GetSubTypes(nTypeId, aLst);
481 const size_t nCount = aLst.size();
483 for (size_t i = 0; i < nCount; ++i)
484 m_xSelectionLB->append(OUString::number(i), aLst[i]);
485 m_xSelectionLB->thaw();
487 bool bEnable = nCount != 0;
489 m_xSelectionLB->set_sensitive( bEnable );
491 if (bEnable)
492 m_xSelectionLB->select(0);
494 if (nTypeId == SwFieldTypesEnum::Macro)
496 const bool bHasMacro = !GetFieldMgr().GetMacroPath().isEmpty();
498 if (bHasMacro)
500 m_xNameED->set_text(GetFieldMgr().GetMacroName());
501 m_xValueGroup->set_sensitive(true);
503 EnableInsert(bHasMacro, IsCurrentPage());
507 // call MacroBrowser, fill Listbox with Macros
508 IMPL_LINK_NOARG( SwFieldFuncPage, MacroHdl, weld::Button&, void)
510 if (GetFieldMgr().ChooseMacro(GetFrameWeld()))
511 UpdateSubType();
514 bool SwFieldFuncPage::FillItemSet(SfxItemSet* )
516 const SwFieldTypesEnum nTypeId = static_cast<SwFieldTypesEnum>(m_xTypeLB->get_id(GetTypeSel()).toUInt32());
518 sal_uInt16 nSubType = 0;
520 const sal_Int32 nEntryPos = m_xFormatLB->get_selected_index();
521 const sal_uInt32 nFormat = (nEntryPos == -1)
522 ? 0 : m_xFormatLB->get_id(nEntryPos).toUInt32();
524 OUString aVal(m_xValueED->get_text());
525 OUString aName(m_xNameED->get_text());
527 switch(nTypeId)
529 case SwFieldTypesEnum::Input:
530 nSubType = INP_TXT;
531 // to prevent removal of CR/LF restore old content
532 if (!m_xNameED->get_value_changed_from_saved() && IsFieldEdit())
533 aName = GetCurField()->GetPar1();
535 break;
537 case SwFieldTypesEnum::Macro:
538 // use the full script URL, not the name in the Edit control
539 aName = GetFieldMgr().GetMacroPath();
540 break;
542 case SwFieldTypesEnum::ConditionalText:
543 aVal = m_xCond1ED->get_text() + "|" + m_xCond2ED->get_text();
544 break;
545 case SwFieldTypesEnum::Dropdown :
547 aName = m_xListNameED->get_text();
548 for (sal_Int32 i = 0, nEntryCount = m_xListItemsLB->n_children(); i < nEntryCount; ++i)
550 if(i)
551 aVal += OUStringChar(DB_DELIM);
552 aVal += m_xListItemsLB->get_text(i);
555 break;
556 default:
557 break;
560 if (!IsFieldEdit() ||
561 m_xNameED->get_value_changed_from_saved() ||
562 m_xValueED->get_value_changed_from_saved() ||
563 m_xCond1ED->get_value_changed_from_saved() ||
564 m_xCond2ED->get_value_changed_from_saved() ||
565 m_xListNameED->get_value_changed_from_saved() ||
566 m_bDropDownLBChanged ||
567 m_nOldFormat != nFormat)
569 InsertField( nTypeId, nSubType, aName, aVal, nFormat );
572 ModifyHdl(m_xNameED->get_widget()); // enable/disable Insert if applicable
574 return false;
577 std::unique_ptr<SfxTabPage> SwFieldFuncPage::Create( weld::Container* pPage, weld::DialogController* pController,
578 const SfxItemSet *const pAttrSet)
580 return std::make_unique<SwFieldFuncPage>(pPage, pController, pAttrSet);
583 sal_uInt16 SwFieldFuncPage::GetGroup()
585 return GRP_FKT;
588 void SwFieldFuncPage::FillUserData()
590 const sal_Int32 nEntryPos = m_xTypeLB->get_selected_index();
591 const sal_uInt16 nTypeSel = ( -1 == nEntryPos )
592 ? USHRT_MAX
593 : m_xTypeLB->get_id(nEntryPos).toUInt32();
594 SetUserData(USER_DATA_VERSION ";" + OUString::number( nTypeSel ));
597 IMPL_LINK_NOARG(SwFieldFuncPage, ModifyHdl, weld::Entry&, void)
599 const sal_Int32 nLen = m_xNameED->get_text().getLength();
601 bool bEnable = true;
602 SwFieldTypesEnum nTypeId = static_cast<SwFieldTypesEnum>(m_xTypeLB->get_id(GetTypeSel()).toUInt32());
604 if( SwFieldTypesEnum::CombinedChars == nTypeId &&
605 (!nLen || nLen > MAX_COMBINED_CHARACTERS ))
606 bEnable = false;
608 EnableInsert(bEnable, IsCurrentPage());
611 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */