LibreOffice Module sw (master)  1
fldvar.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 <sfx2/linkmgr.hxx>
23 #include <usrfld.hxx>
24 #include <docufld.hxx>
25 #include <expfld.hxx>
26 #include <ddefld.hxx>
27 #include <wrtsh.hxx>
28 #include <doc.hxx>
29 #include <docary.hxx>
30 #include <swmodule.hxx>
31 #include "fldvar.hxx"
32 #include "flddinf.hxx"
33 #include <calc.hxx>
34 #include <svl/numformat.hxx>
35 #include <svl/zformat.hxx>
36 #include <o3tl/string_view.hxx>
37 #include <strings.hrc>
38 
39 #define USER_DATA_VERSION_1 "1"
40 #define USER_DATA_VERSION USER_DATA_VERSION_1
41 
43  : SwFieldPage(pPage, pController, "modules/swriter/ui/fldvarpage.ui", "FieldVarPage", pCoreSet)
44  , m_xTypeLB(m_xBuilder->weld_tree_view("type"))
45  , m_xSelection(m_xBuilder->weld_widget("selectframe"))
46  , m_xSelectionLB(m_xBuilder->weld_tree_view("select"))
47  , m_xNameFT(m_xBuilder->weld_label("nameft"))
48  , m_xNameED(m_xBuilder->weld_entry("name"))
49  , m_xValueFT(m_xBuilder->weld_label("valueft"))
50  , m_xValueED(new ConditionEdit(m_xBuilder->weld_entry("value")))
51  , m_xFormat(m_xBuilder->weld_widget("formatframe"))
52  , m_xNumFormatLB(new SwNumFormatTreeView(m_xBuilder->weld_tree_view("numformat")))
53  , m_xFormatLB(m_xBuilder->weld_tree_view("format"))
54  , m_xChapterFrame(m_xBuilder->weld_widget("chapterframe"))
55  , m_xChapterLevelLB(m_xBuilder->weld_combo_box("level"))
56  , m_xInvisibleCB(m_xBuilder->weld_check_button("invisible"))
57  , m_xSeparatorFT(m_xBuilder->weld_label("separatorft"))
58  , m_xSeparatorED(m_xBuilder->weld_entry("separator"))
59  , m_xNewPB(m_xBuilder->weld_button("apply"))
60  , m_xDelPB(m_xBuilder->weld_button("delete"))
61  , nOldFormat(0)
62  , bInit(true)
63 {
65  m_xSelectionLB->make_sorted();
67 
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_xSelectionLB->set_size_request(nWidth, nHeight);
72  m_xFormatLB->set_size_request(nWidth, nHeight/2);
73 
74  sOldValueFT = m_xValueFT->get_label();
75  sOldNameFT = m_xNameFT->get_label();
76 
77  for (sal_uInt16 i = 1; i <= MAXLEVEL; i++)
78  m_xChapterLevelLB->append_text(OUString::number(i));
79 
80  m_xChapterLevelLB->set_active(0);
81  //enable 'active' language selection
82  m_xNumFormatLB->SetShowLanguageControl(true);
83 
84  // uitests
85  m_xTypeLB->set_buildable_name(m_xTypeLB->get_buildable_name() + "-var");
86  m_xNameED->set_buildable_name(m_xNameED->get_buildable_name() + "-var");
87  m_xValueED->set_buildable_name(m_xValueED->get_buildable_name() + "-var");
88  m_xNumFormatLB->set_buildable_name(m_xNumFormatLB->get_buildable_name() + "-var");
89  m_xSelectionLB->set_buildable_name(m_xSelectionLB->get_buildable_name() + "-var");
90  m_xFormatLB->set_buildable_name(m_xFormatLB->get_buildable_name() + "-var");
91 }
92 
94 {
95 }
96 
98 {
100 
101  Init(); // general initialisation
102 
103  m_xTypeLB->freeze();
104  m_xTypeLB->clear();
105 
106  SwFieldTypesEnum nTypeId;
107 
108  if (!IsFieldEdit())
109  {
110  // initialise TypeListBox
112 
113  for (short i = rRg.nStart; i < rRg.nEnd; ++i)
114  {
115  nTypeId = SwFieldMgr::GetTypeId(i);
116  m_xTypeLB->append(OUString::number(static_cast<sal_uInt16>(nTypeId)), SwFieldMgr::GetTypeStr(i));
117  }
118  }
119  else
120  {
121  const SwField* pCurField = GetCurField();
122  assert(pCurField && "<SwFieldVarPage::Reset(..)> - <SwField> instance missing!");
123  nTypeId = pCurField->GetTypeId();
124  if (nTypeId == SwFieldTypesEnum::SetInput)
125  nTypeId = SwFieldTypesEnum::Input;
126  m_xTypeLB->append(OUString::number(static_cast<sal_uInt16>(nTypeId)), SwFieldMgr::GetTypeStr(SwFieldMgr::GetPos(nTypeId)));
127  m_xNumFormatLB->SetAutomaticLanguage(pCurField->IsAutomaticLanguage());
128  SwWrtShell *pSh = GetWrtShell();
129  if(!pSh)
130  pSh = ::GetActiveWrtShell();
131  if(pSh)
132  {
133  const SvNumberformat* pFormat = pSh->GetNumberFormatter()->GetEntry(pCurField->GetFormat());
134  if(pFormat)
135  m_xNumFormatLB->SetLanguage(pFormat->GetLanguage());
136  }
137  }
138 
139  m_xTypeLB->thaw();
140 
141  // select old Pos
143 
144  m_xTypeLB->connect_row_activated(LINK(this, SwFieldVarPage, TreeViewInsertHdl));
145  m_xTypeLB->connect_changed(LINK(this, SwFieldVarPage, TypeHdl));
146  m_xSelectionLB->connect_changed(LINK(this, SwFieldVarPage, SubTypeListBoxHdl));
147  m_xSelectionLB->connect_row_activated(LINK(this, SwFieldVarPage, SubTypeInsertHdl));
148  m_xFormatLB->connect_row_activated(LINK(this, SwFieldVarPage, TreeViewInsertHdl));
149  m_xNumFormatLB->connect_row_activated(LINK(this, SwFieldVarPage, TreeViewInsertHdl));
150  m_xNameED->connect_changed(LINK(this, SwFieldVarPage, ModifyHdl));
151  m_xValueED->connect_changed(LINK(this, SwFieldVarPage, ModifyHdl));
152  m_xNewPB->connect_clicked(LINK(this, SwFieldVarPage, TBClickHdl));
153  m_xDelPB->connect_clicked(LINK(this, SwFieldVarPage, TBClickHdl));
154  m_xChapterLevelLB->connect_changed(LINK(this, SwFieldVarPage, ChapterHdl));
155  m_xSeparatorED->connect_changed(LINK(this, SwFieldVarPage, SeparatorHdl));
156 
157  if( !IsRefresh() )
158  {
159  OUString sUserData = GetUserData();
160  sal_Int32 nIdx{ 0 };
161  if(!IsRefresh() && o3tl::equalsIgnoreAsciiCase(o3tl::getToken(sUserData, 0, ';', nIdx), u"" USER_DATA_VERSION_1))
162  {
163  std::u16string_view sVal = o3tl::getToken(sUserData, 0, ';', nIdx);
164  sal_uInt16 nVal = o3tl::narrowing<sal_uInt16>(o3tl::toInt32(sVal));
165  if (USHRT_MAX != nVal)
166  {
167  for (sal_Int32 i = 0, nEntryCount = m_xTypeLB->n_children(); i < nEntryCount; i++)
168  {
169  if (nVal == m_xTypeLB->get_id(i).toUInt32())
170  {
171  m_xTypeLB->select(i);
172  break;
173  }
174  }
175  }
176  }
177  }
178  TypeHdl(*m_xTypeLB);
179 
180  if (IsFieldEdit())
181  {
182  m_xSelectionLB->save_value();
183  m_xFormatLB->save_value();
184  nOldFormat = m_xNumFormatLB->GetFormat();
185  m_xNameED->save_value();
186  m_xValueED->save_value();
187  m_xInvisibleCB->save_state();
188  m_xChapterLevelLB->save_value();
189  m_xSeparatorED->save_value();
190  }
191 }
192 
194 {
195  // save old ListBoxPos
196  const sal_Int32 nOld = GetTypeSel();
197 
198  // current ListBoxPos
199  SetTypeSel(m_xTypeLB->get_selected_index());
200 
201  if(GetTypeSel() == -1)
202  {
203  SetTypeSel(0);
204  m_xTypeLB->select(0);
205  }
206 
207  if (nOld != GetTypeSel() || nOld == -1)
208  {
209  bInit = true;
210  if (nOld != -1)
211  {
212  m_xNameED->set_text(OUString());
213  m_xValueED->set_text(OUString());
214  }
215 
216  m_xValueED->SetDropEnable(false);
217  UpdateSubType(); // initialise selection-listboxes
218  }
219 
220  bInit = false;
221 }
222 
223 IMPL_LINK( SwFieldVarPage, SubTypeListBoxHdl, weld::TreeView&, rBox, void )
224 {
225  SubTypeHdl(&rBox);
226 }
227 
229 {
230  SwFieldTypesEnum nTypeId = static_cast<SwFieldTypesEnum>(m_xTypeLB->get_id(GetTypeSel()).toUInt32());
231  sal_Int32 nSelPos = m_xSelectionLB->get_selected_index();
232  size_t nSelData = SIZE_MAX;
233 
234  if (nSelPos != -1)
235  nSelData = m_xSelectionLB->get_id(nSelPos).toUInt32();
236 
237  if (IsFieldEdit() && (!pBox || bInit))
238  {
239  if (nTypeId != SwFieldTypesEnum::Formel)
240  m_xNameED->set_text(GetFieldMgr().GetCurFieldPar1());
241 
242  m_xValueED->set_text(GetFieldMgr().GetCurFieldPar2());
243  }
244 
245  if (m_xNameFT->get_label() != sOldNameFT)
246  m_xNameFT->set_label(sOldNameFT);
247  if (m_xValueFT->get_label() != sOldValueFT)
248  m_xValueFT->set_label(sOldValueFT);
249 
250  FillFormatLB(nTypeId);
251 
252  sal_Int32 nSize = m_xFormatLB->n_children();
253 
254  bool bValue = false, bName = false, bNumFormat = false,
255  bInvisible = false, bShowChapterFrame = false;
256  bool bFormat = nSize != 0;
257 
258  switch (nTypeId)
259  {
261  {
262  // change or create user type
263  SwUserFieldType* pType = static_cast<SwUserFieldType*>(
265 
266  if (pType)
267  {
268  if (!IsFieldEdit())
269  {
270  if (pBox || (bInit && !IsRefresh())) // only when interacting via mouse
271  {
272  m_xNameED->set_text(pType->GetName());
273 
274  if (pType->GetType() == UF_STRING)
275  {
276  m_xValueED->set_text(pType->GetContent());
277  m_xNumFormatLB->select(0);
278  }
279  else
280  m_xValueED->set_text(pType->GetContent());
281  }
282  }
283  else
284  m_xValueED->set_text(pType->GetContent());
285  }
286  else
287  {
288  if (pBox) // only when interacting via mouse
289  {
290  m_xNameED->set_text(OUString());
291  m_xValueED->set_text(OUString());
292  }
293  }
294  bValue = bName = bNumFormat = bInvisible = true;
295 
296  m_xValueED->SetDropEnable(true);
297  break;
298  }
299 
301  bValue = true;
302 
303  bNumFormat = bInvisible = true;
304 
305  if (!IsFieldDlgHtmlMode())
306  bName = true;
307  else
308  {
309  m_xNumFormatLB->clear();
310  m_xNumFormatLB->append(OUString::number(NUMBERFORMAT_ENTRY_NOT_FOUND), SwResId(FMT_SETVAR_TEXT));
311  m_xNumFormatLB->select(0);
312  }
313  // is there a corresponding SetField
314  if (IsFieldEdit() || pBox) // only when interacting via mouse
315  {
316  if (nSelPos != -1)
317  {
318  OUString sName(m_xSelectionLB->get_selected_text());
319  m_xNameED->set_text(sName);
320 
321  if (!IsFieldDlgHtmlMode())
322  {
323  SwWrtShell *pSh = GetWrtShell();
324  if(!pSh)
325  pSh = ::GetActiveWrtShell();
326  if(pSh)
327  {
328  SwSetExpFieldType* pSetTyp = static_cast<SwSetExpFieldType*>(
330 
331  if (pSetTyp && pSetTyp->GetType() == nsSwGetSetExpType::GSE_STRING)
332  m_xNumFormatLB->select(0); // textual
333  }
334  }
335  }
336  }
337  if (GetCurField() != nullptr && IsFieldEdit())
338  {
339  // GetFormula leads to problems with date formats because
340  // only the numeric value without formatting is returned.
341  // It must be used though because otherwise in GetPar2 only
342  // the value calculated by Kalkulator would be displayed
343  // (instead of test2 = test + 1)
344  m_xValueED->set_text(static_cast<SwSetExpField*>(GetCurField())->GetFormula());
345  }
346  m_xValueED->SetDropEnable(true);
347  break;
348 
350  {
351  bValue = true;
352  bNumFormat = true;
353  m_xValueFT->set_label(SwResId(STR_FORMULA));
354  m_xValueED->SetDropEnable(true);
355  }
356  break;
357 
359  {
360  if (!IsFieldEdit())
361  {
362  m_xNameED->set_text(OUString());
363  m_xValueED->set_text(OUString());
364  }
365 
366  if (nSelPos != -1)
367  {
368  OUString sName(m_xSelectionLB->get_selected_text());
369  if (!IsFieldEdit())
370  m_xNameED->set_text(sName);
371 
372  // is there a corresponding SetField
373  SwWrtShell *pSh = GetWrtShell();
374  if(!pSh)
375  pSh = ::GetActiveWrtShell();
376  if(pSh)
377  {
378  SwSetExpFieldType* pSetTyp = static_cast<SwSetExpFieldType*>(
380 
381  if(pSetTyp)
382  {
383  if (pSetTyp->GetType() & nsSwGetSetExpType::GSE_STRING) // textual?
384  bFormat = true;
385  else // numeric
386  bNumFormat = true;
387  }
388  }
389  }
390  else
391  bFormat = false;
392 
393  EnableInsert(bFormat || bNumFormat);
394  }
395  break;
396 
398  m_xValueFT->set_label(SwResId(STR_PROMPT));
399 
400  if (nSelPos != -1)
401  {
402  bValue = bNumFormat = true;
403 
404  OUString sName = m_xSelectionLB->get_selected_text();
405  m_xNameED->set_text( sName );
406 
407  // User- or SetField ?
408  if (!GetFieldMgr().GetFieldType(SwFieldIds::User, sName)) // SetExp
409  {
410  // is there a corresponding SetField
411  SwSetExpFieldType* pSetTyp = static_cast<SwSetExpFieldType*>(
413 
414  if(pSetTyp)
415  {
416  if (pSetTyp->GetType() == nsSwGetSetExpType::GSE_STRING) // textual?
417  {
418  m_xNumFormatLB->clear();
419  m_xNumFormatLB->append(OUString::number(NUMBERFORMAT_ENTRY_NOT_FOUND), SwResId(FMT_USERVAR_TEXT));
420  m_xNumFormatLB->select(0);
421  }
422  }
423  if (GetCurField() && IsFieldEdit() && (!pBox || bInit) )
424  m_xValueED->set_text(static_cast<SwSetExpField*>(GetCurField())->GetPromptText());
425  }
426  else // USERFLD
427  bFormat = bNumFormat = false;
428  }
429  break;
430 
432  m_xValueFT->set_label(SwResId(STR_DDE_CMD));
433 
434  if (IsFieldEdit() || pBox) // only when interacting via mouse
435  {
436  if (nSelPos != -1)
437  {
438  SwDDEFieldType* pType =
439  static_cast<SwDDEFieldType*>( GetFieldMgr().GetFieldType(SwFieldIds::Dde, nSelData) );
440 
441  if(pType)
442  {
443  m_xNameED->set_text(pType->GetName());
444 
445  //JP 28.08.95: DDE-Topics/-Items can have blanks in their names!
446  // That's not considered here yet
447  OUString sCmd( pType->GetCmd() );
448  sal_Int32 nTmpPos = 0;
449  sCmd = sCmd.replaceFirst( OUStringChar(sfx2::cTokenSeparator), " ", &nTmpPos );
450  sCmd = sCmd.replaceFirst( OUStringChar(sfx2::cTokenSeparator), " ", &nTmpPos );
451 
452  m_xValueED->set_text( sCmd );
453  m_xFormatLB->select(static_cast<int>(pType->GetType()));
454  }
455  }
456  }
457  bName = bValue = true;
458  break;
459 
461  {
462  bName = bValue = bShowChapterFrame = true;
463 
464  SwFieldType* pFieldTyp;
465  if( GetCurField() && IsFieldEdit() )
466  pFieldTyp = GetCurField()->GetTyp();
467  else
468  {
469  OUString sFieldTypeName(m_xSelectionLB->get_text(nSelPos));
470  if( !sFieldTypeName.isEmpty() )
472  sFieldTypeName );
473  else
474  pFieldTyp = nullptr;
475  }
476 
477  if( GetCurField() && IsFieldEdit() )
478  m_xValueED->set_text( static_cast<SwSetExpField*>(GetCurField())->
479  GetFormula() );
480 
481  if( IsFieldEdit() || pBox ) // only when interacting via mouse
482  m_xNameED->set_text( m_xSelectionLB->get_selected_text() );
483 
484  if( pFieldTyp )
485  {
486  sal_uInt8 nLevel = static_cast<SwSetExpFieldType*>(pFieldTyp)->GetOutlineLvl();
487  if( 0x7f == nLevel )
488  m_xChapterLevelLB->set_active(0);
489  else
490  m_xChapterLevelLB->set_active(nLevel + 1);
491  OUString sDelim = static_cast<SwSetExpFieldType*>(pFieldTyp)->GetDelimiter();
492  m_xSeparatorED->set_text( sDelim );
493  ChapterHdl(*m_xChapterLevelLB);
494  }
495  }
496  break;
497 
499  {
500  bValue = false;
501  m_xValueFT->set_label( SwResId( STR_OFFSET ));
502 
503  if (IsFieldEdit() || pBox) // only when interacting via mouse
504  m_xNameED->set_text(OUString());
505 
506  if (nSelData != 0 && nSelData != SIZE_MAX)
507  {
508  bValue = true; // SubType OFF - knows no Offset
509  if (GetCurField() && IsFieldEdit())
510  m_xValueED->set_text(OUString::number(static_cast<SwRefPageSetField*>(GetCurField())->GetOffset()));
511  }
512  }
513  break;
514 
516  m_xNameED->set_text(OUString());
517  m_xValueED->set_text(OUString());
518  break;
519 
520  default: break;
521  }
522 
523  m_xNumFormatLB->set_visible(bNumFormat);
524  m_xFormatLB->set_visible(!bNumFormat);
525 
526  if (IsFieldEdit())
527  bName = false;
528 
529  m_xFormat->set_sensitive(bFormat || bNumFormat);
530  m_xNameFT->set_sensitive(bName);
531  m_xNameED->set_sensitive(bName);
532  m_xValueFT->set_sensitive(bValue);
533  m_xValueED->set_sensitive(bValue);
534 
535  m_xInvisibleCB->set_visible(!bShowChapterFrame);
536  m_xChapterFrame->set_visible(bShowChapterFrame);
537  m_xInvisibleCB->set_sensitive(bInvisible);
538 
539  ModifyHdl(*m_xNameED); // apply/insert/delete status update
540 }
541 
542 IMPL_LINK(SwFieldVarPage, SubTypeInsertHdl, weld::TreeView&, rBox, bool)
543 {
544  if (!bInit)
545  {
546  SwFieldTypesEnum nTypeId = static_cast<SwFieldTypesEnum>(m_xTypeLB->get_id(GetTypeSel()).toUInt32());
547  if (nTypeId == SwFieldTypesEnum::Formel)
548  {
549  auto nSelPos = m_xSelectionLB->get_selected_index();
550  if (nSelPos != -1)
551  {
552  m_xValueED->replace_selection(m_xSelectionLB->get_text(nSelPos));
553  ModifyHdl(*m_xNameED);
554  return true;
555  }
556  }
557  }
558  TreeViewInsertHdl(rBox);
559  return true;
560 }
561 
562 // renew types in SelectionBox
564 {
565  SetSelectionSel(m_xSelectionLB->get_selected_index());
566 
567  OUString sOldSel;
568  if (GetSelectionSel() != -1)
569  sOldSel = m_xSelectionLB->get_text(GetSelectionSel());
570 
571  // fill Selection-Listbox
572  m_xSelectionLB->freeze();
573  m_xSelectionLB->clear();
574 
575  const SwFieldTypesEnum nTypeId = static_cast<SwFieldTypesEnum>(m_xTypeLB->get_id(GetTypeSel()).toUInt32());
576  std::vector<OUString> aList;
577  GetFieldMgr().GetSubTypes(nTypeId, aList);
578  const size_t nCount = aList.size();
579  for (size_t i = 0; i < nCount; ++i)
580  {
581  if (nTypeId != SwFieldTypesEnum::Input || i)
582  {
583  if (!IsFieldEdit())
584  {
585  m_xSelectionLB->append(OUString::number(i), aList[i]);
586  }
587  else
588  {
589  bool bInsert = false;
590 
591  switch (nTypeId)
592  {
594  if (GetCurField() && aList[i] == GetCurField()->GetPar1())
595  bInsert = true;
596  break;
597 
599  bInsert = true;
600  break;
601 
603  if (GetCurField() && aList[i] == static_cast<const SwFormulaField*>(GetCurField())->GetFormula())
604  bInsert = true;
605  break;
606 
609  if (GetCurField() && aList[i] == GetCurField()->GetTyp()->GetName())
610  {
611  bInsert = true;
612  if (GetCurField()->GetSubType() & nsSwExtendedSubType::SUB_INVISIBLE)
613  m_xInvisibleCB->set_active(true);
614  }
615  break;
616 
618  {
619  if (GetCurField() != nullptr
620  && ((static_cast<SwRefPageSetField*>(GetCurField())->IsOn()
621  && i) || (!static_cast<SwRefPageSetField*>(GetCurField())
622  ->IsOn() && !i)))
623  {
624  sOldSel = aList[i];
625  }
626 
627  // allow all entries for selection:
628  m_xSelectionLB->append(OUString::number(i), aList[i]);
629  break;
630  }
631  default:
632  if (GetCurField() && aList[i] == GetCurField()->GetPar1())
633  bInsert = true;
634  break;
635  }
636 
637  if (bInsert)
638  {
639  m_xSelectionLB->append(OUString::number(i), aList[i]);
640  if (nTypeId != SwFieldTypesEnum::Formel)
641  break;
642  }
643  }
644  }
645  }
646 
647  m_xSelectionLB->thaw();
648 
649  const bool bEnable = m_xSelectionLB->n_children() != 0;
650  weld::TreeView* pLB = nullptr;
651 
652  if (bEnable)
653  {
654  int nIndex = m_xSelectionLB->find_text(sOldSel);
655  if (nIndex != -1)
656  m_xSelectionLB->select(nIndex);
657  else
658  {
659  m_xSelectionLB->select(0);
660  pLB = m_xSelectionLB.get(); // newly initialise all controls
661  }
662  }
663 
664  m_xSelection->set_sensitive(bEnable);
665 
666  SubTypeHdl(pLB);
667 }
668 
670 {
671  OUString sOldSel;
672  const sal_Int32 nFormatSel = m_xFormatLB->get_selected_index();
673  if (nFormatSel != -1)
674  sOldSel = m_xFormatLB->get_text(nFormatSel);
675 
676  weld::TreeView& rWidget = dynamic_cast<weld::TreeView&>(m_xNumFormatLB->get_widget());
677 
678  OUString sOldNumSel;
679  sal_uInt32 nOldNumFormat = 0;
680  sal_Int32 nNumFormatSel = rWidget.get_selected_index();
681  if (nNumFormatSel != -1)
682  {
683  sOldNumSel = rWidget.get_text(nNumFormatSel);
684  nOldNumFormat = m_xNumFormatLB->GetFormat();
685  }
686 
687  // fill Format-Listbox
688  m_xFormatLB->freeze();
689  m_xFormatLB->clear();
690  m_xNumFormatLB->clear(); // flags list as dirty and needing refilling with stock entries
691  bool bSpecialFormat = false;
692 
693  if( SwFieldTypesEnum::GetRefPage != nTypeId )
694  {
695  if (GetCurField() != nullptr && IsFieldEdit())
696  {
697  bSpecialFormat = GetCurField()->GetFormat() == NUMBERFORMAT_ENTRY_NOT_FOUND;
698 
699  if (!bSpecialFormat)
700  {
701  m_xNumFormatLB->SetDefFormat(GetCurField()->GetFormat());
702  sOldNumSel.clear();
703  }
704  else if (nTypeId == SwFieldTypesEnum::Get || nTypeId == SwFieldTypesEnum::Formel)
705  {
706  m_xNumFormatLB->SetFormatType(SvNumFormatType::NUMBER);
707  }
708  }
709  else
710  {
711  if (nOldNumFormat && nOldNumFormat != NUMBERFORMAT_ENTRY_NOT_FOUND)
712  m_xNumFormatLB->SetDefFormat(nOldNumFormat);
713  else
714  m_xNumFormatLB->SetFormatType(SvNumFormatType::NUMBER);
715  }
716  }
717 
718  switch (nTypeId)
719  {
721  {
722  if (!IsFieldEdit() || bSpecialFormat)
723  {
724  OUString sId(OUString::number(NUMBERFORMAT_ENTRY_NOT_FOUND));
725  int nOldIndex = rWidget.get_selected_index();
726  rWidget.insert(0, SwResId(FMT_MARK_TEXT), &sId, nullptr, nullptr);
727  rWidget.insert(1, SwResId(FMT_USERVAR_CMD), &sId, nullptr, nullptr);
728  if (nOldIndex != -1)
729  rWidget.select(nOldIndex + 2);
730  }
731  }
732  break;
733 
735  {
736  if (!IsFieldEdit() || bSpecialFormat)
737  {
738  OUString sId(OUString::number(NUMBERFORMAT_ENTRY_NOT_FOUND));
739  int nOldIndex = rWidget.get_selected_index();
740  rWidget.insert(0, SwResId(FMT_SETVAR_TEXT), &sId, nullptr, nullptr);
741  if (nOldIndex != -1)
742  rWidget.select(nOldIndex + 1);
743  }
744  }
745  break;
746 
748  {
749  OUString sId(OUString::number(NUMBERFORMAT_ENTRY_NOT_FOUND));
750  int nOldIndex = rWidget.get_selected_index();
751  rWidget.insert(0, SwResId(FMT_GETVAR_NAME), &sId, nullptr, nullptr);
752  if (nOldIndex != -1)
753  rWidget.select(nOldIndex + 1);
754  }
755  break;
756 
758  {
759  OUString sId(OUString::number(NUMBERFORMAT_ENTRY_NOT_FOUND));
760  int nOldIndex = rWidget.get_selected_index();
761  rWidget.insert(0, SwResId(FMT_GETVAR_NAME), &sId, nullptr, nullptr);
762  if (nOldIndex != -1)
763  rWidget.select(nOldIndex + 1);
764  }
765  break;
766 
767  default: break;
768  }
769 
770  if (IsFieldEdit() && bSpecialFormat)
771  {
772  if (nTypeId == SwFieldTypesEnum::User && (GetCurField()->GetSubType() & nsSwExtendedSubType::SUB_CMD))
773  rWidget.select(1);
774  else
775  rWidget.select(0);
776  }
777  else
778  {
779  if (!nOldNumFormat && (nNumFormatSel = rWidget.find_text(sOldNumSel)) != -1)
780  rWidget.select(nNumFormatSel);
781  else if (nOldNumFormat == NUMBERFORMAT_ENTRY_NOT_FOUND)
782  rWidget.select_text(sOldSel);
783  }
784 
785  const sal_uInt16 nSize = GetFieldMgr().GetFormatCount(nTypeId, IsFieldDlgHtmlMode());
786 
787  OUString sSelectId;
788 
789  for (sal_uInt16 i = 0; i < nSize; i++)
790  {
791  const sal_uInt16 nFieldId = GetFieldMgr().GetFormatId( nTypeId, i );
792  OUString sId(OUString::number(nFieldId));
793  m_xFormatLB->append(sId, GetFieldMgr().GetFormatStr(nTypeId, i));
794  if (IsFieldEdit() && GetCurField() && nFieldId == GetCurField()->GetFormat())
795  sSelectId = sId;
796  }
797 
798  m_xFormatLB->thaw();
799  if (!sSelectId.isEmpty())
800  m_xFormatLB->select_id(sSelectId);
801 
802  if (nSize && (!IsFieldEdit() || m_xFormatLB->get_selected_index() == -1))
803  {
804  int nIndex = m_xFormatLB->find_text(sOldSel);
805  if (nIndex == -1)
806  nIndex = m_xFormatLB->find_text(SwResId(FMT_NUM_PAGEDESC));
807  if (nIndex == -1)
808  nIndex = m_xFormatLB->find_text(SwResId(FMT_NUM_ARABIC));
809  if (nIndex == -1)
810  nIndex = 0;
811  m_xFormatLB->select(nIndex);
812  }
813 }
814 
815 // Modify
817 {
818  OUString sValue(m_xValueED->get_text());
819  bool bHasValue = !sValue.isEmpty();
820  const SwFieldTypesEnum nTypeId = static_cast<SwFieldTypesEnum>(m_xTypeLB->get_id(GetTypeSel()).toUInt32());
821  bool bInsert = false, bApply = false, bDelete = false;
822 
823  OUString sName( m_xNameED->get_text() );
824  sal_Int32 nLen = sName.getLength();
825 
826  switch( nTypeId )
827  {
833  if ( sName.getLength() != nLen )
834  {
835  nLen = sName.getLength();
836  int nStartPos, nEndPos;
837  m_xNameED->get_selection_bounds(nStartPos, nEndPos);
838  m_xNameED->set_text( sName );
839  m_xNameED->select_region(nStartPos, nEndPos); // restore Cursorpos
840  }
841  break;
842  default: break;
843  }
844 
845  // check buttons
846  switch (nTypeId)
847  {
849  if( nLen )
850  {
851  // is there already a corresponding type
852  bInsert = bApply = true;
853 
854  SwFieldType* pType = GetFieldMgr().GetFieldType(SwFieldIds::Dde, sName);
855 
856  SwWrtShell *pSh = GetWrtShell();
857  if(!pSh)
858  pSh = ::GetActiveWrtShell();
859  if(pSh && pType)
860  bDelete = !pSh->IsUsed( *pType );
861  }
862  break;
863 
865  if( nLen )
866  {
867  // is there already a corresponding type
868  SwFieldType* pType = GetFieldMgr().GetFieldType(SwFieldIds::User, sName);
869 
870  SwWrtShell *pSh = GetWrtShell();
871  if(!pSh)
872  pSh = ::GetActiveWrtShell();
873  if(pSh && pType)
874  bDelete = !pSh->IsUsed( *pType );
875 
876  pType = GetFieldMgr().GetFieldType(SwFieldIds::SetExp, sName);
877  if (!pType) // no name conflict with variables
878  {
879  // user fields can also be inserted without content!
880  // Bug #56845
881  bInsert = bApply = true;
882  }
883  }
884  break;
885 
886  default:
887  bInsert = true;
888 
889  if (nTypeId == SwFieldTypesEnum::Set || nTypeId == SwFieldTypesEnum::Sequence)
890  {
891  SwSetExpFieldType* pFieldType = static_cast<SwSetExpFieldType*>(
892  GetFieldMgr().GetFieldType(SwFieldIds::SetExp, sName));
893 
894  if (pFieldType)
895  {
896 
897  SwWrtShell *pSh = GetWrtShell();
898  if(!pSh)
899  pSh = ::GetActiveWrtShell();
900  if(pSh)
901  {
903  sal_uInt16 i;
904 
905  for (i = 0; i < INIT_FLDTYPES; i++)
906  {
907  SwFieldType* pType = (*p)[ i ].get();
908  if (pType == pFieldType)
909  break;
910  }
911 
912  if (i >= INIT_FLDTYPES && !pSh->IsUsed(*pFieldType))
913  bDelete = true;
914 
915  if (nTypeId == SwFieldTypesEnum::Sequence && !(pFieldType->GetType() & nsSwGetSetExpType::GSE_SEQ))
916  bInsert = false;
917 
918  if (nTypeId == SwFieldTypesEnum::Set && (pFieldType->GetType() & nsSwGetSetExpType::GSE_SEQ))
919  bInsert = false;
920  }
921  }
922  if (GetFieldMgr().GetFieldType(SwFieldIds::User, sName))
923  bInsert = false;
924  }
925 
926  if (!nLen && (nTypeId == SwFieldTypesEnum::Set || nTypeId == SwFieldTypesEnum::Input ||
927  (!IsFieldEdit() && nTypeId == SwFieldTypesEnum::Get ) ) )
928  bInsert = false;
929 
930  if( (nTypeId == SwFieldTypesEnum::Set || nTypeId == SwFieldTypesEnum::Formel) &&
931  !bHasValue )
932  bInsert = false;
933  break;
934  }
935 
936  m_xNewPB->set_sensitive(bApply);
937  m_xDelPB->set_sensitive(bDelete);
938  EnableInsert(bInsert);
939 }
940 
941 IMPL_LINK(SwFieldVarPage, TBClickHdl, weld::Button&, rBox, void)
942 {
943  const SwFieldTypesEnum nTypeId = static_cast<SwFieldTypesEnum>(m_xTypeLB->get_id(GetTypeSel()).toUInt32());
944 
945  if (&rBox == m_xDelPB.get())
946  {
947  if( nTypeId == SwFieldTypesEnum::User )
948  GetFieldMgr().RemoveFieldType(SwFieldIds::User, m_xSelectionLB->get_selected_text());
949  else
950  {
951  SwFieldIds nWhich;
952 
953  switch(nTypeId)
954  {
957  nWhich = SwFieldIds::SetExp;
958  break;
959  default:
960  nWhich = SwFieldIds::Dde;
961  break;
962  }
963 
964  GetFieldMgr().RemoveFieldType(nWhich, m_xSelectionLB->get_selected_text());
965  }
966 
967  UpdateSubType();
968  SwWrtShell *pSh = GetWrtShell();
969  if(!pSh)
970  pSh = ::GetActiveWrtShell();
971  if(pSh)
972  {
973  pSh->SetModified();
974  }
975  }
976  else if (&rBox == m_xNewPB.get())
977  {
978  OUString sName(m_xNameED->get_text()), sValue(m_xValueED->get_text());
979  SwFieldType* pType = nullptr;
981  sal_Int32 nNumFormatPos = m_xNumFormatLB->get_selected_index();
982 
983  switch (nTypeId)
984  {
985  case SwFieldTypesEnum::User: nId = SwFieldIds::User; break;
986  case SwFieldTypesEnum::DDE: nId = SwFieldIds::Dde; break;
987  case SwFieldTypesEnum::Set: nId = SwFieldIds::SetExp;break;
988  default: break;
989  }
990  pType = GetFieldMgr().GetFieldType(nId, sName);
991 
992  int nFormat = m_xFormatLB->get_selected_index();
993  if (nFormat != -1)
994  nFormat = m_xFormatLB->get_id(nFormat).toUInt32();
995 
996  if (pType) // change
997  {
998  SwWrtShell *pSh = GetWrtShell();
999  if(!pSh)
1000  pSh = ::GetActiveWrtShell();
1001  if(pSh)
1002  {
1003  pSh->StartAllAction();
1004 
1005  if (nTypeId == SwFieldTypesEnum::User)
1006  {
1007  if (nNumFormatPos != -1)
1008  {
1009  sal_uLong nNumberFormat = nNumFormatPos == 0 ? 0 : m_xNumFormatLB->GetFormat();
1010  if (nNumberFormat)
1011  { // Switch language to office-language because Kalkulator expects
1012  // String in office format and it should be fed into dialog like
1013  // that
1014  nNumberFormat = SwValueField::GetSystemFormat(pSh->GetNumberFormatter(), nNumberFormat);
1015  }
1016  static_cast<SwUserFieldType*>(pType)->SetContent(m_xValueED->get_text(), nNumberFormat);
1017  static_cast<SwUserFieldType*>(pType)->SetType(
1019  }
1020  }
1021  else
1022  {
1023  if (nFormat != -1)
1024  {
1025  // DDE-Topics/-Items can have blanks in their names!
1026  // That's not being considered here yet.
1027  sal_Int32 nTmpPos = 0;
1028  sValue = sValue.replaceFirst( " ", OUStringChar(sfx2::cTokenSeparator), &nTmpPos );
1029  sValue = sValue.replaceFirst( " ", OUStringChar(sfx2::cTokenSeparator), &nTmpPos );
1030  static_cast<SwDDEFieldType*>(pType)->SetCmd(sValue);
1031  static_cast<SwDDEFieldType*>(pType)->SetType(static_cast<SfxLinkUpdateMode>(nFormat));
1032  }
1033  }
1034  pType->UpdateFields();
1035 
1036  pSh->EndAllAction();
1037  }
1038  }
1039  else // new
1040  {
1041  if(nTypeId == SwFieldTypesEnum::User)
1042  {
1043  SwWrtShell *pSh = GetWrtShell();
1044  if(!pSh)
1045  pSh = ::GetActiveWrtShell();
1046  if(pSh)
1047  {
1048  SwUserFieldType aType( pSh->GetDoc(), sName );
1049 
1050  if (nNumFormatPos != -1)
1051  {
1053  aType.SetContent( sValue, nNumFormatPos == 0 ? 0 : m_xNumFormatLB->GetFormat() );
1054  m_xSelectionLB->append_text(sName);
1055  m_xSelectionLB->select_text(sName);
1056  GetFieldMgr().InsertFieldType( aType ); // Userfld new
1057  }
1058  }
1059  }
1060  else
1061  {
1062  if (nFormat != -1)
1063  {
1064  // DDE-Topics/-Items can have blanks in their names!
1065  // That's not being considered here yet.
1066  sal_Int32 nTmpPos = 0;
1067  sValue = sValue.replaceFirst( " ", OUStringChar(sfx2::cTokenSeparator), &nTmpPos );
1068  sValue = sValue.replaceFirst( " ", OUStringChar(sfx2::cTokenSeparator), &nTmpPos );
1069 
1070  SwDDEFieldType aType(sName, sValue, static_cast<SfxLinkUpdateMode>(nFormat));
1071  m_xSelectionLB->append_text(sName);
1072  m_xSelectionLB->select_text(sName);
1073  GetFieldMgr().InsertFieldType(aType); // DDE-Field new
1074  }
1075  }
1076  }
1077  if (IsFieldEdit())
1078  GetFieldMgr().GetCurField(); // update FieldManager
1079 
1080  UpdateSubType();
1081  }
1082 }
1083 
1085 {
1086  bool bEnable = m_xChapterLevelLB->get_active() != 0;
1087 
1088  m_xSeparatorED->set_sensitive(bEnable);
1089  m_xSeparatorFT->set_sensitive(bEnable);
1090  SeparatorHdl(*m_xSeparatorED);
1091 }
1092 
1094 {
1095  bool bEnable = !m_xSeparatorED->get_text().isEmpty() ||
1096  m_xChapterLevelLB->get_active() == 0;
1097  EnableInsert(bEnable);
1098 }
1099 
1101 {
1102  const SwFieldTypesEnum nTypeId = static_cast<SwFieldTypesEnum>(m_xTypeLB->get_id(GetTypeSel()).toUInt32());
1103 
1104  OUString aVal(m_xValueED->get_text());
1105  OUString aName(m_xNameED->get_text());
1106 
1107  const sal_Int32 nSubPos = m_xSelectionLB->get_selected_index();
1108  sal_uInt16 nSubType = (nSubPos == -1) ? 0 : m_xSelectionLB->get_id(nSubPos).toUInt32();
1109 
1110  sal_uInt32 nFormat;
1111 
1112  if (!m_xNumFormatLB->get_visible())
1113  {
1114  sal_Int32 nFormatPos = m_xFormatLB->get_selected_index();
1115 
1116  if(nFormatPos == -1)
1117  nFormat = 0;
1118  else
1119  nFormat = m_xFormatLB->get_id(nFormatPos).toUInt32();
1120  }
1121  else
1122  {
1123  nFormat = m_xNumFormatLB->GetFormat();
1124 
1125  if (nFormat && nFormat != NUMBERFORMAT_ENTRY_NOT_FOUND && m_xNumFormatLB->IsAutomaticLanguage())
1126  {
1127  // Switch language to office language because Kalkulator expects
1128  // String in office format and it should be fed into the dialog
1129  // like that
1130  SwWrtShell *pSh = GetWrtShell();
1131  if(!pSh)
1132  pSh = ::GetActiveWrtShell();
1133  if(pSh)
1134  {
1135  nFormat = SwValueField::GetSystemFormat(pSh->GetNumberFormatter(), nFormat);
1136  }
1137  }
1138  }
1139  sal_Unicode cSeparator = ' ';
1140  switch (nTypeId)
1141  {
1143  {
1145 
1146  if (nFormat == NUMBERFORMAT_ENTRY_NOT_FOUND && m_xNumFormatLB->get_selected_text() == SwResId(FMT_USERVAR_CMD))
1147  nSubType |= nsSwExtendedSubType::SUB_CMD;
1148 
1149  if (m_xInvisibleCB->get_active())
1151  break;
1152  }
1154  {
1155  nSubType = nsSwGetSetExpType::GSE_FORMULA;
1156  if (m_xNumFormatLB->get_visible() && nFormat == NUMBERFORMAT_ENTRY_NOT_FOUND)
1157  nSubType |= nsSwExtendedSubType::SUB_CMD;
1158  break;
1159  }
1160  case SwFieldTypesEnum::Get:
1161  {
1162  nSubType &= 0xff00;
1163  if (m_xNumFormatLB->get_visible() && nFormat == NUMBERFORMAT_ENTRY_NOT_FOUND)
1164  nSubType |= nsSwExtendedSubType::SUB_CMD;
1165  break;
1166  }
1168  {
1170  nSubType = static_cast< sal_uInt16 >((nSubType & 0xff00) | (pType ? INP_USR : INP_VAR));
1171  break;
1172  }
1173 
1174  case SwFieldTypesEnum::Set:
1175  {
1176  if (IsFieldDlgHtmlMode())
1177  {
1178  nSubType = 0x0100;
1179  nSubType = (nSubType & 0xff00) | nsSwGetSetExpType::GSE_STRING;
1180  }
1181  else
1182  nSubType = (nSubType & 0xff00) | ((nFormat == NUMBERFORMAT_ENTRY_NOT_FOUND) ? nsSwGetSetExpType::GSE_STRING : nsSwGetSetExpType::GSE_EXPR);
1183 
1184  if (m_xInvisibleCB->get_active())
1186  break;
1187  }
1189  {
1190  nSubType = static_cast< sal_uInt16 >(m_xChapterLevelLB->get_active());
1191  if (nSubType == 0)
1192  nSubType = 0x7f;
1193  else
1194  {
1195  nSubType--;
1196  OUString sSeparator(m_xSeparatorED->get_text()[0]);
1197  cSeparator = !sSeparator.isEmpty() ? sSeparator[0] : ' ';
1198  }
1199  break;
1200  }
1202  if( SVX_NUM_CHAR_SPECIAL == nFormat )
1203  aVal = m_xValueED->get_text();
1204  break;
1205  default: break;
1206  }
1207 
1208  if (!IsFieldEdit() ||
1209  m_xNameED->get_value_changed_from_saved() ||
1210  m_xValueED->get_value_changed_from_saved() ||
1211  m_xSelectionLB->get_value_changed_from_saved() ||
1212  m_xFormatLB->get_value_changed_from_saved() ||
1213  nOldFormat != m_xNumFormatLB->GetFormat() ||
1214  m_xInvisibleCB->get_state_changed_from_saved() ||
1215  m_xChapterLevelLB->get_value_changed_from_saved() ||
1216  m_xSeparatorED->get_value_changed_from_saved())
1217  {
1218  InsertField( nTypeId, nSubType, aName, aVal, nFormat,
1219  cSeparator, m_xNumFormatLB->IsAutomaticLanguage() );
1220  }
1221 
1222  UpdateSubType();
1223 
1224  return false;
1225 }
1226 
1227 std::unique_ptr<SfxTabPage> SwFieldVarPage::Create( weld::Container* pPage, weld::DialogController* pController,
1228  const SfxItemSet *const pAttrSet)
1229 {
1230  return std::make_unique<SwFieldVarPage>( pPage, pController, pAttrSet );
1231 }
1232 
1234 {
1235  return GRP_VAR;
1236 }
1237 
1239 {
1240  OUString sData = USER_DATA_VERSION ";";
1241  sal_Int32 nTypeSel = m_xTypeLB->get_selected_index();
1242  if( -1 == nTypeSel )
1243  nTypeSel = USHRT_MAX;
1244  else
1245  nTypeSel = m_xTypeLB->get_id(nTypeSel).toUInt32();
1246  sData += OUString::number( nTypeSel );
1247  SetUserData(sData);
1248 }
1249 
1250 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
SwFieldType * GetFieldType(size_t nField, SwFieldIds nResId=SwFieldIds::Unknown) const
get field types with a ResId, if 0 get all
Definition: edfld.cxx:64
SwFieldType * GetFieldType(SwFieldIds nResId, size_t nField=0) const
Definition: fldmgr.cxx:415
Instances of SwFields and those derived from it occur 0 to n times.
Definition: fldbas.hxx:241
sal_Int32 nIndex
The shared part of a user field.
Definition: usrfld.hxx:34
void RestorePos(weld::TreeView &rLst1)
Definition: fldpage.cxx:285
virtual OUString GetName() const override
Only in derived classes.
Definition: usrfld.cxx:212
virtual sal_uInt16 GetGroup() override
Definition: fldvar.cxx:1233
void SetUserData(const OUString &rString)
sal_uInt32 GetFormat() const
Query parameters for dialog and for BASIC.
Definition: fldbas.hxx:403
const SwExtendedSubType SUB_INVISIBLE
Invisible.
Definition: fldbas.hxx:213
virtual void insert(const TreeIter *pParent, int pos, const OUString *pStr, const OUString *pId, const OUString *pIconName, VirtualDevice *pImageSurface, bool bChildrenOnDemand, TreeIter *pRet)=0
sal_uInt16 GetType() const
Definition: usrfld.hxx:87
virtual void Reset(const SfxItemSet *rSet) override
Definition: fldvar.cxx:97
std::unique_ptr< weld::TreeView > m_xTypeLB
Definition: fldvar.hxx:32
sal_uIntPtr sal_uLong
const sal_Unicode cTokenSeparator
Base class of all fields.
Definition: fldbas.hxx:291
SwWrtShell * GetActiveWrtShell()
Definition: swmodul1.cxx:108
virtual void FillUserData() override
Definition: fldvar.cxx:1238
SfxLinkUpdateMode GetType() const
Definition: ddefld.hxx:82
constexpr sal_uInt8 MAXLEVEL
Definition: swtypes.hxx:92
sal_Int16 nId
static const OUString & GetTypeStr(sal_uInt16 nPos)
Definition: fldmgr.cxx:532
std::basic_string_view< charT, traits > getToken(std::basic_string_view< charT, traits > sv, charT delimiter, std::size_t &position)
SwFieldVarPage(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet *pSet)
Definition: fldvar.cxx:42
void SetModified()
Definition: edws.cxx:70
static sal_uInt16 GetPos(SwFieldTypesEnum nTypeId)
Definition: fldmgr.cxx:554
virtual bool FillItemSet(SfxItemSet *rSet) override
Definition: fldvar.cxx:1100
IMPL_LINK(SwFieldVarPage, SubTypeListBoxHdl, weld::TreeView &, rBox, void)
Definition: fldvar.cxx:223
void EndAllAction()
Definition: edws.cxx:97
For old documents the Field-Which IDs must be preserved !!!
OUString sOldValueFT
Definition: fldvar.hxx:50
std::unique_ptr< weld::Entry > m_xSeparatorED
Definition: fldvar.hxx:46
Used by the UI to modify the document model.
Definition: wrtsh.hxx:96
OUString SwResId(TranslateId aId)
Definition: swmodule.cxx:164
OUString const & GetCmd() const
Definition: ddefld.cxx:190
IDocumentFieldsAccess const & getIDocumentFieldsAccess() const
Definition: doc.cxx:357
virtual void UpdateFields() override
Definition: ddefld.hxx:101
sal_uInt16 sal_Unicode
SwFieldMgr & GetFieldMgr()
Definition: fldpage.hxx:81
#define USER_DATA_VERSION_1
Definition: fldvar.cxx:39
std::unique_ptr< ConditionEdit > m_xValueED
Definition: fldvar.hxx:38
static SwFieldTypesEnum GetTypeId(sal_uInt16 nPos)
Definition: fldmgr.cxx:526
std::unique_ptr< weld::Label > m_xValueFT
Definition: fldvar.hxx:37
sal_uInt16 nEnd
Definition: fldmgr.hxx:63
static std::unique_ptr< SfxTabPage > Create(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet *rAttrSet)
Definition: fldvar.cxx:1227
bool IsUsed(const sw::BroadcastingModify &) const
Query if the paragraph-/character-/frame-/page-style is used.
Definition: edfmt.cxx:137
constexpr sal_uInt32 NUMBERFORMAT_ENTRY_NOT_FOUND
int nCount
void SetSelectionSel(sal_Int32 nSet)
Definition: fldpage.hxx:48
void FillFormatLB(SwFieldTypesEnum nTypeId)
Definition: fldvar.cxx:669
const OUString & GetUserData() const
sal_uInt16 GetFormatCount(SwFieldTypesEnum nTypeId, bool bHtmlMode) const
Definition: fldmgr.cxx:676
void UpdateSubType()
Definition: fldvar.cxx:563
SwDoc * GetDoc() const
Definition: viewsh.hxx:282
bool IsFieldDlgHtmlMode() const
Definition: fldpage.hxx:49
virtual OUString GetName() const override
const char * sName
std::unique_ptr< weld::TreeView > m_xFormatLB
Definition: fldvar.hxx:41
const SwGetSetExpType GSE_EXPR
Expression.
Definition: fldbas.hxx:204
sal_uInt32 nOldFormat
Definition: fldvar.hxx:53
void FillFieldSelect(weld::TreeView &rListBox)
Definition: flddinf.cxx:47
SVX_NUM_CHAR_SPECIAL
std::unique_ptr< weld::ComboBox > m_xChapterLevelLB
Definition: fldvar.hxx:43
std::unique_ptr< weld::Button > m_xNewPB
Definition: fldvar.hxx:47
void EnableInsert(bool bEnable)
Definition: fldpage.cxx:317
int i
const SwExtendedSubType SUB_CMD
Show command.
Definition: fldbas.hxx:212
void SavePos(const weld::TreeView &rLst1)
Definition: fldpage.cxx:275
virtual ~SwFieldVarPage() override
Definition: fldvar.cxx:93
sal_Int32 GetSelectionSel() const
Definition: fldpage.hxx:47
virtual int get_selected_index() const =0
SwFieldTypesEnum
List of FieldTypes at UI.
Definition: fldbas.hxx:94
void Init()
Definition: fldpage.cxx:64
SwFieldIds
Definition: fldbas.hxx:45
bool IsRefresh() const
Definition: fldpage.hxx:50
float u
std::unique_ptr< weld::Widget > m_xSelection
Definition: fldvar.hxx:33
void InsertField(SwFieldTypesEnum nTypeId, sal_uInt16 nSubType, const OUString &rPar1, const OUString &rPar2, sal_uInt32 nFormatId, sal_Unicode cDelim= ' ', bool bIsAutomaticLanguage=true)
Definition: fldpage.cxx:116
sal_Int32 GetTypeSel() const
Definition: fldpage.hxx:45
virtual OUString get_text(int row, int col=-1) const =0
virtual const SwFieldTypes * GetFieldTypes() const =0
SwField * GetCurField()
Definition: fldpage.hxx:51
sal_Int32 toInt32(std::u16string_view str, sal_Int16 radix=10)
sal_uInt16 GetFormatId(SwFieldTypesEnum nTypeId, sal_uInt32 nFormatId) const
Definition: fldmgr.cxx:773
bool IsAutomaticLanguage() const
Definition: fldbas.hxx:383
#define FIELD_COLUMN_WIDTH
Definition: fldpage.hxx:25
virtual SotClipboardFormatId GetFormat(const TransferableDataHelper &aHelper) override
virtual int find_text(const OUString &rText) const =0
SwFieldType * GetTyp() const
Definition: fldbas.hxx:398
static SW_DLLPUBLIC bool IsValidVarName(const OUString &rStr, OUString *pValidName=nullptr)
Definition: calc.cxx:1413
sal_uInt16 nStart
Definition: fldmgr.hxx:62
void SubTypeHdl(const weld::TreeView *)
Definition: fldvar.cxx:228
std::unique_ptr< weld::Widget > m_xChapterFrame
Definition: fldvar.hxx:42
#define INIT_FLDTYPES
Definition: swtypes.hxx:105
SwFieldTypesEnum GetTypeId() const
Definition: fldbas.cxx:257
std::unique_ptr< weld::TreeView > m_xSelectionLB
Definition: fldvar.hxx:34
virtual void select(int pos)=0
SwWrtShell * GetWrtShell()
Definition: fldpage.hxx:52
const SwGetSetExpType GSE_SEQ
Sequence.
Definition: fldbas.hxx:205
void select_text(const OUString &rText)
bool equalsIgnoreAsciiCase(std::u16string_view s1, std::u16string_view s2)
std::unique_ptr< SwNumFormatTreeView > m_xNumFormatLB
Definition: fldvar.hxx:40
unsigned char sal_uInt8
const SvNumberformat * GetEntry(sal_uInt32 nKey) const
OUString aName
OUString sOldNameFT
Definition: fldvar.hxx:51
void * p
const SwGetSetExpType GSE_FORMULA
Formula.
Definition: fldbas.hxx:206
OUString GetContent(sal_uInt32 nFormat=0)
Definition: usrfld.cxx:278
#define USER_DATA_VERSION
Definition: fldvar.cxx:40
std::unique_ptr< weld::Widget > m_xFormat
Definition: fldvar.hxx:39
static sal_uInt32 GetSystemFormat(SvNumberFormatter *pFormatter, sal_uInt32 nFormat)
get format in office language
Definition: fldbas.cxx:664
bool IsFieldEdit() const
Definition: fldpage.hxx:62
std::unique_ptr< weld::Button > m_xDelPB
Definition: fldvar.hxx:48
const SwGetSetExpType GSE_STRING
String.
Definition: fldbas.hxx:203
sal_uInt16 GetType() const
Definition: expfld.hxx:197
static const SwFieldGroupRgn & GetGroupRange(bool bHtmlMode, sal_uInt16 nGrpId)
Definition: fldmgr.cxx:470
std::unique_ptr< weld::Label > m_xNameFT
Definition: fldvar.hxx:35
void StartAllAction()
For all views of this document.
Definition: edws.cxx:86
virtual OUString GetName() const override
Only in derived classes.
Definition: ddefld.cxx:174
std::unique_ptr< weld::Entry > m_xNameED
Definition: fldvar.hxx:36
SvNumberFormatter * GetNumberFormatter()
Query NumberFormatter from document.
Definition: editsh.cxx:757
void SetType(sal_uInt16)
Definition: usrfld.hxx:90
IMPL_LINK_NOARG(SwFieldVarPage, TypeHdl, weld::TreeView &, void)
Definition: fldvar.cxx:193
std::unique_ptr< weld::CheckButton > m_xInvisibleCB
Definition: fldvar.hxx:44
LanguageType GetLanguage() const
void GetSubTypes(SwFieldTypesEnum nId, std::vector< OUString > &rToFill)
Definition: fldmgr.cxx:573
OUString sId