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  const sal_Int16* pTypes = aTypes.getConstArray();
708  for(sal_Int32 nType = 0; nType < aTypes.getLength(); nType++)
709  {
710  sal_Int16 nCurrent = pTypes[nType];
711  //skip all values below or equal to CHARS_LOWER_LETTER_N
712  if(nCurrent > NumberingType::CHARS_LOWER_LETTER_N)
713  {
714  // #i28073# it's not necessarily a sorted sequence
715  ++nCount;
716  }
717  }
718  }
719  return nCount;
720  }
721 
722  return nCount;
723  }
724 }
725 
726 // determine FormatString to a type
727 OUString SwFieldMgr::GetFormatStr(sal_uInt16 nTypeId, sal_uInt32 nFormatId) const
728 {
729  OSL_ENSURE(nTypeId < TYP_END, "forbidden TypeId");
730  const sal_uInt16 nPos = GetPos(nTypeId);
731 
732  if (nPos == USHRT_MAX)
733  return OUString();
734 
735  const char** pStart = aSwFields[nPos].pFormatResIds;
736  if (!pStart)
737  return OUString();
738 
739  if (TYP_AUTHORFLD == nTypeId|| TYP_FILENAMEFLD == nTypeId)
740  nFormatId &= ~static_cast<sal_uInt32>(FF_FIXED); // mask out Fixed-Flag
741 
742  if (nFormatId < aSwFields[nPos].nFormatLength)
743  return SwResId(pStart[nFormatId]);
744 
745  OUString aRet;
746  if (*pStart == FMT_NUM_ARY[0])
747  {
748  if (m_xNumberingInfo.is())
749  {
750  Sequence<sal_Int16> aTypes = m_xNumberingInfo->getSupportedNumberingTypes();
751  const sal_Int16* pTypes = aTypes.getConstArray();
752  sal_Int32 nOffset = aSwFields[nPos].nFormatLength;
753  sal_uInt32 nValidEntry = 0;
754  for (sal_Int32 nType = 0; nType < aTypes.getLength(); nType++)
755  {
756  sal_Int16 nCurrent = pTypes[nType];
757  if(nCurrent > NumberingType::CHARS_LOWER_LETTER_N &&
758  (nCurrent != (NumberingType::BITMAP | LINK_TOKEN)))
759  {
760  if (nValidEntry == nFormatId - nOffset)
761  {
762  sal_uInt32 n = SvxNumberingTypeTable::FindIndex(pTypes[nType]);
763  if (n != RESARRAY_INDEX_NOTFOUND)
764  {
766  }
767  else
768  {
769  aRet = m_xNumberingInfo->getNumberingIdentifier( pTypes[nType] );
770  }
771  break;
772  }
773  ++nValidEntry;
774  }
775  }
776  }
777  }
778 
779  return aRet;
780 }
781 
782 // determine FormatId from Pseudo-ID
783 sal_uInt16 SwFieldMgr::GetFormatId(sal_uInt16 nTypeId, sal_uInt32 nFormatId) const
784 {
785  sal_uInt16 nId = static_cast<sal_uInt16>(nFormatId);
786  switch( nTypeId )
787  {
788  case TYP_DOCINFOFLD:
789  {
790  const OString sId(aSwFields[GetPos(nTypeId)].pFormatResIds[nFormatId]);
791  if (sId == FMT_REG_AUTHOR)
792  nId = DI_SUB_AUTHOR;
793  else if (sId == FMT_REG_TIME)
794  nId = DI_SUB_TIME;
795  else if (sId == FMT_REG_DATE)
796  nId = DI_SUB_DATE;
797  break;
798  }
799  case TYP_PAGENUMBERFLD:
800  case TYP_NEXTPAGEFLD:
801  case TYP_PREVPAGEFLD:
802  case TYP_DOCSTATFLD:
803  case TYP_DBSETNUMBERFLD:
804  case TYP_SEQFLD:
805  case TYP_GETREFPAGEFLD:
806  {
807  sal_uInt16 nPos = GetPos(nTypeId);
808  if (nFormatId < aSwFields[nPos].nFormatLength)
809  {
810  const OString sId(aSwFields[nPos].pFormatResIds[nFormatId]);
811  if (sId == FMT_NUM_ABC)
813  else if (sId == FMT_NUM_SABC)
815  else if (sId == FMT_NUM_ROMAN)
816  nId = SVX_NUM_ROMAN_UPPER;
817  else if (sId == FMT_NUM_SROMAN)
818  nId = SVX_NUM_ROMAN_LOWER;
819  else if (sId == FMT_NUM_ARABIC)
820  nId = SVX_NUM_ARABIC;
821  else if (sId == FMT_NUM_PAGEDESC)
822  nId = SVX_NUM_PAGEDESC;
823  else if (sId == FMT_NUM_PAGESPECIAL)
824  nId = SVX_NUM_CHAR_SPECIAL;
825  else if (sId == FMT_NUM_ABC_N)
827  else if (sId == FMT_NUM_SABC_N)
829  }
830  else if (m_xNumberingInfo.is())
831  {
832  Sequence<sal_Int16> aTypes = m_xNumberingInfo->getSupportedNumberingTypes();
833  const sal_Int16* pTypes = aTypes.getConstArray();
834  sal_Int32 nOffset = aSwFields[nPos].nFormatLength;
835  sal_Int32 nValidEntry = 0;
836  for (sal_Int32 nType = 0; nType < aTypes.getLength(); nType++)
837  {
838  sal_Int16 nCurrent = pTypes[nType];
839  if (nCurrent > NumberingType::CHARS_LOWER_LETTER_N)
840  {
841  if (nValidEntry == static_cast<sal_Int32>(nFormatId) - nOffset)
842  {
843  nId = pTypes[nType];
844  break;
845  }
846  ++nValidEntry;
847  }
848  }
849  }
850  break;
851  }
852  case TYP_DDEFLD:
853  {
854  const OString sId(aSwFields[GetPos(nTypeId)].pFormatResIds[nFormatId]);
855  if (sId == FMT_DDE_NORMAL)
856  nId = static_cast<sal_uInt16>(SfxLinkUpdateMode::ONCALL);
857  else if (sId == FMT_DDE_HOT)
858  nId = static_cast<sal_uInt16>(SfxLinkUpdateMode::ALWAYS);
859  break;
860  }
861  }
862  return nId;
863 }
864 
865 // Traveling
866 bool SwFieldMgr::GoNextPrev( bool bNext, SwFieldType* pTyp )
867 {
869  if(!pSh)
870  return false;
871 
872  if( !pTyp && m_pCurField )
873  {
874  const sal_uInt16 nTypeId = m_pCurField->GetTypeId();
875  if( TYP_SETINPFLD == nTypeId || TYP_USRINPFLD == nTypeId )
876  pTyp = pSh->GetFieldType( 0, SwFieldIds::Input );
877  else
878  pTyp = m_pCurField->GetTyp();
879  }
880 
881  if (pTyp && pTyp->Which() == SwFieldIds::Database)
882  {
883  // for fieldcommand-edit (hop to all DB fields)
884  return pSh->MoveFieldType( nullptr, bNext, SwFieldIds::Database );
885  }
886 
887  return pTyp && pSh->MoveFieldType(pTyp, bNext);
888 }
889 
890 // insert field types
892 {
894  OSL_ENSURE(pSh, "no SwWrtShell found");
895  if(pSh)
896  pSh->InsertFieldType(rType);
897 }
898 
899 // determine current TypeId
900 sal_uInt16 SwFieldMgr::GetCurTypeId() const
901 {
903 }
904 
905 // Over string insert field or update
907  const SwInsertField_Data& rData)
908 {
909  std::unique_ptr<SwField> pField;
910  bool bExp = false;
911  bool bTable = false;
912  bool bPageVar = false;
913  sal_uInt32 nFormatId = rData.m_nFormatId;
914  sal_uInt16 nSubType = rData.m_nSubType;
915  sal_Unicode cSeparator = rData.m_cSeparator;
916  SwWrtShell* pCurShell = rData.m_pSh;
917  if(!pCurShell)
918  pCurShell = m_pWrtShell ? m_pWrtShell : ::lcl_GetShell();
919  OSL_ENSURE(pCurShell, "no SwWrtShell found");
920  if(!pCurShell)
921  return false;
922 
923  switch (rData.m_nTypeId)
924  { // ATTENTION this field is inserted by a separate dialog
925  case TYP_POSTITFLD:
926  {
927  SvtUserOptions aUserOpt;
928  SwPostItFieldType* pType = static_cast<SwPostItFieldType*>(pCurShell->GetFieldType(0, SwFieldIds::Postit));
929  pField.reset(
930  new SwPostItField(
931  pType,
932  rData.m_sPar1, // author
933  rData.m_sPar2, // content
934  aUserOpt.GetID(), // author's initials
935  OUString(), // name
937  }
938  break;
939  case TYP_SCRIPTFLD:
940  {
941  SwScriptFieldType* pType =
942  static_cast<SwScriptFieldType*>(pCurShell->GetFieldType(0, SwFieldIds::Script));
943  pField.reset(new SwScriptField(pType, rData.m_sPar1, rData.m_sPar2, static_cast<bool>(nFormatId)));
944  break;
945  }
946 
947  case TYP_COMBINED_CHARS:
948  {
949  SwCombinedCharFieldType* pType = static_cast<SwCombinedCharFieldType*>(
950  pCurShell->GetFieldType( 0, SwFieldIds::CombinedChars ));
951  pField.reset(new SwCombinedCharField( pType, rData.m_sPar1 ));
952  }
953  break;
954 
955  case TYP_AUTHORITY:
956  {
957  SwAuthorityFieldType* pType =
959  if (!pType)
960  {
961  SwAuthorityFieldType const type(pCurShell->GetDoc());
962  pType = static_cast<SwAuthorityFieldType*>(
963  pCurShell->InsertFieldType(type));
964  }
965  pField.reset(new SwAuthorityField(pType, rData.m_sPar1));
966  }
967  break;
968 
969  case TYP_DATEFLD:
970  case TYP_TIMEFLD:
971  {
972  sal_uInt16 nSub = static_cast< sal_uInt16 >(rData.m_nTypeId == TYP_DATEFLD ? DATEFLD : TIMEFLD);
973  nSub |= nSubType == DATE_VAR ? 0 : FIXEDFLD;
974 
975  SwDateTimeFieldType* pTyp =
976  static_cast<SwDateTimeFieldType*>( pCurShell->GetFieldType(0, SwFieldIds::DateTime) );
977  pField.reset(new SwDateTimeField(pTyp, nSub, nFormatId));
978  pField->SetPar2(rData.m_sPar2);
979  break;
980  }
981 
982  case TYP_FILENAMEFLD:
983  {
984  SwFileNameFieldType* pTyp =
985  static_cast<SwFileNameFieldType*>( pCurShell->GetFieldType(0, SwFieldIds::Filename) );
986  pField.reset(new SwFileNameField(pTyp, nFormatId));
987  break;
988  }
989 
990  case TYP_TEMPLNAMEFLD:
991  {
992  SwTemplNameFieldType* pTyp =
993  static_cast<SwTemplNameFieldType*>( pCurShell->GetFieldType(0, SwFieldIds::TemplateName) );
994  pField.reset(new SwTemplNameField(pTyp, nFormatId));
995  break;
996  }
997 
998  case TYP_CHAPTERFLD:
999  {
1000  sal_uInt16 nByte = static_cast<sal_uInt16>(rData.m_sPar2.toInt32());
1001  SwChapterFieldType* pTyp =
1002  static_cast<SwChapterFieldType*>( pCurShell->GetFieldType(0, SwFieldIds::Chapter) );
1003  pField.reset(new SwChapterField(pTyp, nFormatId));
1004  nByte = std::max(sal_uInt16(1), nByte);
1005  nByte = std::min(nByte, sal_uInt16(MAXLEVEL));
1006  nByte -= 1;
1007  static_cast<SwChapterField*>(pField.get())->SetLevel(static_cast<sal_uInt8>(nByte));
1008  break;
1009  }
1010 
1011  case TYP_NEXTPAGEFLD:
1012  case TYP_PREVPAGEFLD:
1013  case TYP_PAGENUMBERFLD:
1014  {
1015  short nOff = static_cast<short>(rData.m_sPar2.toInt32());
1016 
1017  if(rData.m_nTypeId == TYP_NEXTPAGEFLD)
1018  {
1019  if( SVX_NUM_CHAR_SPECIAL == nFormatId )
1020  nOff = 1;
1021  else
1022  nOff += 1;
1023  nSubType = PG_NEXT;
1024  }
1025  else if(rData.m_nTypeId == TYP_PREVPAGEFLD)
1026  {
1027  if( SVX_NUM_CHAR_SPECIAL == nFormatId )
1028  nOff = -1;
1029  else
1030  nOff -= 1;
1031  nSubType = PG_PREV;
1032  }
1033  else
1034  nSubType = PG_RANDOM;
1035 
1036  SwPageNumberFieldType* pTyp =
1037  static_cast<SwPageNumberFieldType*>( pCurShell->GetFieldType(0, SwFieldIds::PageNumber) );
1038  pField.reset(new SwPageNumberField(pTyp, nSubType, nFormatId, nOff));
1039 
1040  if( SVX_NUM_CHAR_SPECIAL == nFormatId &&
1041  ( PG_PREV == nSubType || PG_NEXT == nSubType ) )
1042  static_cast<SwPageNumberField*>(pField.get())->SetUserString( rData.m_sPar2 );
1043  break;
1044  }
1045 
1046  case TYP_DOCSTATFLD:
1047  {
1048  SwDocStatFieldType* pTyp =
1049  static_cast<SwDocStatFieldType*>( pCurShell->GetFieldType(0, SwFieldIds::DocStat) );
1050  pField.reset(new SwDocStatField(pTyp, nSubType, nFormatId));
1051  break;
1052  }
1053 
1054  case TYP_AUTHORFLD:
1055  {
1056  SwAuthorFieldType* pTyp =
1057  static_cast<SwAuthorFieldType*>( pCurShell->GetFieldType(0, SwFieldIds::Author) );
1058  pField.reset(new SwAuthorField(pTyp, nFormatId));
1059  break;
1060  }
1061 
1062  case TYP_CONDTXTFLD:
1063  case TYP_HIDDENTXTFLD:
1064  {
1065  SwHiddenTextFieldType* pTyp =
1066  static_cast<SwHiddenTextFieldType*>( pCurShell->GetFieldType(0, SwFieldIds::HiddenText) );
1067  pField.reset(new SwHiddenTextField(pTyp, true, rData.m_sPar1, rData.m_sPar2, false, rData.m_nTypeId));
1068  bExp = true;
1069  break;
1070  }
1071 
1072  case TYP_HIDDENPARAFLD:
1073  {
1074  SwHiddenParaFieldType* pTyp =
1075  static_cast<SwHiddenParaFieldType*>( pCurShell->GetFieldType(0, SwFieldIds::HiddenPara) );
1076  pField.reset(new SwHiddenParaField(pTyp, rData.m_sPar1));
1077  bExp = true;
1078  break;
1079  }
1080 
1081  case TYP_SETREFFLD:
1082  {
1083  if( !rData.m_sPar1.isEmpty() && CanInsertRefMark( rData.m_sPar1 ) )
1084  {
1085  pCurShell->SetAttrItem( SwFormatRefMark( rData.m_sPar1 ) );
1086  return true;
1087  }
1088  return false;
1089  }
1090 
1091  case TYP_GETREFFLD:
1092  {
1093  SwGetRefFieldType* pTyp =
1094  static_cast<SwGetRefFieldType*>( pCurShell->GetFieldType(0, SwFieldIds::GetRef) );
1095  sal_uInt16 nSeqNo = static_cast<sal_uInt16>(rData.m_sPar2.toInt32());
1096  OUString sReferenceLanguage;
1097  // handle language-variant formats
1098  if (nFormatId >= SAL_N_ELEMENTS(FMT_REF_ARY))
1099  {
1101  if (nLang == LANGUAGE_HUNGARIAN)
1102  {
1103  if (nFormatId >= SAL_N_ELEMENTS(FMT_REF_ARY) * 2)
1104  sReferenceLanguage = "Hu";
1105  else
1106  sReferenceLanguage = "hu";
1107  }
1108  nFormatId %= SAL_N_ELEMENTS(FMT_REF_ARY);
1109  }
1110  pField.reset(new SwGetRefField(pTyp, rData.m_sPar1, sReferenceLanguage, nSubType, nSeqNo, nFormatId));
1111  bExp = true;
1112  break;
1113  }
1114 
1115  case TYP_DDEFLD:
1116  {
1117  //JP 28.08.95: DDE-Topics/-Items can have blanks in their names!
1118  // That's not yet considered here.
1119  sal_Int32 nIndex = 0;
1120  OUString sCmd = rData.m_sPar2.replaceFirst(" ", OUStringLiteral1(sfx2::cTokenSeparator), &nIndex);
1121  if (nIndex>=0 && ++nIndex<sCmd.getLength())
1122  {
1123  sCmd = sCmd.replaceFirst(" ", OUStringLiteral1(sfx2::cTokenSeparator), &nIndex);
1124  }
1125 
1126  SwDDEFieldType aType( rData.m_sPar1, sCmd, static_cast<SfxLinkUpdateMode>(nFormatId) );
1127  SwDDEFieldType* pTyp = static_cast<SwDDEFieldType*>( pCurShell->InsertFieldType( aType ) );
1128  pField.reset(new SwDDEField( pTyp ));
1129  break;
1130  }
1131 
1132  case TYP_MACROFLD:
1133  {
1134  SwMacroFieldType* pTyp =
1135  static_cast<SwMacroFieldType*>(pCurShell->GetFieldType(0, SwFieldIds::Macro));
1136 
1137  pField.reset(new SwMacroField(pTyp, rData.m_sPar1, rData.m_sPar2));
1138 
1139  break;
1140  }
1141 
1142  case TYP_INTERNETFLD:
1143  {
1144  SwFormatINetFormat aFormat( rData.m_sPar1, m_sCurFrame );
1145  return pCurShell->InsertURL( aFormat, rData.m_sPar2 );
1146  }
1147 
1148  case TYP_JUMPEDITFLD:
1149  {
1150  SwJumpEditFieldType* pTyp =
1151  static_cast<SwJumpEditFieldType*>(pCurShell->GetFieldType(0, SwFieldIds::JumpEdit));
1152 
1153  pField.reset(new SwJumpEditField(pTyp, nFormatId, rData.m_sPar1, rData.m_sPar2));
1154  break;
1155  }
1156 
1157  case TYP_DOCINFOFLD:
1158  {
1159  SwDocInfoFieldType* pTyp = static_cast<SwDocInfoFieldType*>( pCurShell->GetFieldType(
1160  0, SwFieldIds::DocInfo ) );
1161  pField.reset(new SwDocInfoField(pTyp, nSubType, rData.m_sPar1, nFormatId));
1162  break;
1163  }
1164 
1165  case TYP_EXTUSERFLD:
1166  {
1167  SwExtUserFieldType* pTyp = static_cast<SwExtUserFieldType*>( pCurShell->GetFieldType(
1168  0, SwFieldIds::ExtUser) );
1169  pField.reset(new SwExtUserField(pTyp, nSubType, nFormatId));
1170  break;
1171  }
1172 
1173  case TYP_DBFLD:
1174  {
1175 #if HAVE_FEATURE_DBCONNECTIVITY
1176  SwDBData aDBData;
1177  OUString sPar1;
1178 
1179  if (rData.m_sPar1.indexOf(DB_DELIM)<0)
1180  {
1181  aDBData = pCurShell->GetDBData();
1182  sPar1 = rData.m_sPar1;
1183  }
1184  else
1185  {
1186  sal_Int32 nIdx{ 0 };
1187  aDBData.sDataSource = rData.m_sPar1.getToken(0, DB_DELIM, nIdx);
1188  aDBData.sCommand = rData.m_sPar1.getToken(0, DB_DELIM, nIdx);
1189  aDBData.nCommandType = rData.m_sPar1.getToken(0, DB_DELIM, nIdx).toInt32();
1190  sPar1 = rData.m_sPar1.getToken(0, DB_DELIM, nIdx);
1191  }
1192 
1193  if(!aDBData.sDataSource.isEmpty() && pCurShell->GetDBData() != aDBData)
1194  pCurShell->ChgDBData(aDBData);
1195 
1196  SwDBFieldType* pTyp = static_cast<SwDBFieldType*>(pCurShell->InsertFieldType(
1197  SwDBFieldType(pCurShell->GetDoc(), sPar1, aDBData) ) );
1198  pField.reset(new SwDBField(pTyp));
1199  pField->SetSubType(nSubType);
1200 
1201  if( !(nSubType & nsSwExtendedSubType::SUB_OWN_FMT) ) // determine database format
1202  {
1203  Reference< XDataSource> xSource;
1204  rData.m_aDBDataSource >>= xSource;
1205  Reference<XConnection> xConnection;
1206  rData.m_aDBConnection >>= xConnection;
1207  Reference<XPropertySet> xColumn;
1208  rData.m_aDBColumn >>= xColumn;
1209  if(xColumn.is())
1210  {
1211  nFormatId = SwDBManager::GetColumnFormat(xSource, xConnection, xColumn,
1212  pCurShell->GetNumberFormatter(), GetCurrLanguage() );
1213  }
1214  else
1215  nFormatId = pCurShell->GetDBManager()->GetColumnFormat(
1216  aDBData.sDataSource, aDBData.sCommand, sPar1,
1217  pCurShell->GetNumberFormatter(), GetCurrLanguage() );
1218  }
1219  pField->ChangeFormat( nFormatId );
1220 
1221  bExp = true;
1222 #endif
1223  break;
1224  }
1225 
1226  case TYP_DBSETNUMBERFLD:
1227  case TYP_DBNUMSETFLD:
1228  case TYP_DBNEXTSETFLD:
1229  case TYP_DBNAMEFLD:
1230  {
1231 #if HAVE_FEATURE_DBCONNECTIVITY
1232  SwDBData aDBData;
1233 
1234  // extract DBName from rData.m_sPar1. Format: DBName.TableName.CommandType.ExpStrg
1235  sal_Int32 nTablePos = rData.m_sPar1.indexOf(DB_DELIM);
1236  sal_Int32 nCmdTypePos = -1;
1237  sal_Int32 nExpPos = -1;
1238 
1239  if (nTablePos>=0)
1240  {
1241  aDBData.sDataSource = rData.m_sPar1.copy(0, nTablePos++);
1242  nCmdTypePos = rData.m_sPar1.indexOf(DB_DELIM, nTablePos);
1243  if (nCmdTypePos>=0)
1244  {
1245  aDBData.sCommand = rData.m_sPar1.copy(nTablePos, nCmdTypePos++ - nTablePos);
1246  nExpPos = rData.m_sPar1.indexOf(DB_DELIM, nCmdTypePos);
1247  if (nExpPos>=0)
1248  {
1249  aDBData.nCommandType = rData.m_sPar1.copy(nCmdTypePos, nExpPos++ - nCmdTypePos).toInt32();
1250  }
1251  }
1252  }
1253 
1254  sal_Int32 nPos = 0;
1255  if (nExpPos>=0)
1256  nPos = nExpPos;
1257  else if (nTablePos>=0)
1258  nPos = nTablePos;
1259 
1260  OUString sPar1 = rData.m_sPar1.copy(nPos);
1261 
1262  if (!aDBData.sDataSource.isEmpty() && pCurShell->GetDBData() != aDBData)
1263  pCurShell->ChgDBData(aDBData);
1264 
1265  switch(rData.m_nTypeId)
1266  {
1267  case TYP_DBNAMEFLD:
1268  {
1269  SwDBNameFieldType* pTyp =
1270  static_cast<SwDBNameFieldType*>(pCurShell->GetFieldType(0, SwFieldIds::DatabaseName));
1271  pField.reset(new SwDBNameField(pTyp, aDBData));
1272 
1273  break;
1274  }
1275  case TYP_DBNEXTSETFLD:
1276  {
1277  SwDBNextSetFieldType* pTyp = static_cast<SwDBNextSetFieldType*>(pCurShell->GetFieldType(
1278  0, SwFieldIds::DbNextSet) );
1279  pField.reset(new SwDBNextSetField(pTyp, sPar1, aDBData));
1280  bExp = true;
1281  break;
1282  }
1283  case TYP_DBNUMSETFLD:
1284  {
1285  SwDBNumSetFieldType* pTyp = static_cast<SwDBNumSetFieldType*>( pCurShell->GetFieldType(
1286  0, SwFieldIds::DbNumSet) );
1287  pField.reset(new SwDBNumSetField( pTyp, sPar1, rData.m_sPar2, aDBData));
1288  bExp = true;
1289  break;
1290  }
1291  case TYP_DBSETNUMBERFLD:
1292  {
1293  SwDBSetNumberFieldType* pTyp = static_cast<SwDBSetNumberFieldType*>(
1294  pCurShell->GetFieldType(0, SwFieldIds::DbSetNumber) );
1295  pField.reset(new SwDBSetNumberField( pTyp, aDBData, nFormatId));
1296  bExp = true;
1297  break;
1298  }
1299  }
1300 #endif
1301  break;
1302  }
1303 
1304  case TYP_USERFLD:
1305  {
1306  SwUserFieldType* pTyp =
1307  static_cast<SwUserFieldType*>( pCurShell->GetFieldType(SwFieldIds::User, rData.m_sPar1) );
1308 
1309  // only if existing
1310  if(!pTyp)
1311  {
1312  pTyp = static_cast<SwUserFieldType*>( pCurShell->InsertFieldType(
1313  SwUserFieldType(pCurShell->GetDoc(), rData.m_sPar1)) );
1314  }
1315  if (pTyp->GetContent(nFormatId) != rData.m_sPar2)
1316  pTyp->SetContent(rData.m_sPar2, nFormatId);
1317  pField.reset(new SwUserField(pTyp, 0, nFormatId));
1318  if (pField->GetSubType() != nSubType)
1319  pField->SetSubType(nSubType);
1320  bTable = true;
1321  break;
1322  }
1323 
1324  case TYP_INPUTFLD:
1325  {
1326  if ((nSubType & 0x00ff) == INP_VAR)
1327  {
1328  SwSetExpFieldType* pTyp = static_cast<SwSetExpFieldType*>(
1329  pCurShell->GetFieldType(SwFieldIds::SetExp, rData.m_sPar1) );
1330 
1331  // no Expression Type with this name existing -> create
1332  if(pTyp)
1333  {
1334  std::unique_ptr<SwSetExpField> pExpField(
1335  new SwSetExpField(pTyp, OUString(), nFormatId));
1336 
1337  // Don't change type of SwSetExpFieldType:
1338  sal_uInt16 nOldSubType = pExpField->GetSubType();
1339  pExpField->SetSubType(nOldSubType | (nSubType & 0xff00));
1340 
1341  pExpField->SetPromptText(rData.m_sPar2);
1342  pExpField->SetInputFlag(true) ;
1343  bExp = true;
1344  pField = std::move(pExpField);
1345  }
1346  else
1347  return false;
1348  }
1349  else
1350  {
1351  SwInputFieldType* pTyp =
1352  static_cast<SwInputFieldType*>( pCurShell->GetFieldType(0, SwFieldIds::Input) );
1353 
1354  pField.reset(
1355  new SwInputField( pTyp, rData.m_sPar1, rData.m_sPar2, nSubType|nsSwExtendedSubType::SUB_INVISIBLE, nFormatId));
1356  }
1357  break;
1358  }
1359 
1360  case TYP_SETFLD:
1361  {
1362  if (rData.m_sPar2.isEmpty()) // empty variables are not allowed
1363  return false;
1364 
1365  SwSetExpFieldType* pTyp = static_cast<SwSetExpFieldType*>( pCurShell->InsertFieldType(
1366  SwSetExpFieldType(pCurShell->GetDoc(), rData.m_sPar1) ) );
1367 
1368  std::unique_ptr<SwSetExpField> pExpField(new SwSetExpField( pTyp, rData.m_sPar2, nFormatId));
1369  pExpField->SetSubType(nSubType);
1370  pExpField->SetPar2(rData.m_sPar2);
1371  bExp = true;
1372  pField = std::move(pExpField);
1373  break;
1374  }
1375 
1376  case TYP_SEQFLD:
1377  {
1378  SwSetExpFieldType* pTyp = static_cast<SwSetExpFieldType*>( pCurShell->InsertFieldType(
1380 
1381  sal_uInt8 nLevel = static_cast< sal_uInt8 >(nSubType & 0xff);
1382 
1383  pTyp->SetOutlineLvl(nLevel);
1384  if (nLevel != 0x7f && cSeparator == 0)
1385  cSeparator = '.';
1386 
1387  pTyp->SetDelimiter(OUString(cSeparator));
1388  pField.reset(new SwSetExpField(pTyp, rData.m_sPar2, nFormatId));
1389  bExp = true;
1390  break;
1391  }
1392 
1393  case TYP_GETFLD:
1394  {
1395  // is there a corresponding SetField
1396  SwSetExpFieldType* pSetTyp = static_cast<SwSetExpFieldType*>(
1397  pCurShell->GetFieldType(SwFieldIds::SetExp, rData.m_sPar1));
1398 
1399  if(pSetTyp)
1400  {
1401  SwGetExpFieldType* pTyp = static_cast<SwGetExpFieldType*>( pCurShell->GetFieldType(
1402  0, SwFieldIds::GetExp) );
1403  pField.reset( new SwGetExpField(pTyp, rData.m_sPar1, pSetTyp->GetType(), nFormatId) );
1404  pField->SetSubType(nSubType | pSetTyp->GetType());
1405  bExp = true;
1406  }
1407  else
1408  return false;
1409  break;
1410  }
1411 
1412  case TYP_FORMELFLD:
1413  {
1414  if(pCurShell->GetFrameType(nullptr,false) & FrameTypeFlags::TABLE)
1415  {
1416  pCurShell->StartAllAction();
1417 
1418  SvNumberFormatter* pFormatter = pCurShell->GetDoc()->GetNumberFormatter();
1419  const SvNumberformat* pEntry = pFormatter->GetEntry(nFormatId);
1420 
1421  if (pEntry)
1422  {
1423  SfxStringItem aFormat(FN_NUMBER_FORMAT, pEntry->GetFormatstring());
1424  pCurShell->GetView().GetViewFrame()->GetDispatcher()->
1425  ExecuteList(FN_NUMBER_FORMAT, SfxCallMode::SYNCHRON,
1426  { &aFormat });
1427  }
1428 
1429  SfxItemSet aBoxSet( pCurShell->GetAttrPool(),
1431 
1432  OUString sFormula(comphelper::string::stripStart(rData.m_sPar2, ' '));
1433  if ( sFormula.startsWith("=") )
1434  {
1435  sFormula = sFormula.copy(1);
1436  }
1437 
1438  aBoxSet.Put( SwTableBoxFormula( sFormula ));
1439  pCurShell->SetTableBoxFormulaAttrs( aBoxSet );
1440  pCurShell->UpdateTable();
1441 
1442  pCurShell->EndAllAction();
1443  return true;
1444 
1445  }
1446  else
1447  {
1448  SwGetExpFieldType* pTyp = static_cast<SwGetExpFieldType*>(
1449  pCurShell->GetFieldType(0, SwFieldIds::GetExp) );
1450  pField.reset( new SwGetExpField(pTyp, rData.m_sPar2, nsSwGetSetExpType::GSE_FORMULA, nFormatId) );
1451  pField->SetSubType(nSubType);
1452  bExp = true;
1453  }
1454  break;
1455  }
1456  case TYP_SETREFPAGEFLD:
1457  pField.reset( new SwRefPageSetField( static_cast<SwRefPageSetFieldType*>(
1458  pCurShell->GetFieldType( 0, SwFieldIds::RefPageSet ) ),
1459  static_cast<short>(rData.m_sPar2.toInt32()), 0 != nSubType ) );
1460  bPageVar = true;
1461  break;
1462 
1463  case TYP_GETREFPAGEFLD:
1464  pField.reset( new SwRefPageGetField( static_cast<SwRefPageGetFieldType*>(
1465  pCurShell->GetFieldType( 0, SwFieldIds::RefPageGet ) ), nFormatId ) );
1466  bPageVar = true;
1467  break;
1468  case TYP_DROPDOWN :
1469  {
1470  pField.reset( new SwDropDownField(pCurShell->GetFieldType( 0, SwFieldIds::Dropdown )) );
1471  const sal_Int32 nTokenCount = comphelper::string::getTokenCount(rData.m_sPar2, DB_DELIM);
1472  Sequence<OUString> aEntries(nTokenCount);
1473  OUString* pArray = aEntries.getArray();
1474  for(sal_Int32 nToken = 0, nIdx = 0; nToken < nTokenCount; nToken++)
1475  pArray[nToken] = rData.m_sPar2.getToken(0, DB_DELIM, nIdx);
1476  static_cast<SwDropDownField*>(pField.get())->SetItems(aEntries);
1477  static_cast<SwDropDownField*>(pField.get())->SetName(rData.m_sPar1);
1478  }
1479  break;
1480 
1481  // Insert Paragraph Signature field by signing the paragraph.
1482  // The resulting field is really a metadata field, created and added via signing.
1483  case TYP_PARAGRAPHSIGFLD:
1484  pCurShell->SignParagraph();
1485  return true;
1486  break;
1487 
1488  default:
1489  { OSL_ENSURE(false, "wrong field type");
1490  return false;
1491  }
1492  }
1493  OSL_ENSURE(pField, "field not available");
1494 
1495  //the auto language flag has to be set prior to the language!
1496  pField->SetAutomaticLanguage(rData.m_bIsAutomaticLanguage);
1498  pField->SetLanguage(nLang);
1499 
1500  // insert
1501  pCurShell->StartAllAction();
1502 
1503  pCurShell->Insert( *pField );
1504 
1505  if (TYP_INPUTFLD == rData.m_nTypeId)
1506  {
1507  pCurShell->Push();
1508 
1509  // start dialog, not before the field is inserted tdf#99529
1510  pCurShell->Left(CRSR_SKIP_CHARS,
1511  false, (INP_VAR == (nSubType & 0xff)) ? 1 : 2, false );
1512  pCurShell->StartInputFieldDlg(pField.get(), false, true, rData.m_pParent);
1513 
1515  }
1516 
1517  if(bExp && m_bEvalExp)
1518  pCurShell->UpdateExpFields(true);
1519 
1520  if(bTable)
1521  {
1522  pCurShell->Left(CRSR_SKIP_CHARS, false, 1, false );
1523  pCurShell->UpdateOneField(*pField);
1524  pCurShell->Right(CRSR_SKIP_CHARS, false, 1, false );
1525  }
1526  else if( bPageVar )
1527  static_cast<SwRefPageGetFieldType*>(pCurShell->GetFieldType( 0, SwFieldIds::RefPageGet ))->UpdateFields();
1528  else if( TYP_GETREFFLD == rData.m_nTypeId )
1529  pField->GetTyp()->ModifyNotification( nullptr, nullptr );
1530 
1531  // delete temporary field
1532  pField.reset();
1533 
1534  pCurShell->EndAllAction();
1535  return true;
1536 }
1537 
1538 // fields update
1539 void SwFieldMgr::UpdateCurField(sal_uInt32 nFormat,
1540  const OUString& rPar1,
1541  const OUString& rPar2,
1542  std::unique_ptr<SwField> pTmpField)
1543 {
1544  // change format
1545  OSL_ENSURE(m_pCurField, "no field at CursorPos");
1546 
1547  if (!pTmpField)
1548  pTmpField = m_pCurField->CopyField();
1549 
1550  SwFieldType* pType = pTmpField->GetTyp();
1551  const sal_uInt16 nTypeId = pTmpField->GetTypeId();
1552 
1554  OSL_ENSURE(pSh, "no SwWrtShell found");
1555  if(!pSh)
1556  return;
1557  pSh->StartAllAction();
1558 
1559  bool bSetPar2 = true;
1560  bool bSetPar1 = true;
1561  OUString sPar2( rPar2 );
1562 
1563  // Order to Format
1564  switch( nTypeId )
1565  {
1566  case TYP_DDEFLD:
1567  {
1568  // DDE-Topics/-Items can have blanks in their names!
1569  // That's not yet considered here!
1570  sal_Int32 nIndex = 0;
1571  sPar2 = sPar2.replaceFirst(" ", OUStringLiteral1(sfx2::cTokenSeparator), &nIndex );
1572  if (nIndex>=0 && ++nIndex<sPar2.getLength())
1573  {
1574  sPar2 = sPar2.replaceFirst(" ", OUStringLiteral1(sfx2::cTokenSeparator), &nIndex);
1575  }
1576  break;
1577  }
1578 
1579  case TYP_CHAPTERFLD:
1580  {
1581  sal_uInt16 nByte = static_cast<sal_uInt16>(rPar2.toInt32());
1582  nByte = std::max(sal_uInt16(1), nByte);
1583  nByte = std::min(nByte, sal_uInt16(MAXLEVEL));
1584  nByte -= 1;
1585  static_cast<SwChapterField*>(pTmpField.get())->SetLevel(static_cast<sal_uInt8>(nByte));
1586  bSetPar2 = false;
1587  break;
1588  }
1589 
1590  case TYP_SCRIPTFLD:
1591  static_cast<SwScriptField*>(pTmpField.get())->SetCodeURL(static_cast<bool>(nFormat));
1592  break;
1593 
1594  case TYP_NEXTPAGEFLD:
1595  if( SVX_NUM_CHAR_SPECIAL == nFormat )
1596  {
1597  static_cast<SwPageNumberField*>(m_pCurField)->SetUserString( sPar2 );
1598  sPar2 = "1";
1599  }
1600  else
1601  {
1602  if( nFormat + 2 == SVX_NUM_PAGEDESC )
1603  nFormat = SVX_NUM_PAGEDESC;
1604  short nOff = static_cast<short>(sPar2.toInt32());
1605  nOff += 1;
1606  sPar2 = OUString::number(nOff);
1607  }
1608  break;
1609 
1610  case TYP_PREVPAGEFLD:
1611  if( SVX_NUM_CHAR_SPECIAL == nFormat )
1612  {
1613  static_cast<SwPageNumberField*>(m_pCurField)->SetUserString( sPar2 );
1614  sPar2 = "-1";
1615  }
1616  else
1617  {
1618  if( nFormat + 2 == SVX_NUM_PAGEDESC )
1619  nFormat = SVX_NUM_PAGEDESC;
1620  short nOff = static_cast<short>(sPar2.toInt32());
1621  nOff -= 1;
1622  sPar2 = OUString::number(nOff);
1623  }
1624  break;
1625 
1626  case TYP_PAGENUMBERFLD:
1627  case TYP_GETREFPAGEFLD:
1628  if( nFormat + 2 == SVX_NUM_PAGEDESC )
1629  nFormat = SVX_NUM_PAGEDESC;
1630  break;
1631 
1632  case TYP_GETREFFLD:
1633  {
1634  bSetPar2 = false;
1635  static_cast<SwGetRefField*>(pTmpField.get())->SetSubType( static_cast<sal_uInt16>(rPar2.toInt32()) );
1636  const sal_Int32 nPos = rPar2.indexOf( '|' );
1637  if( nPos>=0 )
1638  static_cast<SwGetRefField*>(pTmpField.get())->SetSeqNo( static_cast<sal_uInt16>(rPar2.copy( nPos + 1 ).toInt32()));
1639  }
1640  break;
1641  case TYP_DROPDOWN:
1642  {
1643  sal_Int32 nTokenCount = comphelper::string::getTokenCount(sPar2, DB_DELIM);
1644  Sequence<OUString> aEntries(nTokenCount);
1645  OUString* pArray = aEntries.getArray();
1646  for(sal_Int32 nToken = 0, nIdx = 0; nToken < nTokenCount; nToken++)
1647  pArray[nToken] = sPar2.getToken(0, DB_DELIM, nIdx);
1648  static_cast<SwDropDownField*>(pTmpField.get())->SetItems(aEntries);
1649  static_cast<SwDropDownField*>(pTmpField.get())->SetName(rPar1);
1650  bSetPar1 = bSetPar2 = false;
1651  }
1652  break;
1653  case TYP_AUTHORITY :
1654  {
1655  //#i99069# changes to a bibliography field should change the field type
1656  SwAuthorityField* pAuthorityField = static_cast<SwAuthorityField*>(pTmpField.get());
1657  SwAuthorityFieldType* pAuthorityType = static_cast<SwAuthorityFieldType*>(pType);
1658  rtl::Reference<SwAuthEntry> xTempEntry(new SwAuthEntry);
1659  for( sal_Int32 i = 0, nIdx = 0; i < AUTH_FIELD_END; ++i )
1660  xTempEntry->SetAuthorField( static_cast<ToxAuthorityField>(i),
1661  rPar1.getToken( 0, TOX_STYLE_DELIMITER, nIdx ));
1662  if( pAuthorityType->ChangeEntryContent( xTempEntry.get() ) )
1663  {
1664  pType->UpdateFields();
1665  pSh->SetModified();
1666  }
1667 
1668  if( xTempEntry->GetAuthorField( AUTH_FIELD_IDENTIFIER ) ==
1669  pAuthorityField->GetFieldText( AUTH_FIELD_IDENTIFIER ) )
1670  bSetPar1 = false; //otherwise it's a new or changed entry, the field needs to be updated
1671  bSetPar2 = false;
1672  }
1673  break;
1674  }
1675 
1676  // set format
1677  // setup format before SetPar2 because of NumberFormatter!
1678  pTmpField->ChangeFormat(nFormat);
1679 
1680  if( bSetPar1 )
1681  pTmpField->SetPar1( rPar1 );
1682  if( bSetPar2 )
1683  pTmpField->SetPar2( sPar2 );
1684 
1685  // kick off update
1686  if(nTypeId == TYP_DDEFLD ||
1687  nTypeId == TYP_USERFLD ||
1688  nTypeId == TYP_USRINPFLD)
1689  {
1690  pType->UpdateFields();
1691  pSh->SetModified();
1692  }
1693  else {
1694  // mb: #32157
1695  pSh->SwEditShell::UpdateOneField(*pTmpField);
1696  GetCurField();
1697  }
1698 
1699  pTmpField.reset();
1700 
1701  pSh->EndAllAction();
1702 }
1703 
1704 // explicitly evaluate ExpressionFields
1706 {
1707  if (pSh == nullptr)
1709 
1710  if(pSh)
1711  {
1712  pSh->StartAllAction();
1713  pSh->UpdateExpFields(true);
1714  pSh->EndAllAction();
1715  }
1716 }
1718 {
1720  if( pSh )
1721  return pSh->GetCurLang();
1723 }
1724 
1726 {
1727  static const char* coFieldNms[] =
1728  {
1729  FLD_DATE_STD,
1730  FLD_TIME_STD,
1731  STR_FILENAMEFLD,
1732  STR_DBNAMEFLD,
1733  STR_CHAPTERFLD,
1734  STR_PAGENUMBERFLD,
1735  STR_DOCSTATFLD,
1736  STR_AUTHORFLD,
1737  STR_SETFLD,
1738  STR_GETFLD,
1739  STR_FORMELFLD,
1740  STR_HIDDENTXTFLD,
1741  STR_SETREFFLD,
1742  STR_GETREFFLD,
1743  STR_DDEFLD,
1744  STR_MACROFLD,
1745  STR_INPUTFLD,
1746  STR_HIDDENPARAFLD,
1747  STR_DOCINFOFLD,
1748  STR_DBFLD,
1749  STR_USERFLD,
1750  STR_POSTITFLD,
1751  STR_TEMPLNAMEFLD,
1752  STR_SEQFLD,
1753  STR_DBNEXTSETFLD,
1754  STR_DBNUMSETFLD,
1755  STR_DBSETNUMBERFLD,
1756  STR_CONDTXTFLD,
1757  STR_NEXTPAGEFLD,
1758  STR_PREVPAGEFLD,
1759  STR_EXTUSERFLD,
1760  FLD_DATE_FIX,
1761  FLD_TIME_FIX,
1762  STR_SETINPUTFLD,
1763  STR_USRINPUTFLD,
1764  STR_SETREFPAGEFLD,
1765  STR_GETREFPAGEFLD,
1766  STR_INTERNETFLD,
1767  STR_JUMPEDITFLD,
1768  STR_SCRIPTFLD,
1769  STR_AUTHORITY,
1770  STR_COMBINED_CHARS,
1771  STR_DROPDOWN,
1772  STR_CUSTOM_FIELD,
1773  STR_PARAGRAPH_SIGNATURE
1774  };
1775 
1776  // insert infos for fields
1777  SwFieldType::s_pFieldNames = new std::vector<OUString>;
1778  SwFieldType::s_pFieldNames->reserve(SAL_N_ELEMENTS(coFieldNms));
1779  for (const char* id : coFieldNms)
1780  {
1781  const OUString aTmp(SwResId(id));
1783  }
1784 }
1785 
1787 {
1788  bool bRet = false;
1789 
1790  // choose script dialog
1791  OUString aScriptURL = SfxApplication::ChooseScript(pDialogParent);
1792 
1793  // the script selector dialog returns a valid script URL
1794  if ( !aScriptURL.isEmpty() )
1795  {
1796  SetMacroPath( aScriptURL );
1797  bRet = true;
1798  }
1799 
1800  return bRet;
1801 }
1802 
1803 void SwFieldMgr::SetMacroPath(const OUString& rPath)
1804 {
1805  m_sMacroPath = rPath;
1806  m_sMacroName = rPath;
1807 
1808  // try to set sMacroName member variable by parsing the macro path
1809  // using the new URI parsing services
1810 
1812  ::comphelper::getProcessComponentContext();
1813 
1815  xFactory = uri::UriReferenceFactory::create( xContext );
1816 
1818  xUrl( xFactory->parse( m_sMacroPath ), UNO_QUERY );
1819 
1820  if ( xUrl.is() )
1821  {
1822  m_sMacroName = xUrl->getName();
1823  }
1824 }
1825 
1826 sal_uInt32 SwFieldMgr::GetDefaultFormat(sal_uInt16 nTypeId, bool bIsText, SvNumberFormatter* pFormatter)
1827 {
1828  SvNumFormatType nDefFormat;
1829 
1830  switch (nTypeId)
1831  {
1832  case TYP_TIMEFLD:
1833  case TYP_DATEFLD:
1834  {
1835  nDefFormat = (nTypeId == TYP_DATEFLD) ? SvNumFormatType::DATE : SvNumFormatType::TIME;
1836  }
1837  break;
1838 
1839  default:
1840  if (bIsText)
1841  {
1842  nDefFormat = SvNumFormatType::TEXT;
1843  }
1844  else
1845  {
1846  nDefFormat = SvNumFormatType::ALL;
1847  }
1848  break;
1849  }
1850 
1851  return pFormatter->GetStandardFormat(nDefFormat, GetCurrLanguage());
1852 }
1853 
1855 {
1856  if(!m_xNumberingInfo.is())
1857  {
1859  Reference<XDefaultNumberingProvider> xDefNum = text::DefaultNumberingProvider::create(xContext);
1860  const_cast<SwFieldMgr*>(this)->m_xNumberingInfo.set(xDefNum, UNO_QUERY);
1861  }
1862  return m_xNumberingInfo;
1863 }
1864 
1865 /* 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:63
static const char * FMT_USERVAR_ARY[]
Definition: fldmgr.cxx:285
SVX_NUM_CHARS_UPPER_LETTER_N
void EvalExpFields(SwWrtShell *pSh)
Definition: fldmgr.cxx:1705
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:81
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:1826
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:1725
SvNumberFormatter * GetNumberFormatter(bool bCreate=true)
Definition: doc.hxx:1399
const SwExtendedSubType SUB_INVISIBLE
Invisible.
Definition: fldbas.hxx:205
bool m_bEvalExp
Definition: fldmgr.hxx:110
void Insert(SwField const &)
Definition: wrtsh2.cxx:71
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:783
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:1690
#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:1539
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:100
sal_Int16 nId
css::uno::Reference< css::text::XNumberingTypeInfo > m_xNumberingInfo
Definition: fldmgr.hxx:114
OUString m_sCurFrame
Definition: fldmgr.hxx:104
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:1751
#define FN_NUMBER_FORMAT
Definition: cmdid.h:424
sal_uInt16 const m_nSubType
Definition: fldmgr.hxx:72
bool InsertField(const SwInsertField_Data &rData)
Definition: fldmgr.cxx:906
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:1717
#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:86
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:1803
const SwView & GetView() const
Definition: wrtsh.hxx:424
FUNC_TYPE const nType
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:103
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:80
static const char * FMT_AUTHOR_ARY[]
Definition: fldmgr.cxx:159
bool ChooseMacro(weld::Window *pDialogParent)
Definition: fldmgr.cxx:1786
static const char * FLD_STAT_ARY[]
Definition: fldmgr.cxx:200
SwWrtShell *const m_pSh
Definition: fldmgr.hxx:76
static sal_uInt8 nTablePos
Definition: basesh.cxx:125
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:82
#define SAL_N_ELEMENTS(arr)
const SwDocInfoSubType DI_CUSTOM
Definition: docufld.hxx:75
sal_uInt32 const m_nFormatId
Definition: fldmgr.hxx:75
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:900
const SfxItemPool & GetAttrPool() const
Definition: viewsh.hxx:614
void GetSubTypes(sal_uInt16 nId, std::vector< OUString > &rToFill)
Definition: fldmgr.cxx:574
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:109
size_t const nSubTypeLength
Definition: fldmgr.cxx:297
SwWrtShell * m_pWrtShell
Definition: fldmgr.hxx:101
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:73
void Push()
store a copy of the current cursor on the cursor stack
Definition: crsrsh.cxx:2143
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:107
OString stripStart(const OString &rIn, sal_Char c)
SwField * GetCurField()
Definition: fldmgr.cxx:433
std::vector< OUString > aDocInfoLst
Definition: shellres.hxx:63
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:256
sal_uInt16 GetCursorCnt(bool bAll=true) const
Get the number of elements in the ring of cursors.
Definition: crsrsh.cxx:2617
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:866
sal_uInt16 const m_nTypeId
Definition: fldmgr.hxx:71
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:64
OUString GetFieldText(ToxAuthorityField eField) const
Definition: authfld.cxx:545
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:74
SAL_DLLPRIVATE css::uno::Reference< css::text::XNumberingTypeInfo > const & GetNumberingInfo() const
Definition: fldmgr.cxx:1854
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:106
#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:259
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:78
Get reference.
Definition: reffld.hxx:63
OUString GetFormatStr(sal_uInt16 nTypeId, sal_uInt32 nFormatId) const
Definition: fldmgr.cxx:727
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:1726
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:79
void StartAllAction()
For all views of this document.
Definition: edws.cxx:85
sal_Unicode const m_cSeparator
Definition: fldmgr.hxx:77
sal_Int32 nPos
DefTokenId const nToken
SwFieldIds Which() const
Definition: fldbas.hxx:265
SvNumberFormatter * GetNumberFormatter()
Query NumberFormatter from document.
Definition: editsh.cxx:750
OUString m_aCurPar1
Definition: fldmgr.hxx:102
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:891
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