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