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