LibreOffice Module sw (master)  1
fldmgr.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 <config_features.h>
21 
22 #include <cmdid.h>
23 #include <hintids.hxx>
24 #include <svl/stritem.hxx>
25 #include <com/sun/star/text/DefaultNumberingProvider.hpp>
26 #include <com/sun/star/text/XDefaultNumberingProvider.hpp>
27 #include <com/sun/star/text/XNumberingTypeInfo.hpp>
28 #include <com/sun/star/style/NumberingType.hpp>
29 #include <com/sun/star/beans/XPropertySet.hpp>
30 #include <com/sun/star/sdbc/XConnection.hpp>
31 #include <com/sun/star/sdbc/XDataSource.hpp>
32 #include <com/sun/star/uri/UriReferenceFactory.hpp>
33 #include <com/sun/star/uri/XVndSunStarScriptUrl.hpp>
35 #include <comphelper/string.hxx>
36 #include <editeng/unolingu.hxx>
38 #include <tools/resary.hxx>
39 #include <sfx2/dispatch.hxx>
40 #include <sfx2/objsh.hxx>
41 #include <sfx2/linkmgr.hxx>
42 #include <sfx2/app.hxx>
43 #include <sfx2/viewfrm.hxx>
44 #include <svx/dialogs.hrc>
45 #include <svx/strarray.hxx>
46 #include <basic/basmgr.hxx>
47 #include <editeng/langitem.hxx>
48 #include <svl/macitem.hxx>
49 #include <basic/sbmod.hxx>
50 #include <fmtrfmrk.hxx>
51 #include <basic/sbmeth.hxx>
52 #include <basic/sbx.hxx>
53 #include <svl/zforlist.hxx>
54 #include <svl/zformat.hxx>
55 #include <vcl/mnemonic.hxx>
56 #include <view.hxx>
57 #include <wrtsh.hxx>
58 #include <doc.hxx>
59 #include <docsh.hxx>
60 #include <swmodule.hxx>
61 #include <charatr.hxx>
62 #include <fmtinfmt.hxx>
63 #include <cellatr.hxx>
64 #include <dbmgr.hxx>
65 #include <shellres.hxx>
66 #include <fldbas.hxx>
67 #include <docufld.hxx>
68 #include <chpfld.hxx>
69 #include <ddefld.hxx>
70 #include <expfld.hxx>
71 #include <reffld.hxx>
72 #include <usrfld.hxx>
73 #include <dbfld.hxx>
74 #include <authfld.hxx>
75 #include <flddat.hxx>
76 #include <fldmgr.hxx>
77 #include <flddropdown.hxx>
78 #include <strings.hrc>
79 #include <tox.hxx>
80 #include <cnttab.hxx>
81 #include <unotools/useroptions.hxx>
82 
83 using namespace com::sun::star::uno;
84 using namespace com::sun::star::container;
85 using namespace com::sun::star::lang;
86 using namespace com::sun::star::beans;
87 using namespace com::sun::star::text;
88 using namespace com::sun::star::style;
89 using namespace com::sun::star::sdbc;
90 using namespace ::com::sun::star;
91 using namespace nsSwDocInfoSubType;
92 
93 // groups of fields
94 enum
95 {
98 
101 
104 
107 
110 
113 };
114 
115 enum
116 {
119 
121  GRP_WEB_FKT_END = GRP_WEB_FKT_BEGIN + 0, // the group is empty!
122 
123  GRP_WEB_REF_BEGIN = GRP_WEB_FKT_END + 6, // the group is empty!
125 
128 
129  GRP_WEB_DB_BEGIN = GRP_WEB_REG_END, // the group is empty!
131 
134 };
135 
136 static const sal_uInt16 VF_COUNT = 1; // { 0 }
137 static const sal_uInt16 VF_USR_COUNT = 2; // { 0, nsSwExtendedSubType::SUB_CMD }
138 static const sal_uInt16 VF_DB_COUNT = 1; // { nsSwExtendedSubType::SUB_OWN_FMT }
139 
140 static const char* FLD_EU_ARY[] =
141 {
142  FLD_EU_COMPANY,
143  FLD_EU_GIVENNAME,
144  FLD_EU_SURNAME,
145  FLD_EU_INITIALS,
146  FLD_EU_STREET,
147  FLD_EU_COUNTRY,
148  FLD_EU_POSTCODE,
149  FLD_EU_TOWN,
150  FLD_EU_TITLE,
151  FLD_EU_POS,
152  FLD_EU_TELPERSONAL,
153  FLD_EU_TELWORK,
154  FLD_EU_FAX,
155  FLD_EU_EMAIL,
156  FLD_EU_REGION
157 };
158 
159 static const char* FMT_AUTHOR_ARY[] =
160 {
161  FMT_AUTHOR_NAME,
162  FMT_AUTHOR_SCUT
163 };
164 
165 static const char* FLD_DATE_ARY[] =
166 {
167  FLD_DATE_FIX,
168  FLD_DATE_STD,
169 };
170 
171 static const char* FLD_TIME_ARY[] =
172 {
173  FLD_TIME_FIX,
174  FLD_TIME_STD
175 };
176 
177 static const char* FMT_NUM_ARY[] =
178 {
179  FMT_NUM_ABC,
180  FMT_NUM_SABC,
181  FMT_NUM_ABC_N,
182  FMT_NUM_SABC_N,
183  FMT_NUM_ROMAN,
184  FMT_NUM_SROMAN,
185  FMT_NUM_ARABIC,
186  FMT_NUM_PAGEDESC,
187  FMT_NUM_PAGESPECIAL
188 };
189 
190 static const char* FMT_FF_ARY[] =
191 {
192  FMT_FF_NAME,
193  FMT_FF_PATHNAME,
194  FMT_FF_PATH,
195  FMT_FF_NAME_NOEXT,
196  FMT_FF_UI_NAME,
197  FMT_FF_UI_RANGE
198 };
199 
200 static const char* FLD_STAT_ARY[] =
201 {
202  FLD_STAT_PAGE,
203  FLD_STAT_PARA,
204  FLD_STAT_WORD,
205  FLD_STAT_CHAR,
206  FLD_STAT_TABLE,
207  FLD_STAT_GRF,
208  FLD_STAT_OBJ
209 };
210 
211 static const char* FMT_CHAPTER_ARY[] =
212 {
213  FMT_CHAPTER_NO,
214  FMT_CHAPTER_NAME,
215  FMT_CHAPTER_NAMENO,
216  FMT_CHAPTER_NO_NOSEPARATOR
217 };
218 
219 static const char* FLD_INPUT_ARY[] =
220 {
221  FLD_INPUT_TEXT
222 };
223 
224 static const char* FMT_MARK_ARY[] =
225 {
226  FMT_MARK_TEXT,
227  FMT_MARK_TABLE,
228  FMT_MARK_FRAME,
229  FMT_MARK_GRAFIC,
230  FMT_MARK_OLE
231 };
232 
233 static const char* FMT_REF_ARY[] =
234 {
235  FMT_REF_PAGE,
236  FMT_REF_CHAPTER,
237  FMT_REF_TEXT,
238  FMT_REF_UPDOWN,
239  FMT_REF_PAGE_PGDSC,
240  FMT_REF_ONLYNUMBER,
241  FMT_REF_ONLYCAPTION,
242  FMT_REF_ONLYSEQNO,
243  FMT_REF_NUMBER,
244  FMT_REF_NUMBER_NO_CONTEXT,
245  FMT_REF_NUMBER_FULL_CONTEXT
246 };
247 
248 static const char* FMT_REG_ARY[] =
249 {
250  FMT_REG_AUTHOR,
251  FMT_REG_TIME,
252  FMT_REG_DATE
253 };
254 
255 static const char* FMT_DBFLD_ARY[] =
256 {
257  FMT_DBFLD_DB,
258  FMT_DBFLD_SYS
259 };
260 
261 static const char* FMT_SETVAR_ARY[] =
262 {
263  FMT_SETVAR_SYS,
264  FMT_SETVAR_TEXT
265 };
266 
267 static const char* FMT_GETVAR_ARY[] =
268 {
269  FMT_GETVAR_TEXT,
270  FMT_GETVAR_NAME
271 };
272 
273 static const char* FMT_DDE_ARY[] =
274 {
275  FMT_DDE_NORMAL,
276  FMT_DDE_HOT
277 };
278 
279 static const char* FLD_PAGEREF_ARY[] =
280 {
281  FLD_PAGEREF_OFF,
282  FLD_PAGEREF_ON
283 };
284 
285 static const char* FMT_USERVAR_ARY[] =
286 {
287  FMT_USERVAR_TEXT,
288  FMT_USERVAR_CMD
289 };
290 
291 // field types and subtypes
293 {
294  sal_uInt16 const nTypeId;
295 
296  const char** pSubTypeResIds;
297  size_t const nSubTypeLength;
298 
299  const char** pFormatResIds;
300  size_t const nFormatLength;
301 };
302 
303 // strings and formats
304 static const SwFieldPack aSwFields[] =
305 {
306  // Document
307  { TYP_EXTUSERFLD, FLD_EU_ARY, SAL_N_ELEMENTS(FLD_EU_ARY), nullptr, 0 },
308  { TYP_AUTHORFLD, nullptr, 0, FMT_AUTHOR_ARY, SAL_N_ELEMENTS(FMT_AUTHOR_ARY) },
309  { TYP_DATEFLD, FLD_DATE_ARY, SAL_N_ELEMENTS(FLD_DATE_ARY), nullptr, 0 },
310  { TYP_TIMEFLD, FLD_TIME_ARY, SAL_N_ELEMENTS(FLD_TIME_ARY), nullptr, 0 },
311  { TYP_PAGENUMBERFLD, nullptr, 0, FMT_NUM_ARY, SAL_N_ELEMENTS(FMT_NUM_ARY) -1 },
312  { TYP_NEXTPAGEFLD, nullptr, 0, FMT_NUM_ARY, SAL_N_ELEMENTS(FMT_NUM_ARY) },
313  { TYP_PREVPAGEFLD, nullptr, 0, FMT_NUM_ARY, SAL_N_ELEMENTS(FMT_NUM_ARY) },
314  { TYP_FILENAMEFLD, nullptr, 0, FMT_FF_ARY, SAL_N_ELEMENTS(FMT_FF_ARY) },
315  { TYP_DOCSTATFLD, FLD_STAT_ARY, SAL_N_ELEMENTS(FLD_STAT_ARY), FMT_NUM_ARY, SAL_N_ELEMENTS(FMT_NUM_ARY) -1 },
316 
317  { TYP_CHAPTERFLD, nullptr, 0, FMT_CHAPTER_ARY, SAL_N_ELEMENTS(FMT_CHAPTER_ARY) },
318  { TYP_TEMPLNAMEFLD, nullptr, 0, FMT_FF_ARY, SAL_N_ELEMENTS(FMT_FF_ARY) },
319  { TYP_PARAGRAPHSIGFLD, nullptr, 0, nullptr, 0 },
320 
321  // Functions
322  { TYP_CONDTXTFLD, nullptr, 0, nullptr, 0 },
323  { TYP_DROPDOWN, nullptr, 0, nullptr, 0 },
324  { TYP_INPUTFLD, FLD_INPUT_ARY, SAL_N_ELEMENTS(FLD_INPUT_ARY), nullptr, 0 },
325  { TYP_MACROFLD, nullptr, 0, nullptr, 0 },
326  { TYP_JUMPEDITFLD, nullptr, 0, FMT_MARK_ARY, SAL_N_ELEMENTS(FMT_MARK_ARY) },
327  { TYP_COMBINED_CHARS, nullptr, 0, nullptr, 0 },
328  { TYP_HIDDENTXTFLD, nullptr, 0, nullptr, 0 },
329  { TYP_HIDDENPARAFLD, nullptr, 0, nullptr, 0 },
330 
331  // Cross-References
332  { TYP_SETREFFLD, nullptr, 0, nullptr, 0 },
333  { TYP_GETREFFLD, nullptr, 0, FMT_REF_ARY, SAL_N_ELEMENTS(FMT_REF_ARY) },
334 
335  // DocInformation
336  { TYP_DOCINFOFLD, nullptr, 0, FMT_REG_ARY, SAL_N_ELEMENTS(FMT_REG_ARY) },
337 
338  // Database
339  { TYP_DBFLD, nullptr, 0, FMT_DBFLD_ARY, SAL_N_ELEMENTS(FMT_DBFLD_ARY) },
340  { TYP_DBNEXTSETFLD, nullptr, 0, nullptr, 0 },
341  { TYP_DBNUMSETFLD, nullptr, 0, nullptr, 0 },
342  { TYP_DBSETNUMBERFLD, nullptr, 0, FMT_NUM_ARY, SAL_N_ELEMENTS(FMT_NUM_ARY) - 2 },
343  { TYP_DBNAMEFLD, nullptr, 0, nullptr, 0 },
344 
345  // Variables
346  { TYP_SETFLD, nullptr, 0, FMT_SETVAR_ARY, SAL_N_ELEMENTS(FMT_SETVAR_ARY) },
347 
348  { TYP_GETFLD, nullptr, 0, FMT_GETVAR_ARY, SAL_N_ELEMENTS(FMT_GETVAR_ARY) },
349  { TYP_DDEFLD, nullptr, 0, FMT_DDE_ARY, SAL_N_ELEMENTS(FMT_DDE_ARY) },
350  { TYP_FORMELFLD, nullptr, 0, FMT_GETVAR_ARY, SAL_N_ELEMENTS(FMT_GETVAR_ARY) },
351  { TYP_INPUTFLD, FLD_INPUT_ARY, SAL_N_ELEMENTS(FLD_INPUT_ARY), nullptr, 0 },
352  { TYP_SEQFLD, nullptr, 0, FMT_NUM_ARY, SAL_N_ELEMENTS(FMT_NUM_ARY) - 2 },
353  { TYP_SETREFPAGEFLD, FLD_PAGEREF_ARY, SAL_N_ELEMENTS(FLD_PAGEREF_ARY),nullptr, 0 },
354  { TYP_GETREFPAGEFLD, nullptr, 0, FMT_NUM_ARY, SAL_N_ELEMENTS(FMT_NUM_ARY) - 1 },
355  { TYP_USERFLD, nullptr, 0, FMT_USERVAR_ARY, SAL_N_ELEMENTS(FMT_USERVAR_ARY) }
356 };
357 
358 // access to the shell
360 {
361  SwView* pView;
362  if ( nullptr != (pView = ::GetActiveView()) )
363  return pView->GetWrtShellPtr();
364  OSL_FAIL("no current shell found!");
365  return nullptr;
366 }
367 
368 static sal_uInt16 GetPackCount() { return SAL_N_ELEMENTS(aSwFields); }
369 
370 // FieldManager controls inserting and updating of fields
372  m_pWrtShell(pSh),
373  m_bEvalExp(true)
374 {
375  // determine current field if existing
376  GetCurField();
377 }
378 
380 {
381 }
382 
383 // organise RefMark by names
384 bool SwFieldMgr::CanInsertRefMark( const OUString& rStr )
385 {
386  bool bRet = false;
388  OSL_ENSURE(pSh, "no SwWrtShell found");
389  if(pSh)
390  {
391  sal_uInt16 nCnt = pSh->GetCursorCnt();
392 
393  // the last Cursor doesn't have to be a spanned selection
394  if( 1 < nCnt && !pSh->SwCursorShell::HasSelection() )
395  --nCnt;
396 
397  bRet = 2 > nCnt && nullptr == pSh->GetRefMark( rStr );
398  }
399  return bRet;
400 }
401 
402 // access over ResIds
403 void SwFieldMgr::RemoveFieldType(SwFieldIds nResId, const OUString& rName )
404 {
406  OSL_ENSURE(pSh, "no SwWrtShell found");
407  if( pSh )
408  pSh->RemoveFieldType(nResId, rName);
409 }
410 
412 {
414  OSL_ENSURE(pSh, "no SwWrtShell found");
415  return pSh ? pSh->GetFieldTypeCount() : 0;
416 }
417 
418 SwFieldType* SwFieldMgr::GetFieldType(SwFieldIds nResId, size_t nField) const
419 {
421  OSL_ENSURE(pSh, "no SwWrtShell found");
422  return pSh ? pSh->GetFieldType(nField, nResId) : nullptr;
423 }
424 
425 SwFieldType* SwFieldMgr::GetFieldType(SwFieldIds nResId, const OUString& rName) const
426 {
428  OSL_ENSURE(pSh, "no SwWrtShell found");
429  return pSh ? pSh->GetFieldType(nResId, rName) : nullptr;
430 }
431 
432 // determine current field
434 {
436  if ( pSh )
437  m_pCurField = pSh->GetCurField( true );
438  else
439  m_pCurField = nullptr;
440 
441  // initialise strings and format
442  m_aCurPar1.clear();
443  m_aCurPar2.clear();
444  m_sCurFrame.clear();
445  m_nCurFormat = 0;
446 
447  if(!m_pCurField)
448  return nullptr;
449 
450  // preprocess current values; determine parameter 1 and parameter 2
451  // as well as the format
452  const sal_uInt16 nTypeId = m_pCurField->GetTypeId();
453 
457 
458  switch( nTypeId )
459  {
460  case TYP_PAGENUMBERFLD:
461  case TYP_NEXTPAGEFLD:
462  case TYP_PREVPAGEFLD:
463  case TYP_GETREFPAGEFLD:
465  m_nCurFormat -= 2;
466  break;
467  }
468  return m_pCurField;
469 }
470 
471 // provide group range
472 const SwFieldGroupRgn& SwFieldMgr::GetGroupRange(bool bHtmlMode, sal_uInt16 nGrpId)
473 {
474  static SwFieldGroupRgn const aRanges[] =
475  {
476  { /* Document */ GRP_DOC_BEGIN, GRP_DOC_END },
477  { /* Functions */ GRP_FKT_BEGIN, GRP_FKT_END },
478  { /* Cross-Refs */ GRP_REF_BEGIN, GRP_REF_END },
479  { /* DocInfos */ GRP_REG_BEGIN, GRP_REG_END },
480  { /* Database */ GRP_DB_BEGIN, GRP_DB_END },
481  { /* User */ GRP_VAR_BEGIN, GRP_VAR_END }
482  };
483  static SwFieldGroupRgn const aWebRanges[] =
484  {
485  { /* Document */ GRP_WEB_DOC_BEGIN, GRP_WEB_DOC_END },
486  { /* Functions */ GRP_WEB_FKT_BEGIN, GRP_WEB_FKT_END },
487  { /* Cross-Refs */ GRP_WEB_REF_BEGIN, GRP_WEB_REF_END },
488  { /* DocInfos */ GRP_WEB_REG_BEGIN, GRP_WEB_REG_END },
489  { /* Database */ GRP_WEB_DB_BEGIN, GRP_WEB_DB_END },
490  { /* User */ GRP_WEB_VAR_BEGIN, GRP_WEB_VAR_END }
491  };
492 
493  if (bHtmlMode)
494  return aWebRanges[nGrpId];
495  else
496  return aRanges[nGrpId];
497 }
498 
499 // determine GroupId
500 sal_uInt16 SwFieldMgr::GetGroup(sal_uInt16 nTypeId, sal_uInt16 nSubType)
501 {
502  if (nTypeId == TYP_SETINPFLD)
503  nTypeId = TYP_SETFLD;
504 
505  if (nTypeId == TYP_INPUTFLD && (nSubType & INP_USR))
506  nTypeId = TYP_USERFLD;
507 
508  if (nTypeId == TYP_FIXDATEFLD)
509  nTypeId = TYP_DATEFLD;
510 
511  if (nTypeId == TYP_FIXTIMEFLD)
512  nTypeId = TYP_TIMEFLD;
513 
514  for (sal_uInt16 i = GRP_DOC; i <= GRP_VAR; i++)
515  {
516  const SwFieldGroupRgn& rRange = GetGroupRange(false/*bHtmlMode*/, i);
517  for (sal_uInt16 nPos = rRange.nStart; nPos < rRange.nEnd; nPos++)
518  {
519  if (aSwFields[nPos].nTypeId == nTypeId)
520  return i;
521  }
522  }
523  return USHRT_MAX;
524 }
525 
526 // determine names to TypeId
527 // ACCESS over TYP_....
528 sal_uInt16 SwFieldMgr::GetTypeId(sal_uInt16 nPos)
529 {
530  OSL_ENSURE(nPos < ::GetPackCount(), "forbidden Pos");
531  return aSwFields[ nPos ].nTypeId;
532 }
533 
534 OUString SwFieldMgr::GetTypeStr(sal_uInt16 nPos)
535 {
536  OSL_ENSURE(nPos < ::GetPackCount(), "forbidden TypeId");
537 
538  sal_uInt16 nFieldWh = aSwFields[ nPos ].nTypeId;
539 
540  // special treatment for date/time fields (without var/fix)
541  if( TYP_DATEFLD == nFieldWh )
542  {
543  static OUString g_aDate( SwResId( STR_DATEFLD ) );
544  return g_aDate;
545  }
546  if( TYP_TIMEFLD == nFieldWh )
547  {
548  static OUString g_aTime( SwResId( STR_TIMEFLD ) );
549  return g_aTime;
550  }
551 
552  return SwFieldType::GetTypeStr( nFieldWh );
553 }
554 
555 // determine Pos in the list
556 sal_uInt16 SwFieldMgr::GetPos(sal_uInt16 nTypeId)
557 {
558  switch( nTypeId )
559  {
560  case TYP_FIXDATEFLD: nTypeId = TYP_DATEFLD; break;
561  case TYP_FIXTIMEFLD: nTypeId = TYP_TIMEFLD; break;
562  case TYP_SETINPFLD: nTypeId = TYP_SETFLD; break;
563  case TYP_USRINPFLD: nTypeId = TYP_USERFLD; break;
564  }
565 
566  for(sal_uInt16 i = 0; i < GetPackCount(); i++)
567  if(aSwFields[i].nTypeId == nTypeId)
568  return i;
569 
570  return USHRT_MAX;
571 }
572 
573 // localise subtypes of a field
574 void SwFieldMgr::GetSubTypes(sal_uInt16 nTypeId, std::vector<OUString>& rToFill)
575 {
577  OSL_ENSURE(pSh, "no SwWrtShell found");
578  if(pSh)
579  {
580  const sal_uInt16 nPos = GetPos(nTypeId);
581 
582  switch(nTypeId)
583  {
584  case TYP_SETREFFLD:
585  case TYP_GETREFFLD:
586  {
587  // references are no fields
588  pSh->GetRefMarks( &rToFill );
589  break;
590  }
591  case TYP_MACROFLD:
592  {
593  break;
594  }
595  case TYP_INPUTFLD:
596  {
597  rToFill.push_back(SwResId(aSwFields[nPos].pSubTypeResIds[0]));
598  [[fallthrough]]; // move on at generic types
599  }
600  case TYP_DDEFLD:
601  case TYP_SEQFLD:
602  case TYP_FORMELFLD:
603  case TYP_GETFLD:
604  case TYP_SETFLD:
605  case TYP_USERFLD:
606  {
607 
608  const size_t nCount = pSh->GetFieldTypeCount();
609  for(size_t i = 0; i < nCount; ++i)
610  {
611  SwFieldType* pFieldType = pSh->GetFieldType( i );
612  const SwFieldIds nWhich = pFieldType->Which();
613 
614  if((nTypeId == TYP_DDEFLD && pFieldType->Which() == SwFieldIds::Dde) ||
615 
616  (nTypeId == TYP_USERFLD && nWhich == SwFieldIds::User) ||
617 
618  (nTypeId == TYP_GETFLD && nWhich == SwFieldIds::SetExp &&
619  !(static_cast<SwSetExpFieldType*>(pFieldType)->GetType() & nsSwGetSetExpType::GSE_SEQ)) ||
620 
621  (nTypeId == TYP_SETFLD && nWhich == SwFieldIds::SetExp &&
622  !(static_cast<SwSetExpFieldType*>(pFieldType)->GetType() & nsSwGetSetExpType::GSE_SEQ)) ||
623 
624  (nTypeId == TYP_SEQFLD && nWhich == SwFieldIds::SetExp &&
625  (static_cast<SwSetExpFieldType*>(pFieldType)->GetType() & nsSwGetSetExpType::GSE_SEQ)) ||
626 
627  ((nTypeId == TYP_INPUTFLD || nTypeId == TYP_FORMELFLD) &&
628  (nWhich == SwFieldIds::User ||
629  (nWhich == SwFieldIds::SetExp &&
630  !(static_cast<SwSetExpFieldType*>(pFieldType)->GetType() & nsSwGetSetExpType::GSE_SEQ))) ) )
631  {
632  rToFill.push_back(pFieldType->GetName());
633  }
634  }
635  break;
636  }
637  case TYP_DBNEXTSETFLD:
638  case TYP_DBNUMSETFLD:
639  case TYP_DBNAMEFLD:
640  case TYP_DBSETNUMBERFLD:
641  break;
642 
643  default:
644  {
645  // static SubTypes
646  if(nPos != USHRT_MAX)
647  {
648  sal_uInt16 nCount;
649  if (nTypeId == TYP_DOCINFOFLD)
650  nCount = DI_SUBTYPE_END - DI_SUBTYPE_BEGIN;
651  else
652  nCount = aSwFields[nPos].nSubTypeLength;
653 
654  for(sal_uInt16 i = 0; i < nCount; ++i)
655  {
656  OUString sNew;
657  if (nTypeId == TYP_DOCINFOFLD)
658  {
659  if ( i == DI_CUSTOM )
660  sNew = SwResId(STR_CUSTOM_FIELD);
661  else
663  }
664  else
665  sNew = SwResId(aSwFields[nPos].pSubTypeResIds[i]);
666 
667  rToFill.push_back(sNew);
668  }
669  }
670  }
671  }
672  }
673 }
674 
675 // determine format
676 // ACCESS over TYP_....
677 sal_uInt16 SwFieldMgr::GetFormatCount(sal_uInt16 nTypeId, bool bHtmlMode) const
678 {
679  OSL_ENSURE(nTypeId < TYP_END, "forbidden TypeId");
680  {
681  const sal_uInt16 nPos = GetPos(nTypeId);
682 
683  if (nPos == USHRT_MAX || (bHtmlMode && nTypeId == TYP_SETFLD))
684  return 0;
685 
686  sal_uInt16 nCount = aSwFields[nPos].nFormatLength;
687 
688  if (nTypeId == TYP_FILENAMEFLD)
689  nCount -= 2; // no range or template
690 
691  const char** pStart = aSwFields[nPos].pFormatResIds;
692  if (!pStart)
693  return nCount;
694 
695  if (strcmp(*pStart, FMT_GETVAR_ARY[0]) == 0 || strcmp(*pStart, FMT_SETVAR_ARY[0]) == 0)
696  return VF_COUNT;
697  else if (strcmp(*pStart, FMT_USERVAR_ARY[0]) == 0)
698  return VF_USR_COUNT;
699  else if (strcmp(*pStart, FMT_DBFLD_ARY[0]) == 0)
700  return VF_DB_COUNT;
701  else if (strcmp(*pStart, FMT_NUM_ARY[0]) == 0)
702  {
704  if(m_xNumberingInfo.is())
705  {
706  Sequence<sal_Int16> aTypes = m_xNumberingInfo->getSupportedNumberingTypes();
707  // #i28073# it's not necessarily a sorted sequence
708  //skip all values below or equal to CHARS_LOWER_LETTER_N
709  nCount += std::count_if(aTypes.begin(), aTypes.end(),
710  [](sal_Int16 nCurrent) { return nCurrent > NumberingType::CHARS_LOWER_LETTER_N; });
711  }
712  return nCount;
713  }
714 
715  return nCount;
716  }
717 }
718 
719 // determine FormatString to a type
720 OUString SwFieldMgr::GetFormatStr(sal_uInt16 nTypeId, sal_uInt32 nFormatId) const
721 {
722  OSL_ENSURE(nTypeId < TYP_END, "forbidden TypeId");
723  const sal_uInt16 nPos = GetPos(nTypeId);
724 
725  if (nPos == USHRT_MAX)
726  return OUString();
727 
728  const char** pStart = aSwFields[nPos].pFormatResIds;
729  if (!pStart)
730  return OUString();
731 
732  if (TYP_AUTHORFLD == nTypeId|| TYP_FILENAMEFLD == nTypeId)
733  nFormatId &= ~static_cast<sal_uInt32>(FF_FIXED); // mask out Fixed-Flag
734 
735  if (nFormatId < aSwFields[nPos].nFormatLength)
736  return SwResId(pStart[nFormatId]);
737 
738  OUString aRet;
739  if (*pStart == FMT_NUM_ARY[0])
740  {
741  if (m_xNumberingInfo.is())
742  {
743  Sequence<sal_Int16> aTypes = m_xNumberingInfo->getSupportedNumberingTypes();
744  sal_Int32 nOffset = aSwFields[nPos].nFormatLength;
745  sal_uInt32 nValidEntry = 0;
746  for (const sal_Int16 nCurrent : aTypes)
747  {
748  if(nCurrent > NumberingType::CHARS_LOWER_LETTER_N &&
749  (nCurrent != (NumberingType::BITMAP | LINK_TOKEN)))
750  {
751  if (nValidEntry == nFormatId - nOffset)
752  {
753  sal_uInt32 n = SvxNumberingTypeTable::FindIndex(nCurrent);
754  if (n != RESARRAY_INDEX_NOTFOUND)
755  {
757  }
758  else
759  {
760  aRet = m_xNumberingInfo->getNumberingIdentifier( nCurrent );
761  }
762  break;
763  }
764  ++nValidEntry;
765  }
766  }
767  }
768  }
769 
770  return aRet;
771 }
772 
773 // determine FormatId from Pseudo-ID
774 sal_uInt16 SwFieldMgr::GetFormatId(sal_uInt16 nTypeId, sal_uInt32 nFormatId) const
775 {
776  sal_uInt16 nId = static_cast<sal_uInt16>(nFormatId);
777  switch( nTypeId )
778  {
779  case TYP_DOCINFOFLD:
780  {
781  const OString sId(aSwFields[GetPos(nTypeId)].pFormatResIds[nFormatId]);
782  if (sId == FMT_REG_AUTHOR)
783  nId = DI_SUB_AUTHOR;
784  else if (sId == FMT_REG_TIME)
785  nId = DI_SUB_TIME;
786  else if (sId == FMT_REG_DATE)
787  nId = DI_SUB_DATE;
788  break;
789  }
790  case TYP_PAGENUMBERFLD:
791  case TYP_NEXTPAGEFLD:
792  case TYP_PREVPAGEFLD:
793  case TYP_DOCSTATFLD:
794  case TYP_DBSETNUMBERFLD:
795  case TYP_SEQFLD:
796  case TYP_GETREFPAGEFLD:
797  {
798  sal_uInt16 nPos = GetPos(nTypeId);
799  if (nFormatId < aSwFields[nPos].nFormatLength)
800  {
801  const OString sId(aSwFields[nPos].pFormatResIds[nFormatId]);
802  if (sId == FMT_NUM_ABC)
804  else if (sId == FMT_NUM_SABC)
806  else if (sId == FMT_NUM_ROMAN)
807  nId = SVX_NUM_ROMAN_UPPER;
808  else if (sId == FMT_NUM_SROMAN)
809  nId = SVX_NUM_ROMAN_LOWER;
810  else if (sId == FMT_NUM_ARABIC)
811  nId = SVX_NUM_ARABIC;
812  else if (sId == FMT_NUM_PAGEDESC)
813  nId = SVX_NUM_PAGEDESC;
814  else if (sId == FMT_NUM_PAGESPECIAL)
815  nId = SVX_NUM_CHAR_SPECIAL;
816  else if (sId == FMT_NUM_ABC_N)
818  else if (sId == FMT_NUM_SABC_N)
820  }
821  else if (m_xNumberingInfo.is())
822  {
823  Sequence<sal_Int16> aTypes = m_xNumberingInfo->getSupportedNumberingTypes();
824  sal_Int32 nOffset = aSwFields[nPos].nFormatLength;
825  sal_Int32 nValidEntry = 0;
826  for (const sal_Int16 nCurrent : aTypes)
827  {
828  if (nCurrent > NumberingType::CHARS_LOWER_LETTER_N)
829  {
830  if (nValidEntry == static_cast<sal_Int32>(nFormatId) - nOffset)
831  {
832  nId = nCurrent;
833  break;
834  }
835  ++nValidEntry;
836  }
837  }
838  }
839  break;
840  }
841  case TYP_DDEFLD:
842  {
843  const OString sId(aSwFields[GetPos(nTypeId)].pFormatResIds[nFormatId]);
844  if (sId == FMT_DDE_NORMAL)
845  nId = static_cast<sal_uInt16>(SfxLinkUpdateMode::ONCALL);
846  else if (sId == FMT_DDE_HOT)
847  nId = static_cast<sal_uInt16>(SfxLinkUpdateMode::ALWAYS);
848  break;
849  }
850  }
851  return nId;
852 }
853 
854 // Traveling
855 bool SwFieldMgr::GoNextPrev( bool bNext, SwFieldType* pTyp )
856 {
858  if(!pSh)
859  return false;
860 
861  if( !pTyp && m_pCurField )
862  {
863  const sal_uInt16 nTypeId = m_pCurField->GetTypeId();
864  if( TYP_SETINPFLD == nTypeId || TYP_USRINPFLD == nTypeId )
865  pTyp = pSh->GetFieldType( 0, SwFieldIds::Input );
866  else
867  pTyp = m_pCurField->GetTyp();
868  }
869 
870  if (pTyp && pTyp->Which() == SwFieldIds::Database)
871  {
872  // for fieldcommand-edit (hop to all DB fields)
873  return pSh->MoveFieldType( nullptr, bNext, SwFieldIds::Database );
874  }
875 
876  return pTyp && pSh->MoveFieldType(pTyp, bNext);
877 }
878 
879 // insert field types
881 {
883  OSL_ENSURE(pSh, "no SwWrtShell found");
884  if(pSh)
885  pSh->InsertFieldType(rType);
886 }
887 
888 // determine current TypeId
889 sal_uInt16 SwFieldMgr::GetCurTypeId() const
890 {
892 }
893 
894 // Over string insert field or update
896  const SwInsertField_Data& rData)
897 {
898  std::unique_ptr<SwField> pField;
899  bool bExp = false;
900  bool bTable = false;
901  bool bPageVar = false;
902  sal_uInt32 nFormatId = rData.m_nFormatId;
903  sal_uInt16 nSubType = rData.m_nSubType;
904  sal_Unicode cSeparator = rData.m_cSeparator;
905  SwWrtShell* pCurShell = rData.m_pSh;
906  if(!pCurShell)
907  pCurShell = m_pWrtShell ? m_pWrtShell : ::lcl_GetShell();
908  OSL_ENSURE(pCurShell, "no SwWrtShell found");
909  if(!pCurShell)
910  return false;
911 
912  switch (rData.m_nTypeId)
913  { // ATTENTION this field is inserted by a separate dialog
914  case TYP_POSTITFLD:
915  {
916  SvtUserOptions aUserOpt;
917  SwPostItFieldType* pType = static_cast<SwPostItFieldType*>(pCurShell->GetFieldType(0, SwFieldIds::Postit));
918  pField.reset(
919  new SwPostItField(
920  pType,
921  rData.m_sPar1, // author
922  rData.m_sPar2, // content
923  aUserOpt.GetID(), // author's initials
924  OUString(), // name
926  }
927  break;
928  case TYP_SCRIPTFLD:
929  {
930  SwScriptFieldType* pType =
931  static_cast<SwScriptFieldType*>(pCurShell->GetFieldType(0, SwFieldIds::Script));
932  pField.reset(new SwScriptField(pType, rData.m_sPar1, rData.m_sPar2, static_cast<bool>(nFormatId)));
933  break;
934  }
935 
936  case TYP_COMBINED_CHARS:
937  {
938  SwCombinedCharFieldType* pType = static_cast<SwCombinedCharFieldType*>(
939  pCurShell->GetFieldType( 0, SwFieldIds::CombinedChars ));
940  pField.reset(new SwCombinedCharField( pType, rData.m_sPar1 ));
941  }
942  break;
943 
944  case TYP_AUTHORITY:
945  {
946  SwAuthorityFieldType* pType =
948  if (!pType)
949  {
950  SwAuthorityFieldType const type(pCurShell->GetDoc());
951  pType = static_cast<SwAuthorityFieldType*>(
952  pCurShell->InsertFieldType(type));
953  }
954  pField.reset(new SwAuthorityField(pType, rData.m_sPar1));
955  }
956  break;
957 
958  case TYP_DATEFLD:
959  case TYP_TIMEFLD:
960  {
961  sal_uInt16 nSub = static_cast< sal_uInt16 >(rData.m_nTypeId == TYP_DATEFLD ? DATEFLD : TIMEFLD);
962  nSub |= nSubType == DATE_VAR ? 0 : FIXEDFLD;
963 
964  SwDateTimeFieldType* pTyp =
965  static_cast<SwDateTimeFieldType*>( pCurShell->GetFieldType(0, SwFieldIds::DateTime) );
966  pField.reset(new SwDateTimeField(pTyp, nSub, nFormatId));
967  pField->SetPar2(rData.m_sPar2);
968  break;
969  }
970 
971  case TYP_FILENAMEFLD:
972  {
973  SwFileNameFieldType* pTyp =
974  static_cast<SwFileNameFieldType*>( pCurShell->GetFieldType(0, SwFieldIds::Filename) );
975  pField.reset(new SwFileNameField(pTyp, nFormatId));
976  break;
977  }
978 
979  case TYP_TEMPLNAMEFLD:
980  {
981  SwTemplNameFieldType* pTyp =
982  static_cast<SwTemplNameFieldType*>( pCurShell->GetFieldType(0, SwFieldIds::TemplateName) );
983  pField.reset(new SwTemplNameField(pTyp, nFormatId));
984  break;
985  }
986 
987  case TYP_CHAPTERFLD:
988  {
989  sal_uInt16 nByte = static_cast<sal_uInt16>(rData.m_sPar2.toInt32());
990  SwChapterFieldType* pTyp =
991  static_cast<SwChapterFieldType*>( pCurShell->GetFieldType(0, SwFieldIds::Chapter) );
992  pField.reset(new SwChapterField(pTyp, nFormatId));
993  nByte = std::max(sal_uInt16(1), nByte);
994  nByte = std::min(nByte, sal_uInt16(MAXLEVEL));
995  nByte -= 1;
996  static_cast<SwChapterField*>(pField.get())->SetLevel(static_cast<sal_uInt8>(nByte));
997  break;
998  }
999 
1000  case TYP_NEXTPAGEFLD:
1001  case TYP_PREVPAGEFLD:
1002  case TYP_PAGENUMBERFLD:
1003  {
1004  short nOff = static_cast<short>(rData.m_sPar2.toInt32());
1005 
1006  if(rData.m_nTypeId == TYP_NEXTPAGEFLD)
1007  {
1008  if( SVX_NUM_CHAR_SPECIAL == nFormatId )
1009  nOff = 1;
1010  else
1011  nOff += 1;
1012  nSubType = PG_NEXT;
1013  }
1014  else if(rData.m_nTypeId == TYP_PREVPAGEFLD)
1015  {
1016  if( SVX_NUM_CHAR_SPECIAL == nFormatId )
1017  nOff = -1;
1018  else
1019  nOff -= 1;
1020  nSubType = PG_PREV;
1021  }
1022  else
1023  nSubType = PG_RANDOM;
1024 
1025  SwPageNumberFieldType* pTyp =
1026  static_cast<SwPageNumberFieldType*>( pCurShell->GetFieldType(0, SwFieldIds::PageNumber) );
1027  pField.reset(new SwPageNumberField(pTyp, nSubType, nFormatId, nOff));
1028 
1029  if( SVX_NUM_CHAR_SPECIAL == nFormatId &&
1030  ( PG_PREV == nSubType || PG_NEXT == nSubType ) )
1031  static_cast<SwPageNumberField*>(pField.get())->SetUserString( rData.m_sPar2 );
1032  break;
1033  }
1034 
1035  case TYP_DOCSTATFLD:
1036  {
1037  SwDocStatFieldType* pTyp =
1038  static_cast<SwDocStatFieldType*>( pCurShell->GetFieldType(0, SwFieldIds::DocStat) );
1039  pField.reset(new SwDocStatField(pTyp, nSubType, nFormatId));
1040  break;
1041  }
1042 
1043  case TYP_AUTHORFLD:
1044  {
1045  SwAuthorFieldType* pTyp =
1046  static_cast<SwAuthorFieldType*>( pCurShell->GetFieldType(0, SwFieldIds::Author) );
1047  pField.reset(new SwAuthorField(pTyp, nFormatId));
1048  break;
1049  }
1050 
1051  case TYP_CONDTXTFLD:
1052  case TYP_HIDDENTXTFLD:
1053  {
1054  SwHiddenTextFieldType* pTyp =
1055  static_cast<SwHiddenTextFieldType*>( pCurShell->GetFieldType(0, SwFieldIds::HiddenText) );
1056  pField.reset(new SwHiddenTextField(pTyp, true, rData.m_sPar1, rData.m_sPar2, false, rData.m_nTypeId));
1057  bExp = true;
1058  break;
1059  }
1060 
1061  case TYP_HIDDENPARAFLD:
1062  {
1063  SwHiddenParaFieldType* pTyp =
1064  static_cast<SwHiddenParaFieldType*>( pCurShell->GetFieldType(0, SwFieldIds::HiddenPara) );
1065  pField.reset(new SwHiddenParaField(pTyp, rData.m_sPar1));
1066  bExp = true;
1067  break;
1068  }
1069 
1070  case TYP_SETREFFLD:
1071  {
1072  if( !rData.m_sPar1.isEmpty() && CanInsertRefMark( rData.m_sPar1 ) )
1073  {
1074  pCurShell->SetAttrItem( SwFormatRefMark( rData.m_sPar1 ) );
1075  return true;
1076  }
1077  return false;
1078  }
1079 
1080  case TYP_GETREFFLD:
1081  {
1082  SwGetRefFieldType* pTyp =
1083  static_cast<SwGetRefFieldType*>( pCurShell->GetFieldType(0, SwFieldIds::GetRef) );
1084  sal_uInt16 nSeqNo = static_cast<sal_uInt16>(rData.m_sPar2.toInt32());
1085  OUString sReferenceLanguage;
1086  // handle language-variant formats
1087  if (nFormatId >= SAL_N_ELEMENTS(FMT_REF_ARY))
1088  {
1090  if (nLang == LANGUAGE_HUNGARIAN)
1091  {
1092  if (nFormatId >= SAL_N_ELEMENTS(FMT_REF_ARY) * 2)
1093  sReferenceLanguage = "Hu";
1094  else
1095  sReferenceLanguage = "hu";
1096  }
1097  nFormatId %= SAL_N_ELEMENTS(FMT_REF_ARY);
1098  }
1099  pField.reset(new SwGetRefField(pTyp, rData.m_sPar1, sReferenceLanguage, nSubType, nSeqNo, nFormatId));
1100  bExp = true;
1101  break;
1102  }
1103 
1104  case TYP_DDEFLD:
1105  {
1106  //JP 28.08.95: DDE-Topics/-Items can have blanks in their names!
1107  // That's not yet considered here.
1108  sal_Int32 nIndex = 0;
1109  OUString sCmd = rData.m_sPar2.replaceFirst(" ", OUStringLiteral1(sfx2::cTokenSeparator), &nIndex);
1110  if (nIndex>=0 && ++nIndex<sCmd.getLength())
1111  {
1112  sCmd = sCmd.replaceFirst(" ", OUStringLiteral1(sfx2::cTokenSeparator), &nIndex);
1113  }
1114 
1115  SwDDEFieldType aType( rData.m_sPar1, sCmd, static_cast<SfxLinkUpdateMode>(nFormatId) );
1116  SwDDEFieldType* pTyp = static_cast<SwDDEFieldType*>( pCurShell->InsertFieldType( aType ) );
1117  pField.reset(new SwDDEField( pTyp ));
1118  break;
1119  }
1120 
1121  case TYP_MACROFLD:
1122  {
1123  SwMacroFieldType* pTyp =
1124  static_cast<SwMacroFieldType*>(pCurShell->GetFieldType(0, SwFieldIds::Macro));
1125 
1126  pField.reset(new SwMacroField(pTyp, rData.m_sPar1, rData.m_sPar2));
1127 
1128  break;
1129  }
1130 
1131  case TYP_INTERNETFLD:
1132  {
1133  SwFormatINetFormat aFormat( rData.m_sPar1, m_sCurFrame );
1134  return pCurShell->InsertURL( aFormat, rData.m_sPar2 );
1135  }
1136 
1137  case TYP_JUMPEDITFLD:
1138  {
1139  SwJumpEditFieldType* pTyp =
1140  static_cast<SwJumpEditFieldType*>(pCurShell->GetFieldType(0, SwFieldIds::JumpEdit));
1141 
1142  pField.reset(new SwJumpEditField(pTyp, nFormatId, rData.m_sPar1, rData.m_sPar2));
1143  break;
1144  }
1145 
1146  case TYP_DOCINFOFLD:
1147  {
1148  SwDocInfoFieldType* pTyp = static_cast<SwDocInfoFieldType*>( pCurShell->GetFieldType(
1149  0, SwFieldIds::DocInfo ) );
1150  pField.reset(new SwDocInfoField(pTyp, nSubType, rData.m_sPar1, nFormatId));
1151  break;
1152  }
1153 
1154  case TYP_EXTUSERFLD:
1155  {
1156  SwExtUserFieldType* pTyp = static_cast<SwExtUserFieldType*>( pCurShell->GetFieldType(
1157  0, SwFieldIds::ExtUser) );
1158  pField.reset(new SwExtUserField(pTyp, nSubType, nFormatId));
1159  break;
1160  }
1161 
1162  case TYP_DBFLD:
1163  {
1164 #if HAVE_FEATURE_DBCONNECTIVITY
1165  SwDBData aDBData;
1166  OUString sPar1;
1167 
1168  if (rData.m_sPar1.indexOf(DB_DELIM)<0)
1169  {
1170  aDBData = pCurShell->GetDBData();
1171  sPar1 = rData.m_sPar1;
1172  }
1173  else
1174  {
1175  sal_Int32 nIdx{ 0 };
1176  aDBData.sDataSource = rData.m_sPar1.getToken(0, DB_DELIM, nIdx);
1177  aDBData.sCommand = rData.m_sPar1.getToken(0, DB_DELIM, nIdx);
1178  aDBData.nCommandType = rData.m_sPar1.getToken(0, DB_DELIM, nIdx).toInt32();
1179  sPar1 = rData.m_sPar1.getToken(0, DB_DELIM, nIdx);
1180  }
1181 
1182  if(!aDBData.sDataSource.isEmpty() && pCurShell->GetDBData() != aDBData)
1183  pCurShell->ChgDBData(aDBData);
1184 
1185  SwDBFieldType* pTyp = static_cast<SwDBFieldType*>(pCurShell->InsertFieldType(
1186  SwDBFieldType(pCurShell->GetDoc(), sPar1, aDBData) ) );
1187  pField.reset(new SwDBField(pTyp));
1188  pField->SetSubType(nSubType);
1189 
1190  if( !(nSubType & nsSwExtendedSubType::SUB_OWN_FMT) ) // determine database format
1191  {
1192  Reference< XDataSource> xSource;
1193  rData.m_aDBDataSource >>= xSource;
1194  Reference<XConnection> xConnection;
1195  rData.m_aDBConnection >>= xConnection;
1196  Reference<XPropertySet> xColumn;
1197  rData.m_aDBColumn >>= xColumn;
1198  if(xColumn.is())
1199  {
1200  nFormatId = SwDBManager::GetColumnFormat(xSource, xConnection, xColumn,
1201  pCurShell->GetNumberFormatter(), GetCurrLanguage() );
1202  }
1203  else
1204  nFormatId = pCurShell->GetDBManager()->GetColumnFormat(
1205  aDBData.sDataSource, aDBData.sCommand, sPar1,
1206  pCurShell->GetNumberFormatter(), GetCurrLanguage() );
1207  }
1208  pField->ChangeFormat( nFormatId );
1209 
1210  bExp = true;
1211 #endif
1212  break;
1213  }
1214 
1215  case TYP_DBSETNUMBERFLD:
1216  case TYP_DBNUMSETFLD:
1217  case TYP_DBNEXTSETFLD:
1218  case TYP_DBNAMEFLD:
1219  {
1220 #if HAVE_FEATURE_DBCONNECTIVITY
1221  SwDBData aDBData;
1222 
1223  // extract DBName from rData.m_sPar1. Format: DBName.TableName.CommandType.ExpStrg
1224  sal_Int32 nTablePos = rData.m_sPar1.indexOf(DB_DELIM);
1225  sal_Int32 nCmdTypePos = -1;
1226  sal_Int32 nExpPos = -1;
1227 
1228  if (nTablePos>=0)
1229  {
1230  aDBData.sDataSource = rData.m_sPar1.copy(0, nTablePos++);
1231  nCmdTypePos = rData.m_sPar1.indexOf(DB_DELIM, nTablePos);
1232  if (nCmdTypePos>=0)
1233  {
1234  aDBData.sCommand = rData.m_sPar1.copy(nTablePos, nCmdTypePos++ - nTablePos);
1235  nExpPos = rData.m_sPar1.indexOf(DB_DELIM, nCmdTypePos);
1236  if (nExpPos>=0)
1237  {
1238  aDBData.nCommandType = rData.m_sPar1.copy(nCmdTypePos, nExpPos++ - nCmdTypePos).toInt32();
1239  }
1240  }
1241  }
1242 
1243  sal_Int32 nPos = 0;
1244  if (nExpPos>=0)
1245  nPos = nExpPos;
1246  else if (nTablePos>=0)
1247  nPos = nTablePos;
1248 
1249  OUString sPar1 = rData.m_sPar1.copy(nPos);
1250 
1251  if (!aDBData.sDataSource.isEmpty() && pCurShell->GetDBData() != aDBData)
1252  pCurShell->ChgDBData(aDBData);
1253 
1254  switch(rData.m_nTypeId)
1255  {
1256  case TYP_DBNAMEFLD:
1257  {
1258  SwDBNameFieldType* pTyp =
1259  static_cast<SwDBNameFieldType*>(pCurShell->GetFieldType(0, SwFieldIds::DatabaseName));
1260  pField.reset(new SwDBNameField(pTyp, aDBData));
1261 
1262  break;
1263  }
1264  case TYP_DBNEXTSETFLD:
1265  {
1266  SwDBNextSetFieldType* pTyp = static_cast<SwDBNextSetFieldType*>(pCurShell->GetFieldType(
1267  0, SwFieldIds::DbNextSet) );
1268  pField.reset(new SwDBNextSetField(pTyp, sPar1, aDBData));
1269  bExp = true;
1270  break;
1271  }
1272  case TYP_DBNUMSETFLD:
1273  {
1274  SwDBNumSetFieldType* pTyp = static_cast<SwDBNumSetFieldType*>( pCurShell->GetFieldType(
1275  0, SwFieldIds::DbNumSet) );
1276  pField.reset(new SwDBNumSetField( pTyp, sPar1, rData.m_sPar2, aDBData));
1277  bExp = true;
1278  break;
1279  }
1280  case TYP_DBSETNUMBERFLD:
1281  {
1282  SwDBSetNumberFieldType* pTyp = static_cast<SwDBSetNumberFieldType*>(
1283  pCurShell->GetFieldType(0, SwFieldIds::DbSetNumber) );
1284  pField.reset(new SwDBSetNumberField( pTyp, aDBData, nFormatId));
1285  bExp = true;
1286  break;
1287  }
1288  }
1289 #endif
1290  break;
1291  }
1292 
1293  case TYP_USERFLD:
1294  {
1295  SwUserFieldType* pTyp =
1296  static_cast<SwUserFieldType*>( pCurShell->GetFieldType(SwFieldIds::User, rData.m_sPar1) );
1297 
1298  // only if existing
1299  if(!pTyp)
1300  {
1301  pTyp = static_cast<SwUserFieldType*>( pCurShell->InsertFieldType(
1302  SwUserFieldType(pCurShell->GetDoc(), rData.m_sPar1)) );
1303  }
1304  if (pTyp->GetContent(nFormatId) != rData.m_sPar2)
1305  pTyp->SetContent(rData.m_sPar2, nFormatId);
1306  pField.reset(new SwUserField(pTyp, 0, nFormatId));
1307  if (pField->GetSubType() != nSubType)
1308  pField->SetSubType(nSubType);
1309  bTable = true;
1310  break;
1311  }
1312 
1313  case TYP_INPUTFLD:
1314  {
1315  if ((nSubType & 0x00ff) == INP_VAR)
1316  {
1317  SwSetExpFieldType* pTyp = static_cast<SwSetExpFieldType*>(
1318  pCurShell->GetFieldType(SwFieldIds::SetExp, rData.m_sPar1) );
1319 
1320  // no Expression Type with this name existing -> create
1321  if(pTyp)
1322  {
1323  std::unique_ptr<SwSetExpField> pExpField(
1324  new SwSetExpField(pTyp, OUString(), nFormatId));
1325 
1326  // Don't change type of SwSetExpFieldType:
1327  sal_uInt16 nOldSubType = pExpField->GetSubType();
1328  pExpField->SetSubType(nOldSubType | (nSubType & 0xff00));
1329 
1330  pExpField->SetPromptText(rData.m_sPar2);
1331  pExpField->SetInputFlag(true) ;
1332  bExp = true;
1333  pField = std::move(pExpField);
1334  }
1335  else
1336  return false;
1337  }
1338  else
1339  {
1340  SwInputFieldType* pTyp =
1341  static_cast<SwInputFieldType*>( pCurShell->GetFieldType(0, SwFieldIds::Input) );
1342 
1343  pField.reset(
1344  new SwInputField( pTyp, rData.m_sPar1, rData.m_sPar2, nSubType|nsSwExtendedSubType::SUB_INVISIBLE, nFormatId));
1345  }
1346  break;
1347  }
1348 
1349  case TYP_SETFLD:
1350  {
1351  if (rData.m_sPar2.isEmpty()) // empty variables are not allowed
1352  return false;
1353 
1354  SwSetExpFieldType* pTyp = static_cast<SwSetExpFieldType*>( pCurShell->InsertFieldType(
1355  SwSetExpFieldType(pCurShell->GetDoc(), rData.m_sPar1) ) );
1356 
1357  std::unique_ptr<SwSetExpField> pExpField(new SwSetExpField( pTyp, rData.m_sPar2, nFormatId));
1358  pExpField->SetSubType(nSubType);
1359  pExpField->SetPar2(rData.m_sPar2);
1360  bExp = true;
1361  pField = std::move(pExpField);
1362  break;
1363  }
1364 
1365  case TYP_SEQFLD:
1366  {
1367  SwSetExpFieldType* pTyp = static_cast<SwSetExpFieldType*>( pCurShell->InsertFieldType(
1369 
1370  sal_uInt8 nLevel = static_cast< sal_uInt8 >(nSubType & 0xff);
1371 
1372  pTyp->SetOutlineLvl(nLevel);
1373  if (nLevel != 0x7f && cSeparator == 0)
1374  cSeparator = '.';
1375 
1376  pTyp->SetDelimiter(OUString(cSeparator));
1377  pField.reset(new SwSetExpField(pTyp, rData.m_sPar2, nFormatId));
1378  bExp = true;
1379  break;
1380  }
1381 
1382  case TYP_GETFLD:
1383  {
1384  // is there a corresponding SetField
1385  SwSetExpFieldType* pSetTyp = static_cast<SwSetExpFieldType*>(
1386  pCurShell->GetFieldType(SwFieldIds::SetExp, rData.m_sPar1));
1387 
1388  if(pSetTyp)
1389  {
1390  SwGetExpFieldType* pTyp = static_cast<SwGetExpFieldType*>( pCurShell->GetFieldType(
1391  0, SwFieldIds::GetExp) );
1392  pField.reset( new SwGetExpField(pTyp, rData.m_sPar1, pSetTyp->GetType(), nFormatId) );
1393  pField->SetSubType(nSubType | pSetTyp->GetType());
1394  bExp = true;
1395  }
1396  else
1397  return false;
1398  break;
1399  }
1400 
1401  case TYP_FORMELFLD:
1402  {
1403  if(pCurShell->GetFrameType(nullptr,false) & FrameTypeFlags::TABLE)
1404  {
1405  pCurShell->StartAllAction();
1406 
1407  SvNumberFormatter* pFormatter = pCurShell->GetDoc()->GetNumberFormatter();
1408  const SvNumberformat* pEntry = pFormatter->GetEntry(nFormatId);
1409 
1410  if (pEntry)
1411  {
1412  SfxStringItem aFormat(FN_NUMBER_FORMAT, pEntry->GetFormatstring());
1413  pCurShell->GetView().GetViewFrame()->GetDispatcher()->
1414  ExecuteList(FN_NUMBER_FORMAT, SfxCallMode::SYNCHRON,
1415  { &aFormat });
1416  }
1417 
1418  SfxItemSet aBoxSet( pCurShell->GetAttrPool(),
1420 
1421  OUString sFormula(comphelper::string::stripStart(rData.m_sPar2, ' '));
1422  if ( sFormula.startsWith("=") )
1423  {
1424  sFormula = sFormula.copy(1);
1425  }
1426 
1427  aBoxSet.Put( SwTableBoxFormula( sFormula ));
1428  pCurShell->SetTableBoxFormulaAttrs( aBoxSet );
1429  pCurShell->UpdateTable();
1430 
1431  pCurShell->EndAllAction();
1432  return true;
1433 
1434  }
1435  else
1436  {
1437  SwGetExpFieldType* pTyp = static_cast<SwGetExpFieldType*>(
1438  pCurShell->GetFieldType(0, SwFieldIds::GetExp) );
1439  pField.reset( new SwGetExpField(pTyp, rData.m_sPar2, nsSwGetSetExpType::GSE_FORMULA, nFormatId) );
1440  pField->SetSubType(nSubType);
1441  bExp = true;
1442  }
1443  break;
1444  }
1445  case TYP_SETREFPAGEFLD:
1446  pField.reset( new SwRefPageSetField( static_cast<SwRefPageSetFieldType*>(
1447  pCurShell->GetFieldType( 0, SwFieldIds::RefPageSet ) ),
1448  static_cast<short>(rData.m_sPar2.toInt32()), 0 != nSubType ) );
1449  bPageVar = true;
1450  break;
1451 
1452  case TYP_GETREFPAGEFLD:
1453  pField.reset( new SwRefPageGetField( static_cast<SwRefPageGetFieldType*>(
1454  pCurShell->GetFieldType( 0, SwFieldIds::RefPageGet ) ), nFormatId ) );
1455  bPageVar = true;
1456  break;
1457  case TYP_DROPDOWN :
1458  {
1459  pField.reset( new SwDropDownField(pCurShell->GetFieldType( 0, SwFieldIds::Dropdown )) );
1460  const sal_Int32 nTokenCount = comphelper::string::getTokenCount(rData.m_sPar2, DB_DELIM);
1461  Sequence<OUString> aEntries(nTokenCount);
1462  OUString* pArray = aEntries.getArray();
1463  for(sal_Int32 nToken = 0, nIdx = 0; nToken < nTokenCount; nToken++)
1464  pArray[nToken] = rData.m_sPar2.getToken(0, DB_DELIM, nIdx);
1465  static_cast<SwDropDownField*>(pField.get())->SetItems(aEntries);
1466  static_cast<SwDropDownField*>(pField.get())->SetName(rData.m_sPar1);
1467  }
1468  break;
1469 
1470  // Insert Paragraph Signature field by signing the paragraph.
1471  // The resulting field is really a metadata field, created and added via signing.
1472  case TYP_PARAGRAPHSIGFLD:
1473  pCurShell->SignParagraph();
1474  return true;
1475  break;
1476 
1477  default:
1478  { OSL_ENSURE(false, "wrong field type");
1479  return false;
1480  }
1481  }
1482  OSL_ENSURE(pField, "field not available");
1483 
1484  //the auto language flag has to be set prior to the language!
1485  pField->SetAutomaticLanguage(rData.m_bIsAutomaticLanguage);
1487  pField->SetLanguage(nLang);
1488 
1489  // insert
1490  pCurShell->StartAllAction();
1491 
1492  pCurShell->Insert(*pField, rData.m_pAnnotationRange.get());
1493 
1494  if (TYP_INPUTFLD == rData.m_nTypeId)
1495  {
1496  pCurShell->Push();
1497 
1498  // start dialog, not before the field is inserted tdf#99529
1499  pCurShell->Left(CRSR_SKIP_CHARS,
1500  false, (INP_VAR == (nSubType & 0xff)) ? 1 : 2, false );
1501  pCurShell->StartInputFieldDlg(pField.get(), false, true, rData.m_pParent);
1502 
1504  }
1505 
1506  if(bExp && m_bEvalExp)
1507  pCurShell->UpdateExpFields(true);
1508 
1509  if(bTable)
1510  {
1511  pCurShell->Left(CRSR_SKIP_CHARS, false, 1, false );
1512  pCurShell->UpdateOneField(*pField);
1513  pCurShell->Right(CRSR_SKIP_CHARS, false, 1, false );
1514  }
1515  else if( bPageVar )
1516  static_cast<SwRefPageGetFieldType*>(pCurShell->GetFieldType( 0, SwFieldIds::RefPageGet ))->UpdateFields();
1517  else if( TYP_GETREFFLD == rData.m_nTypeId )
1518  pField->GetTyp()->ModifyNotification( nullptr, nullptr );
1519 
1520  // delete temporary field
1521  pField.reset();
1522 
1523  pCurShell->EndAllAction();
1524  return true;
1525 }
1526 
1527 // fields update
1528 void SwFieldMgr::UpdateCurField(sal_uInt32 nFormat,
1529  const OUString& rPar1,
1530  const OUString& rPar2,
1531  std::unique_ptr<SwField> pTmpField)
1532 {
1533  // change format
1534  OSL_ENSURE(m_pCurField, "no field at CursorPos");
1535 
1536  if (!pTmpField)
1537  pTmpField = m_pCurField->CopyField();
1538 
1539  SwFieldType* pType = pTmpField->GetTyp();
1540  const sal_uInt16 nTypeId = pTmpField->GetTypeId();
1541 
1543  OSL_ENSURE(pSh, "no SwWrtShell found");
1544  if(!pSh)
1545  return;
1546  pSh->StartAllAction();
1547 
1548  bool bSetPar2 = true;
1549  bool bSetPar1 = true;
1550  OUString sPar2( rPar2 );
1551 
1552  // Order to Format
1553  switch( nTypeId )
1554  {
1555  case TYP_DDEFLD:
1556  {
1557  // DDE-Topics/-Items can have blanks in their names!
1558  // That's not yet considered here!
1559  sal_Int32 nIndex = 0;
1560  sPar2 = sPar2.replaceFirst(" ", OUStringLiteral1(sfx2::cTokenSeparator), &nIndex );
1561  if (nIndex>=0 && ++nIndex<sPar2.getLength())
1562  {
1563  sPar2 = sPar2.replaceFirst(" ", OUStringLiteral1(sfx2::cTokenSeparator), &nIndex);
1564  }
1565  break;
1566  }
1567 
1568  case TYP_CHAPTERFLD:
1569  {
1570  sal_uInt16 nByte = static_cast<sal_uInt16>(rPar2.toInt32());
1571  nByte = std::max(sal_uInt16(1), nByte);
1572  nByte = std::min(nByte, sal_uInt16(MAXLEVEL));
1573  nByte -= 1;
1574  static_cast<SwChapterField*>(pTmpField.get())->SetLevel(static_cast<sal_uInt8>(nByte));
1575  bSetPar2 = false;
1576  break;
1577  }
1578 
1579  case TYP_SCRIPTFLD:
1580  static_cast<SwScriptField*>(pTmpField.get())->SetCodeURL(static_cast<bool>(nFormat));
1581  break;
1582 
1583  case TYP_NEXTPAGEFLD:
1584  if( SVX_NUM_CHAR_SPECIAL == nFormat )
1585  {
1586  static_cast<SwPageNumberField*>(m_pCurField)->SetUserString( sPar2 );
1587  sPar2 = "1";
1588  }
1589  else
1590  {
1591  if( nFormat + 2 == SVX_NUM_PAGEDESC )
1592  nFormat = SVX_NUM_PAGEDESC;
1593  short nOff = static_cast<short>(sPar2.toInt32());
1594  nOff += 1;
1595  sPar2 = OUString::number(nOff);
1596  }
1597  break;
1598 
1599  case TYP_PREVPAGEFLD:
1600  if( SVX_NUM_CHAR_SPECIAL == nFormat )
1601  {
1602  static_cast<SwPageNumberField*>(m_pCurField)->SetUserString( sPar2 );
1603  sPar2 = "-1";
1604  }
1605  else
1606  {
1607  if( nFormat + 2 == SVX_NUM_PAGEDESC )
1608  nFormat = SVX_NUM_PAGEDESC;
1609  short nOff = static_cast<short>(sPar2.toInt32());
1610  nOff -= 1;
1611  sPar2 = OUString::number(nOff);
1612  }
1613  break;
1614 
1615  case TYP_PAGENUMBERFLD:
1616  case TYP_GETREFPAGEFLD:
1617  if( nFormat + 2 == SVX_NUM_PAGEDESC )
1618  nFormat = SVX_NUM_PAGEDESC;
1619  break;
1620 
1621  case TYP_GETREFFLD:
1622  {
1623  bSetPar2 = false;
1624  static_cast<SwGetRefField*>(pTmpField.get())->SetSubType( static_cast<sal_uInt16>(rPar2.toInt32()) );
1625  const sal_Int32 nPos = rPar2.indexOf( '|' );
1626  if( nPos>=0 )
1627  static_cast<SwGetRefField*>(pTmpField.get())->SetSeqNo( static_cast<sal_uInt16>(rPar2.copy( nPos + 1 ).toInt32()));
1628  }
1629  break;
1630  case TYP_DROPDOWN:
1631  {
1632  sal_Int32 nTokenCount = comphelper::string::getTokenCount(sPar2, DB_DELIM);
1633  Sequence<OUString> aEntries(nTokenCount);
1634  OUString* pArray = aEntries.getArray();
1635  for(sal_Int32 nToken = 0, nIdx = 0; nToken < nTokenCount; nToken++)
1636  pArray[nToken] = sPar2.getToken(0, DB_DELIM, nIdx);
1637  static_cast<SwDropDownField*>(pTmpField.get())->SetItems(aEntries);
1638  static_cast<SwDropDownField*>(pTmpField.get())->SetName(rPar1);
1639  bSetPar1 = bSetPar2 = false;
1640  }
1641  break;
1642  case TYP_AUTHORITY :
1643  {
1644  //#i99069# changes to a bibliography field should change the field type
1645  SwAuthorityField* pAuthorityField = static_cast<SwAuthorityField*>(pTmpField.get());
1646  SwAuthorityFieldType* pAuthorityType = static_cast<SwAuthorityFieldType*>(pType);
1647  rtl::Reference<SwAuthEntry> xTempEntry(new SwAuthEntry);
1648  for( sal_Int32 i = 0, nIdx = 0; i < AUTH_FIELD_END; ++i )
1649  xTempEntry->SetAuthorField( static_cast<ToxAuthorityField>(i),
1650  rPar1.getToken( 0, TOX_STYLE_DELIMITER, nIdx ));
1651  if( pAuthorityType->ChangeEntryContent( xTempEntry.get() ) )
1652  {
1653  pType->UpdateFields();
1654  pSh->SetModified();
1655  }
1656 
1657  if( xTempEntry->GetAuthorField( AUTH_FIELD_IDENTIFIER ) ==
1658  pAuthorityField->GetFieldText( AUTH_FIELD_IDENTIFIER ) )
1659  bSetPar1 = false; //otherwise it's a new or changed entry, the field needs to be updated
1660  bSetPar2 = false;
1661  }
1662  break;
1663  }
1664 
1665  // set format
1666  // setup format before SetPar2 because of NumberFormatter!
1667  pTmpField->ChangeFormat(nFormat);
1668 
1669  if( bSetPar1 )
1670  pTmpField->SetPar1( rPar1 );
1671  if( bSetPar2 )
1672  pTmpField->SetPar2( sPar2 );
1673 
1674  // kick off update
1675  if(nTypeId == TYP_DDEFLD ||
1676  nTypeId == TYP_USERFLD ||
1677  nTypeId == TYP_USRINPFLD)
1678  {
1679  pType->UpdateFields();
1680  pSh->SetModified();
1681  }
1682  else {
1683  // mb: #32157
1684  pSh->SwEditShell::UpdateOneField(*pTmpField);
1685  GetCurField();
1686  }
1687 
1688  pTmpField.reset();
1689 
1690  pSh->EndAllAction();
1691 }
1692 
1693 // explicitly evaluate ExpressionFields
1695 {
1696  if (pSh == nullptr)
1698 
1699  if(pSh)
1700  {
1701  pSh->StartAllAction();
1702  pSh->UpdateExpFields(true);
1703  pSh->EndAllAction();
1704  }
1705 }
1707 {
1709  if( pSh )
1710  return pSh->GetCurLang();
1712 }
1713 
1715 {
1716  static const char* coFieldNms[] =
1717  {
1718  FLD_DATE_STD,
1719  FLD_TIME_STD,
1720  STR_FILENAMEFLD,
1721  STR_DBNAMEFLD,
1722  STR_CHAPTERFLD,
1723  STR_PAGENUMBERFLD,
1724  STR_DOCSTATFLD,
1725  STR_AUTHORFLD,
1726  STR_SETFLD,
1727  STR_GETFLD,
1728  STR_FORMELFLD,
1729  STR_HIDDENTXTFLD,
1730  STR_SETREFFLD,
1731  STR_GETREFFLD,
1732  STR_DDEFLD,
1733  STR_MACROFLD,
1734  STR_INPUTFLD,
1735  STR_HIDDENPARAFLD,
1736  STR_DOCINFOFLD,
1737  STR_DBFLD,
1738  STR_USERFLD,
1739  STR_POSTITFLD,
1740  STR_TEMPLNAMEFLD,
1741  STR_SEQFLD,
1742  STR_DBNEXTSETFLD,
1743  STR_DBNUMSETFLD,
1744  STR_DBSETNUMBERFLD,
1745  STR_CONDTXTFLD,
1746  STR_NEXTPAGEFLD,
1747  STR_PREVPAGEFLD,
1748  STR_EXTUSERFLD,
1749  FLD_DATE_FIX,
1750  FLD_TIME_FIX,
1751  STR_SETINPUTFLD,
1752  STR_USRINPUTFLD,
1753  STR_SETREFPAGEFLD,
1754  STR_GETREFPAGEFLD,
1755  STR_INTERNETFLD,
1756  STR_JUMPEDITFLD,
1757  STR_SCRIPTFLD,
1758  STR_AUTHORITY,
1759  STR_COMBINED_CHARS,
1760  STR_DROPDOWN,
1761  STR_CUSTOM_FIELD,
1762  STR_PARAGRAPH_SIGNATURE
1763  };
1764 
1765  // insert infos for fields
1766  SwFieldType::s_pFieldNames = new std::vector<OUString>;
1767  SwFieldType::s_pFieldNames->reserve(SAL_N_ELEMENTS(coFieldNms));
1768  for (const char* id : coFieldNms)
1769  {
1770  const OUString aTmp(SwResId(id));
1772  }
1773 }
1774 
1776 {
1777  bool bRet = false;
1778 
1779  // choose script dialog
1780  OUString aScriptURL = SfxApplication::ChooseScript(pDialogParent);
1781 
1782  // the script selector dialog returns a valid script URL
1783  if ( !aScriptURL.isEmpty() )
1784  {
1785  SetMacroPath( aScriptURL );
1786  bRet = true;
1787  }
1788 
1789  return bRet;
1790 }
1791 
1792 void SwFieldMgr::SetMacroPath(const OUString& rPath)
1793 {
1794  m_sMacroPath = rPath;
1795  m_sMacroName = rPath;
1796 
1797  // try to set sMacroName member variable by parsing the macro path
1798  // using the new URI parsing services
1799 
1801  ::comphelper::getProcessComponentContext();
1802 
1804  xFactory = uri::UriReferenceFactory::create( xContext );
1805 
1807  xUrl( xFactory->parse( m_sMacroPath ), UNO_QUERY );
1808 
1809  if ( xUrl.is() )
1810  {
1811  m_sMacroName = xUrl->getName();
1812  }
1813 }
1814 
1815 sal_uInt32 SwFieldMgr::GetDefaultFormat(sal_uInt16 nTypeId, bool bIsText, SvNumberFormatter* pFormatter)
1816 {
1817  SvNumFormatType nDefFormat;
1818 
1819  switch (nTypeId)
1820  {
1821  case TYP_TIMEFLD:
1822  case TYP_DATEFLD:
1823  {
1824  nDefFormat = (nTypeId == TYP_DATEFLD) ? SvNumFormatType::DATE : SvNumFormatType::TIME;
1825  }
1826  break;
1827 
1828  default:
1829  if (bIsText)
1830  {
1831  nDefFormat = SvNumFormatType::TEXT;
1832  }
1833  else
1834  {
1835  nDefFormat = SvNumFormatType::ALL;
1836  }
1837  break;
1838  }
1839 
1840  return pFormatter->GetStandardFormat(nDefFormat, GetCurrLanguage());
1841 }
1842 
1844 {
1845  if(!m_xNumberingInfo.is())
1846  {
1848  Reference<XDefaultNumberingProvider> xDefNum = text::DefaultNumberingProvider::create(xContext);
1849  const_cast<SwFieldMgr*>(this)->m_xNumberingInfo.set(xDefNum, UNO_QUERY);
1850  }
1851  return m_xNumberingInfo;
1852 }
1853 
1854 /* 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
static const char * FLD_EU_ARY[]
Definition: fldmgr.cxx:140
SfxViewFrame * GetViewFrame() const
Instances of SwFields and those derived from it occur 0 to n times.
Definition: fldbas.hxx:233
const SwDocInfoSubType DI_SUB_TIME
Definition: docufld.hxx:79
void SetDelimiter(const OUString &s)
Definition: expfld.hxx:179
bool Right(sal_uInt16 nMode, bool bSelect, sal_uInt16 nCount, bool bBasicCall, bool bVisual=false)
Definition: move.cxx:119
sal_uInt16 const nStart
Definition: fldmgr.hxx:62
static const char * FMT_USERVAR_ARY[]
Definition: fldmgr.cxx:285
SVX_NUM_CHARS_UPPER_LETTER_N
void EvalExpFields(SwWrtShell *pSh)
Definition: fldmgr.cxx:1694
sal_Int32 nCommandType
Definition: swdbdata.hxx:32
The shared part of a user field.
Definition: usrfld.hxx:35
static sal_uInt32 FindIndex(int nValue)
static const char * FLD_TIME_ARY[]
Definition: fldmgr.cxx:171
css::uno::Any m_aDBColumn
Definition: fldmgr.hxx:80
static sal_uInt16 GetGroup(sal_uInt16 nTypeId, sal_uInt16 nSubType)
Definition: fldmgr.cxx:500
SwView * GetActiveView()
Definition: swmodul1.cxx:123
const SwDocInfoSubType DI_SUBTYPE_END
Definition: docufld.hxx:76
sal_uInt32 GetDefaultFormat(sal_uInt16 nTypeId, bool bIsText, SvNumberFormatter *pFormatter)
Definition: fldmgr.cxx:1815
static ShellResource * GetShellRes()
Definition: viewsh.cxx:2490
sal_uInt32 GetFormat() const
Query parameters for dialog and for BASIC.
Definition: fldbas.hxx:387
static void GetFieldName_()
Sets up FieldNames; fldmgr.cxx!
Definition: fldmgr.cxx:1714
SvNumberFormatter * GetNumberFormatter(bool bCreate=true)
Definition: doc.hxx:1399
const SwExtendedSubType SUB_INVISIBLE
Invisible.
Definition: fldbas.hxx:205
bool m_bEvalExp
Definition: fldmgr.hxx:111
LanguageType getLanguageType(bool bResolveSystem=true) const
static const char * FMT_GETVAR_ARY[]
Definition: fldmgr.cxx:267
bool MoveFieldType(const SwFieldType *pFieldType, const bool bNext, const SwFieldIds nResType=SwFieldIds::Unknown, const bool bAddSetExpressionFieldsToInputFields=true)
Definition: crstrvl.cxx:714
sal_uInt16 GetFormatId(sal_uInt16 nTypeId, sal_uInt32 nFormatId) const
Definition: fldmgr.cxx:774
SfxDispatcher * GetDispatcher()
void SetOutlineLvl(sal_uInt8 n)
Definition: expfld.hxx:181
OUString sDataSource
Definition: swdbdata.hxx:30
static const sal_uInt16 VF_USR_COUNT
Definition: fldmgr.cxx:137
const sal_Unicode cTokenSeparator
Base class of all fields.
Definition: fldbas.hxx:279
SVX_NUM_CHARS_UPPER_LETTER
bool Pop(SwCursorShell::PopMode=SwCursorShell::PopMode::DeleteStack)
Definition: wrtsh1.cxx:1697
#define TOX_STYLE_DELIMITER
Definition: tox.hxx:386
void UpdateCurField(sal_uInt32 nFormat, const OUString &rPar1, const OUString &rPar2, std::unique_ptr< SwField > _pField=nullptr)
Definition: fldmgr.cxx:1528
sal_uInt16 GetTypeId() const
Definition: fldbas.cxx:209
static const sal_uInt16 VF_COUNT
Definition: fldmgr.cxx:136
std::unique_ptr< SwField > CopyField() const
Definition: fldbas.cxx:432
SwField * m_pCurField
Definition: fldmgr.hxx:101
sal_Int16 nId
css::uno::Reference< css::text::XNumberingTypeInfo > m_xNumberingInfo
Definition: fldmgr.hxx:115
OUString m_sCurFrame
Definition: fldmgr.hxx:105
static const char * FMT_REG_ARY[]
Definition: fldmgr.cxx:248
static SwWrtShell * lcl_GetShell()
Definition: fldmgr.cxx:359
void SetModified()
Definition: edws.cxx:69
void SignParagraph()
Sign the paragraph at the cursor.
Definition: edfcol.cxx:1753
#define FN_NUMBER_FORMAT
Definition: cmdid.h:426
sal_uInt16 const m_nSubType
Definition: fldmgr.hxx:71
bool InsertField(const SwInsertField_Data &rData)
Definition: fldmgr.cxx:895
void EndAllAction()
Definition: edws.cxx:96
#define RESARRAY_INDEX_NOTFOUND
For old documents the Field-Which IDs must be preserved !!!
const OUString & GetFormatstring() const
SAL_DLLPRIVATE LanguageType GetCurrLanguage() const
Definition: fldmgr.cxx:1706
#define LANGUAGE_HUNGARIAN
size_t const nFormatLength
Definition: fldmgr.cxx:300
static LanguageType nLang
Definition: srtdlg.cxx:58
static OUString GetString(sal_uInt32 i)
void UpdateFields() const
Definition: fldbas.hxx:271
LanguageType GetCurLang() const
Definition: edattr.cxx:813
sal_uInt16 GetRefMarks(std::vector< OUString > *=nullptr) const
get the names of all references in a Doc
Definition: editsh.cxx:453
Used by the UI to modify the document model.
Definition: wrtsh.hxx:88
virtual OUString GetPar1() const
Definition: fldbas.cxx:271
static sal_uInt16 GetTypeId(sal_uInt16 nPos)
Definition: fldmgr.cxx:528
sal_uInt16 sal_Unicode
void SetMacroPath(const OUString &rPath)
Definition: fldmgr.cxx:1792
const SwView & GetView() const
Definition: wrtsh.hxx:426
invariant for SwAuthorityField is that it is always registered at its SwAuthorityFieldType via AddFie...
Definition: authfld.hxx:148
static const sal_uInt16 VF_DB_COUNT
Definition: fldmgr.cxx:138
size_t GetFieldTypeCount() const
Definition: fldmgr.cxx:411
static std::vector< OUString > * s_pFieldNames
field names
Definition: fldbas.hxx:240
SwField * GetCurField(const bool bIncludeInputFieldAtStart=false) const
Definition: crstrvl.cxx:927
sal_uInt16 GetFormatCount(sal_uInt16 nTypeId, bool bHtmlMode) const
Definition: fldmgr.cxx:677
SVX_NUM_ARABIC
const sal_uInt8 MAXLEVEL
Definition: swtypes.hxx:95
OUString m_aCurPar2
Definition: fldmgr.hxx:104
SVX_NUM_ROMAN_UPPER
SVX_NUM_ROMAN_LOWER
static const char * FMT_REF_ARY[]
Definition: fldmgr.cxx:233
SwDoc * GetDoc() const
Definition: viewsh.hxx:284
css::uno::Any m_aDBConnection
Definition: fldmgr.hxx:79
static const char * FMT_AUTHOR_ARY[]
Definition: fldmgr.cxx:159
bool ChooseMacro(weld::Window *pDialogParent)
Definition: fldmgr.cxx:1775
void Insert(SwField const &, SwPaM *pAnnotationRange=nullptr)
Definition: wrtsh2.cxx:71
static const char * FLD_STAT_ARY[]
Definition: fldmgr.cxx:200
SwWrtShell *const m_pSh
Definition: fldmgr.hxx:75
static sal_uInt8 nTablePos
Definition: basesh.cxx:131
virtual void ModifyNotification(const SfxPoolItem *pOldValue, const SfxPoolItem *pNewValue)
Definition: calbck.hxx:154
void SetTableBoxFormulaAttrs(const SfxItemSet &rSet)
Definition: edtab.cxx:331
static const char * FMT_FF_ARY[]
Definition: fldmgr.cxx:190
weld::Widget * m_pParent
Definition: fldmgr.hxx:81
#define SAL_N_ELEMENTS(arr)
const SwDocInfoSubType DI_CUSTOM
Definition: docufld.hxx:75
sal_uInt32 const m_nFormatId
Definition: fldmgr.hxx:74
static OUString ChooseScript(weld::Window *pParent)
SVX_NUM_CHAR_SPECIAL
static const char * FMT_DBFLD_ARY[]
Definition: fldmgr.cxx:255
SwDBManager * GetDBManager() const
For evaluation of DB fields (new DB-manager).
Definition: edfld.cxx:340
sal_uInt16 GetCurTypeId() const
Definition: fldmgr.cxx:889
const SfxItemPool & GetAttrPool() const
Definition: viewsh.hxx:614
void GetSubTypes(sal_uInt16 nId, std::vector< OUString > &rToFill)
Definition: fldmgr.cxx:574
std::unique_ptr< SwPaM > m_pAnnotationRange
Marks the PostIt field's annotation start/end if it differs from the cursor selection.
Definition: fldmgr.hxx:83
const char ** pFormatResIds
Definition: fldmgr.cxx:299
SVX_NUM_CHARS_LOWER_LETTER
const SwFormatRefMark * GetRefMark(const OUString &rName) const
get the reference of a given name in the Doc
Definition: editsh.cxx:447
sal_uInt32 m_nCurFormat
Definition: fldmgr.hxx:110
size_t const nSubTypeLength
Definition: fldmgr.cxx:297
SwWrtShell * m_pWrtShell
Definition: fldmgr.hxx:102
The non-shared part of a user field.
Definition: usrfld.hxx:101
SwFieldType * InsertFieldType(const SwFieldType &)
insert field type
Definition: edfld.cxx:350
const OUString m_sPar1
Definition: fldmgr.hxx:72
void Push()
store a copy of the current cursor on the cursor stack
Definition: crsrsh.cxx:2145
bool CanInsertRefMark(const OUString &rStr)
Definition: fldmgr.cxx:384
void RemoveFieldType(SwFieldIds nResId, const OUString &rName)
Definition: fldmgr.cxx:403
bool InsertURL(const SwFormatINetFormat &rFormat, const OUString &rStr, bool bKeepSelection=false)
Definition: editsh.cxx:639
int i
void SetAttrItem(const SfxPoolItem &, SetAttrMode nFlags=SetAttrMode::DEFAULT, const bool bParagraphSetting=false)
Definition: edatmisc.cxx:113
static sal_uInt16 GetPackCount()
Definition: fldmgr.cxx:368
SwFieldIds
Definition: fldbas.hxx:38
size_t GetFieldTypeCount(SwFieldIds nResId=SwFieldIds::Unknown) const
count field types with a ResId, if SwFieldIds::Unknown count all
Definition: edfld.cxx:47
OUString m_sMacroName
Definition: fldmgr.hxx:108
OString stripStart(const OString &rIn, sal_Char c)
SwField * GetCurField()
Definition: fldmgr.cxx:433
std::vector< OUString > aDocInfoLst
Definition: shellres.hxx:61
SwDBData const & GetDBData() const
Database information.
Definition: edfld.cxx:298
SvNumFormatType
bool StartInputFieldDlg(SwField *, bool bPrevButton, bool bNextButton, weld::Widget *pParentWin, FieldDialogPressedButton *pPressedButton=nullptr)
Definition: wrtsh2.cxx:272
sal_uInt16 GetCursorCnt(bool bAll=true) const
Get the number of elements in the ring of cursors.
Definition: crsrsh.cxx:2619
const SwDocInfoSubType DI_SUB_DATE
Definition: docufld.hxx:80
static sal_uLong GetColumnFormat(css::uno::Reference< css::sdbc::XDataSource > const &xSource, css::uno::Reference< css::sdbc::XConnection > const &xConnection, css::uno::Reference< css::beans::XPropertySet > const &xColumn, SvNumberFormatter *pNFormatr, LanguageType nLanguage)
OUString SwResId(const char *pId)
Definition: swmodule.cxx:191
OUString GetID() const
virtual OUString GetPar2() const
Definition: fldbas.cxx:276
void UpdateOneField(SwField &)
One single field.
Definition: edfld.cxx:208
bool GoNextPrev(bool bNext=true, SwFieldType *pTyp=nullptr)
Definition: fldmgr.cxx:855
sal_uInt16 const m_nTypeId
Definition: fldmgr.hxx:70
static const char * FMT_MARK_ARY[]
Definition: fldmgr.cxx:224
SVX_NUM_CHARS_LOWER_LETTER_N
#define DB_DELIM
Definition: swtypes.hxx:141
void UpdateTable()
update fields of a listing
Definition: edtab.cxx:244
sal_uInt16 const nEnd
Definition: fldmgr.hxx:63
Dropdown field.
Definition: flddropdown.hxx:58
SwFieldType * GetTyp() const
Definition: fldbas.hxx:382
const SwDocInfoSubType DI_SUB_AUTHOR
Definition: docufld.hxx:78
const OUString m_sPar2
Definition: fldmgr.hxx:73
SAL_DLLPRIVATE css::uno::Reference< css::text::XNumberingTypeInfo > const & GetNumberingInfo() const
Definition: fldmgr.cxx:1843
void UpdateExpFields(bool bCloseDB=false)
only every expression fields update
Definition: edfld.cxx:326
SVX_NUM_PAGEDESC
const SwGetSetExpType GSE_SEQ
Sequence.
Definition: fldbas.hxx:197
SwWrtShell * GetWrtShellPtr() const
Definition: view.hxx:401
sal_uInt16 const nTypeId
Definition: fldmgr.cxx:294
bool ChangeEntryContent(const SwAuthEntry *pNewEntry)
Definition: authfld.cxx:149
static const char * FMT_CHAPTER_ARY[]
Definition: fldmgr.cxx:211
bool Left(sal_uInt16 nMode, bool bSelect, sal_uInt16 nCount, bool bBasicCall, bool bVisual=false)
Definition: move.cxx:102
static const char * FLD_DATE_ARY[]
Definition: fldmgr.cxx:165
virtual OUString GetName() const
Only in derived classes.
Definition: fldbas.cxx:145
const SwDocInfoSubType DI_SUBTYPE_BEGIN
NB: these must denote consecutive integers! NB2: these are extended by 4 DI_INFO values for backward ...
Definition: docufld.hxx:65
OUString m_sMacroPath
Definition: fldmgr.hxx:107
#define LINK_TOKEN
unsigned char sal_uInt8
static OUString GetTypeStr(sal_uInt16 nTypeId)
Definition: fldbas.cxx:128
const SvNumberformat * GetEntry(sal_uInt32 nKey) const
const o3tl::enumarray< SvxAdjust, unsigned short > aSvxToUnoAdjust USHRT_MAX
Definition: unosett.cxx:261
sal_uInt32 GetStandardFormat(SvNumFormatType eType, LanguageType eLnge=LANGUAGE_DONTKNOW)
const char ** pSubTypeResIds
Definition: fldmgr.cxx:296
static const char * FMT_NUM_ARY[]
Definition: fldmgr.cxx:177
void RemoveFieldType(size_t nField)
delete field type
Definition: edfld.cxx:98
const SwExtendedSubType SUB_OWN_FMT
SwDBField: Don't accept formatting from database.
Definition: fldbas.hxx:206
static const char * FLD_PAGEREF_ARY[]
Definition: fldmgr.cxx:279
Reference< XComponentContext > getProcessComponentContext()
const SwGetSetExpType GSE_FORMULA
Formula.
Definition: fldbas.hxx:198
OUString GetContent(sal_uInt32 nFormat=0)
Definition: usrfld.cxx:272
bool const m_bIsAutomaticLanguage
Definition: fldmgr.hxx:77
Get reference.
Definition: reffld.hxx:65
OUString GetFormatStr(sal_uInt16 nTypeId, sal_uInt32 nFormatId) const
Definition: fldmgr.cxx:720
static OUString GetTypeStr(sal_uInt16 nPos)
Definition: fldmgr.cxx:534
const sal_uInt16 CRSR_SKIP_CHARS
Definition: swcrsr.hxx:63
ScXMLEditAttributeMap::Entry const aEntries[]
static sal_uInt16 GetPos(sal_uInt16 nTypeId)
Definition: fldmgr.cxx:556
const LanguageTag & GetLanguageTag() const
~SwFieldMgr()
Definition: fldmgr.cxx:379
SwFieldMgr(SwWrtShell *pSh=nullptr)
Definition: fldmgr.cxx:371
sal_Int32 getTokenCount(const OString &rIn, sal_Char cTok)
static OUString EraseAllMnemonicChars(const OUString &rStr)
void ChgDBData(const SwDBData &SwDBData)
Definition: wrtsh1.cxx:1733
sal_uInt16 GetType() const
Definition: expfld.hxx:194
static const SwFieldGroupRgn & GetGroupRange(bool bHtmlMode, sal_uInt16 nGrpId)
Definition: fldmgr.cxx:472
static const char * FMT_SETVAR_ARY[]
Definition: fldmgr.cxx:261
css::uno::Any const m_aDBDataSource
Definition: fldmgr.hxx:78
void StartAllAction()
For all views of this document.
Definition: edws.cxx:85
sal_Unicode const m_cSeparator
Definition: fldmgr.hxx:76
sal_Int32 nPos
DefTokenId const nToken
SwFieldIds Which() const
Definition: fldbas.hxx:265
SvNumberFormatter * GetNumberFormatter()
Query NumberFormatter from document.
Definition: editsh.cxx:750
const OUString & GetFieldText(ToxAuthorityField eField) const
Definition: authfld.cxx:545
OUString m_aCurPar1
Definition: fldmgr.hxx:103
OUString sCommand
Definition: swdbdata.hxx:31
FrameTypeFlags GetFrameType(const Point *pPt, bool bStopAtFly) const
For return values see above FrameType.
Definition: fews.cxx:238
void InsertFieldType(SwFieldType const &rType)
Definition: fldmgr.cxx:880
static const char * FLD_INPUT_ARY[]
Definition: fldmgr.cxx:219
static const SwFieldPack aSwFields[]
Definition: fldmgr.cxx:304
Definition: view.hxx:146
void SetContent(const OUString &rStr, sal_uInt32 nFormat=0)
Definition: usrfld.cxx:288
static const char * FMT_DDE_ARY[]
Definition: fldmgr.cxx:273
OUString sId