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