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