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