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