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