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 <unotools/useroptions.hxx>
69 
70 using namespace com::sun::star::uno;
71 using namespace com::sun::star::container;
72 using namespace com::sun::star::lang;
73 using namespace com::sun::star::beans;
74 using namespace com::sun::star::text;
75 using namespace com::sun::star::style;
76 using namespace com::sun::star::sdbc;
77 using namespace ::com::sun::star;
78 using namespace nsSwDocInfoSubType;
79 
80 // groups of fields
81 enum
82 {
85 
88 
91 
94 
97 
100 };
101 
102 enum
103 {
106 
108  GRP_WEB_FKT_END = GRP_WEB_FKT_BEGIN + 0, // the group is empty!
109 
110  GRP_WEB_REF_BEGIN = GRP_WEB_FKT_END + 6, // the group is empty!
112 
115 
116  GRP_WEB_DB_BEGIN = GRP_WEB_REG_END, // the group is empty!
118 
121 };
122 
123 const sal_uInt16 VF_COUNT = 1; // { 0 }
124 const sal_uInt16 VF_USR_COUNT = 2; // { 0, nsSwExtendedSubType::SUB_CMD }
125 const sal_uInt16 VF_DB_COUNT = 1; // { nsSwExtendedSubType::SUB_OWN_FMT }
126 
127 static const char* FLD_EU_ARY[] =
128 {
129  FLD_EU_COMPANY,
130  FLD_EU_GIVENNAME,
131  FLD_EU_SURNAME,
132  FLD_EU_INITIALS,
133  FLD_EU_STREET,
134  FLD_EU_COUNTRY,
135  FLD_EU_POSTCODE,
136  FLD_EU_TOWN,
137  FLD_EU_TITLE,
138  FLD_EU_POS,
139  FLD_EU_TELPERSONAL,
140  FLD_EU_TELWORK,
141  FLD_EU_FAX,
142  FLD_EU_EMAIL,
143  FLD_EU_REGION
144 };
145 
146 static const char* FMT_AUTHOR_ARY[] =
147 {
148  FMT_AUTHOR_NAME,
149  FMT_AUTHOR_SCUT
150 };
151 
152 static const char* FLD_DATE_ARY[] =
153 {
154  FLD_DATE_FIX,
155  FLD_DATE_STD,
156 };
157 
158 static const char* FLD_TIME_ARY[] =
159 {
160  FLD_TIME_FIX,
161  FLD_TIME_STD
162 };
163 
164 static const char* FMT_NUM_ARY[] =
165 {
166  FMT_NUM_ABC,
167  FMT_NUM_SABC,
168  FMT_NUM_ABC_N,
169  FMT_NUM_SABC_N,
170  FMT_NUM_ROMAN,
171  FMT_NUM_SROMAN,
172  FMT_NUM_ARABIC,
173  FMT_NUM_PAGEDESC,
174  FMT_NUM_PAGESPECIAL
175 };
176 
177 static const char* FMT_FF_ARY[] =
178 {
179  FMT_FF_NAME,
180  FMT_FF_PATHNAME,
181  FMT_FF_PATH,
182  FMT_FF_NAME_NOEXT,
183  FMT_FF_UI_NAME,
184  FMT_FF_UI_RANGE
185 };
186 
187 static const char* FLD_STAT_ARY[] =
188 {
189  FLD_STAT_PAGE,
190  FLD_STAT_PARA,
191  FLD_STAT_WORD,
192  FLD_STAT_CHAR,
193  FLD_STAT_TABLE,
194  FLD_STAT_GRF,
195  FLD_STAT_OBJ
196 };
197 
198 static const char* FMT_CHAPTER_ARY[] =
199 {
200  FMT_CHAPTER_NO,
201  FMT_CHAPTER_NAME,
202  FMT_CHAPTER_NAMENO,
203  FMT_CHAPTER_NO_NOSEPARATOR
204 };
205 
206 static const char* FLD_INPUT_ARY[] =
207 {
208  FLD_INPUT_TEXT
209 };
210 
211 static const char* FMT_MARK_ARY[] =
212 {
213  FMT_MARK_TEXT,
214  FMT_MARK_TABLE,
215  FMT_MARK_FRAME,
216  FMT_MARK_GRAFIC,
217  FMT_MARK_OLE
218 };
219 
220 static const char* FMT_REF_ARY[] =
221 {
222  FMT_REF_PAGE,
223  FMT_REF_CHAPTER,
224  FMT_REF_TEXT,
225  FMT_REF_UPDOWN,
226  FMT_REF_PAGE_PGDSC,
227  FMT_REF_ONLYNUMBER,
228  FMT_REF_ONLYCAPTION,
229  FMT_REF_ONLYSEQNO,
230  FMT_REF_NUMBER,
231  FMT_REF_NUMBER_NO_CONTEXT,
232  FMT_REF_NUMBER_FULL_CONTEXT
233 };
234 
235 static const char* FMT_REG_ARY[] =
236 {
237  FMT_REG_AUTHOR,
238  FMT_REG_TIME,
239  FMT_REG_DATE
240 };
241 
242 static const char* FMT_DBFLD_ARY[] =
243 {
244  FMT_DBFLD_DB,
245  FMT_DBFLD_SYS
246 };
247 
248 static const char* FMT_SETVAR_ARY[] =
249 {
250  FMT_SETVAR_SYS,
251  FMT_SETVAR_TEXT
252 };
253 
254 static const char* FMT_GETVAR_ARY[] =
255 {
256  FMT_GETVAR_TEXT,
257  FMT_GETVAR_NAME
258 };
259 
260 static const char* FMT_DDE_ARY[] =
261 {
262  FMT_DDE_NORMAL,
263  FMT_DDE_HOT
264 };
265 
266 static const char* FLD_PAGEREF_ARY[] =
267 {
268  FLD_PAGEREF_OFF,
269  FLD_PAGEREF_ON
270 };
271 
272 static const char* FMT_USERVAR_ARY[] =
273 {
274  FMT_USERVAR_TEXT,
275  FMT_USERVAR_CMD
276 };
277 
278 namespace {
279 
280 // field types and subtypes
281 struct SwFieldPack
282 {
283  SwFieldTypesEnum nTypeId;
284 
285  const char** pSubTypeResIds;
286  size_t nSubTypeLength;
287 
288  const char** pFormatResIds;
289  size_t nFormatLength;
290 };
291 
292 }
293 
294 // strings and formats
295 const SwFieldPack aSwFields[] =
296 {
297  // Document
298  { SwFieldTypesEnum::ExtendedUser, FLD_EU_ARY, SAL_N_ELEMENTS(FLD_EU_ARY), nullptr, 0 },
299  { SwFieldTypesEnum::Author, nullptr, 0, FMT_AUTHOR_ARY, SAL_N_ELEMENTS(FMT_AUTHOR_ARY) },
300  { SwFieldTypesEnum::Date, FLD_DATE_ARY, SAL_N_ELEMENTS(FLD_DATE_ARY), nullptr, 0 },
301  { SwFieldTypesEnum::Time, FLD_TIME_ARY, SAL_N_ELEMENTS(FLD_TIME_ARY), nullptr, 0 },
302  { SwFieldTypesEnum::PageNumber, nullptr, 0, FMT_NUM_ARY, SAL_N_ELEMENTS(FMT_NUM_ARY) -1 },
303  { SwFieldTypesEnum::NextPage, nullptr, 0, FMT_NUM_ARY, SAL_N_ELEMENTS(FMT_NUM_ARY) },
304  { SwFieldTypesEnum::PreviousPage, nullptr, 0, FMT_NUM_ARY, SAL_N_ELEMENTS(FMT_NUM_ARY) },
305  { SwFieldTypesEnum::Filename, nullptr, 0, FMT_FF_ARY, SAL_N_ELEMENTS(FMT_FF_ARY) },
307 
308  { SwFieldTypesEnum::Chapter, nullptr, 0, FMT_CHAPTER_ARY, SAL_N_ELEMENTS(FMT_CHAPTER_ARY) },
309  { SwFieldTypesEnum::TemplateName, nullptr, 0, FMT_FF_ARY, SAL_N_ELEMENTS(FMT_FF_ARY) },
310  { SwFieldTypesEnum::ParagraphSignature, nullptr, 0, nullptr, 0 },
311 
312  // Functions
313  { SwFieldTypesEnum::ConditionalText, nullptr, 0, nullptr, 0 },
314  { SwFieldTypesEnum::Dropdown, nullptr, 0, nullptr, 0 },
315  { SwFieldTypesEnum::Input, FLD_INPUT_ARY, SAL_N_ELEMENTS(FLD_INPUT_ARY), nullptr, 0 },
316  { SwFieldTypesEnum::Macro, nullptr, 0, nullptr, 0 },
317  { SwFieldTypesEnum::JumpEdit, nullptr, 0, FMT_MARK_ARY, SAL_N_ELEMENTS(FMT_MARK_ARY) },
318  { SwFieldTypesEnum::CombinedChars, nullptr, 0, nullptr, 0 },
319  { SwFieldTypesEnum::HiddenText, nullptr, 0, nullptr, 0 },
320  { SwFieldTypesEnum::HiddenParagraph, nullptr, 0, nullptr, 0 },
321 
322  // Cross-References
323  { SwFieldTypesEnum::SetRef, nullptr, 0, nullptr, 0 },
324  { SwFieldTypesEnum::GetRef, nullptr, 0, FMT_REF_ARY, SAL_N_ELEMENTS(FMT_REF_ARY) },
325 
326  // DocInformation
327  { SwFieldTypesEnum::DocumentInfo, nullptr, 0, FMT_REG_ARY, SAL_N_ELEMENTS(FMT_REG_ARY) },
328 
329  // Database
330  { SwFieldTypesEnum::Database, nullptr, 0, FMT_DBFLD_ARY, SAL_N_ELEMENTS(FMT_DBFLD_ARY) },
331  { SwFieldTypesEnum::DatabaseNextSet, nullptr, 0, nullptr, 0 },
332  { SwFieldTypesEnum::DatabaseNumberSet, nullptr, 0, nullptr, 0 },
333  { SwFieldTypesEnum::DatabaseSetNumber, nullptr, 0, FMT_NUM_ARY, SAL_N_ELEMENTS(FMT_NUM_ARY) - 2 },
334  { SwFieldTypesEnum::DatabaseName, nullptr, 0, nullptr, 0 },
335 
336  // Variables
337  { SwFieldTypesEnum::Set, nullptr, 0, FMT_SETVAR_ARY, SAL_N_ELEMENTS(FMT_SETVAR_ARY) },
338 
339  { SwFieldTypesEnum::Get, nullptr, 0, FMT_GETVAR_ARY, SAL_N_ELEMENTS(FMT_GETVAR_ARY) },
340  { SwFieldTypesEnum::DDE, nullptr, 0, FMT_DDE_ARY, SAL_N_ELEMENTS(FMT_DDE_ARY) },
341  { SwFieldTypesEnum::Formel, nullptr, 0, FMT_GETVAR_ARY, SAL_N_ELEMENTS(FMT_GETVAR_ARY) },
342  { SwFieldTypesEnum::Input, FLD_INPUT_ARY, SAL_N_ELEMENTS(FLD_INPUT_ARY), nullptr, 0 },
343  { SwFieldTypesEnum::Sequence, nullptr, 0, FMT_NUM_ARY, SAL_N_ELEMENTS(FMT_NUM_ARY) - 2 },
344  { SwFieldTypesEnum::SetRefPage, FLD_PAGEREF_ARY, SAL_N_ELEMENTS(FLD_PAGEREF_ARY),nullptr, 0 },
345  { SwFieldTypesEnum::GetRefPage, nullptr, 0, FMT_NUM_ARY, SAL_N_ELEMENTS(FMT_NUM_ARY) - 1 },
346  { SwFieldTypesEnum::User, nullptr, 0, FMT_USERVAR_ARY, SAL_N_ELEMENTS(FMT_USERVAR_ARY) }
347 };
348 
349 // access to the shell
351 {
352  SwView* pView = ::GetActiveView();
353  if ( nullptr != pView )
354  return pView->GetWrtShellPtr();
355  OSL_FAIL("no current shell found!");
356  return nullptr;
357 }
358 
359 static sal_uInt16 GetPackCount() { return SAL_N_ELEMENTS(aSwFields); }
360 
361 // FieldManager controls inserting and updating of fields
363  m_pWrtShell(pSh),
364  m_bEvalExp(true)
365 {
366  // determine current field if existing
367  GetCurField();
368 }
369 
371 {
372 }
373 
374 // organise RefMark by names
375 bool SwFieldMgr::CanInsertRefMark( const OUString& rStr )
376 {
377  bool bRet = false;
379  OSL_ENSURE(pSh, "no SwWrtShell found");
380  if(pSh)
381  {
382  sal_uInt16 nCnt = pSh->GetCursorCnt();
383 
384  // the last Cursor doesn't have to be a spanned selection
385  if( 1 < nCnt && !pSh->SwCursorShell::HasSelection() )
386  --nCnt;
387 
388  bRet = 2 > nCnt && nullptr == pSh->GetRefMark( rStr );
389  }
390  return bRet;
391 }
392 
393 // access over ResIds
394 void SwFieldMgr::RemoveFieldType(SwFieldIds nResId, const OUString& rName )
395 {
397  OSL_ENSURE(pSh, "no SwWrtShell found");
398  if( pSh )
399  pSh->RemoveFieldType(nResId, rName);
400 }
401 
403 {
405  OSL_ENSURE(pSh, "no SwWrtShell found");
406  return pSh ? pSh->GetFieldTypeCount() : 0;
407 }
408 
409 SwFieldType* SwFieldMgr::GetFieldType(SwFieldIds nResId, size_t nField) const
410 {
412  OSL_ENSURE(pSh, "no SwWrtShell found");
413  return pSh ? pSh->GetFieldType(nField, nResId) : nullptr;
414 }
415 
416 SwFieldType* SwFieldMgr::GetFieldType(SwFieldIds nResId, const OUString& rName) const
417 {
419  OSL_ENSURE(pSh, "no SwWrtShell found");
420  return pSh ? pSh->GetFieldType(nResId, rName) : nullptr;
421 }
422 
423 // determine current field
425 {
427  if ( pSh )
428  m_pCurField = pSh->GetCurField( true );
429  else
430  m_pCurField = nullptr;
431 
432  // initialise strings and format
433  m_aCurPar1.clear();
434  m_aCurPar2.clear();
435  m_sCurFrame.clear();
436  m_nCurFormat = 0;
437 
438  if(!m_pCurField)
439  return nullptr;
440 
441  // preprocess current values; determine parameter 1 and parameter 2
442  // as well as the format
443  const SwFieldTypesEnum nTypeId = m_pCurField->GetTypeId();
444 
448 
449  switch( nTypeId )
450  {
456  m_nCurFormat -= 2;
457  break;
458  default: break;
459  }
460  return m_pCurField;
461 }
462 
463 // provide group range
464 const SwFieldGroupRgn& SwFieldMgr::GetGroupRange(bool bHtmlMode, sal_uInt16 nGrpId)
465 {
466  static SwFieldGroupRgn const aRanges[] =
467  {
468  { /* Document */ GRP_DOC_BEGIN, GRP_DOC_END },
469  { /* Functions */ GRP_FKT_BEGIN, GRP_FKT_END },
470  { /* Cross-Refs */ GRP_REF_BEGIN, GRP_REF_END },
471  { /* DocInfos */ GRP_REG_BEGIN, GRP_REG_END },
472  { /* Database */ GRP_DB_BEGIN, GRP_DB_END },
473  { /* User */ GRP_VAR_BEGIN, GRP_VAR_END }
474  };
475  static SwFieldGroupRgn const aWebRanges[] =
476  {
477  { /* Document */ GRP_WEB_DOC_BEGIN, GRP_WEB_DOC_END },
478  { /* Functions */ GRP_WEB_FKT_BEGIN, GRP_WEB_FKT_END },
479  { /* Cross-Refs */ GRP_WEB_REF_BEGIN, GRP_WEB_REF_END },
480  { /* DocInfos */ GRP_WEB_REG_BEGIN, GRP_WEB_REG_END },
481  { /* Database */ GRP_WEB_DB_BEGIN, GRP_WEB_DB_END },
482  { /* User */ GRP_WEB_VAR_BEGIN, GRP_WEB_VAR_END }
483  };
484 
485  if (bHtmlMode)
486  return aWebRanges[nGrpId];
487  else
488  return aRanges[nGrpId];
489 }
490 
491 // determine GroupId
492 sal_uInt16 SwFieldMgr::GetGroup(SwFieldTypesEnum nTypeId, sal_uInt16 nSubType)
493 {
494  if (nTypeId == SwFieldTypesEnum::SetInput)
495  nTypeId = SwFieldTypesEnum::Set;
496 
497  if (nTypeId == SwFieldTypesEnum::Input && (nSubType & INP_USR))
498  nTypeId = SwFieldTypesEnum::User;
499 
500  if (nTypeId == SwFieldTypesEnum::FixedDate)
501  nTypeId = SwFieldTypesEnum::Date;
502 
503  if (nTypeId == SwFieldTypesEnum::FixedTime)
504  nTypeId = SwFieldTypesEnum::Time;
505 
506  for (sal_uInt16 i = GRP_DOC; i <= GRP_VAR; i++)
507  {
508  const SwFieldGroupRgn& rRange = GetGroupRange(false/*bHtmlMode*/, i);
509  for (sal_uInt16 nPos = rRange.nStart; nPos < rRange.nEnd; nPos++)
510  {
511  if (aSwFields[nPos].nTypeId == nTypeId)
512  return i;
513  }
514  }
515  return USHRT_MAX;
516 }
517 
518 // determine names to TypeId
519 // ACCESS over TYP_...
521 {
522  OSL_ENSURE(nPos < ::GetPackCount(), "forbidden Pos");
523  return aSwFields[ nPos ].nTypeId;
524 }
525 
526 OUString SwFieldMgr::GetTypeStr(sal_uInt16 nPos)
527 {
528  OSL_ENSURE(nPos < ::GetPackCount(), "forbidden TypeId");
529 
530  SwFieldTypesEnum nFieldWh = aSwFields[ nPos ].nTypeId;
531 
532  // special treatment for date/time fields (without var/fix)
533  if( SwFieldTypesEnum::Date == nFieldWh )
534  {
535  static OUString g_aDate( SwResId( STR_DATEFLD ) );
536  return g_aDate;
537  }
538  if( SwFieldTypesEnum::Time == nFieldWh )
539  {
540  static OUString g_aTime( SwResId( STR_TIMEFLD ) );
541  return g_aTime;
542  }
543 
544  return SwFieldType::GetTypeStr( nFieldWh );
545 }
546 
547 // determine Pos in the list
549 {
550  switch( nTypeId )
551  {
554  case SwFieldTypesEnum::SetInput: nTypeId = SwFieldTypesEnum::Set; break;
556  default: break;
557  }
558 
559  for(sal_uInt16 i = 0; i < GetPackCount(); i++)
560  if(aSwFields[i].nTypeId == nTypeId)
561  return i;
562 
563  return USHRT_MAX;
564 }
565 
566 // localise subtypes of a field
567 void SwFieldMgr::GetSubTypes(SwFieldTypesEnum nTypeId, std::vector<OUString>& rToFill)
568 {
570  OSL_ENSURE(pSh, "no SwWrtShell found");
571  if(!pSh)
572  return;
573 
574  const sal_uInt16 nPos = GetPos(nTypeId);
575 
576  switch(nTypeId)
577  {
580  {
581  // references are no fields
582  pSh->GetRefMarks( &rToFill );
583  break;
584  }
586  {
587  break;
588  }
590  {
591  rToFill.push_back(SwResId(aSwFields[nPos].pSubTypeResIds[0]));
592  [[fallthrough]]; // move on at generic types
593  }
600  {
601 
602  const size_t nCount = pSh->GetFieldTypeCount();
603  for(size_t i = 0; i < nCount; ++i)
604  {
605  SwFieldType* pFieldType = pSh->GetFieldType( i );
606  const SwFieldIds nWhich = pFieldType->Which();
607 
608  if((nTypeId == SwFieldTypesEnum::DDE && pFieldType->Which() == SwFieldIds::Dde) ||
609 
610  (nTypeId == SwFieldTypesEnum::User && nWhich == SwFieldIds::User) ||
611 
612  (nTypeId == SwFieldTypesEnum::Get && nWhich == SwFieldIds::SetExp &&
613  !(static_cast<SwSetExpFieldType*>(pFieldType)->GetType() & nsSwGetSetExpType::GSE_SEQ)) ||
614 
615  (nTypeId == SwFieldTypesEnum::Set && nWhich == SwFieldIds::SetExp &&
616  !(static_cast<SwSetExpFieldType*>(pFieldType)->GetType() & nsSwGetSetExpType::GSE_SEQ)) ||
617 
618  (nTypeId == SwFieldTypesEnum::Sequence && nWhich == SwFieldIds::SetExp &&
619  (static_cast<SwSetExpFieldType*>(pFieldType)->GetType() & nsSwGetSetExpType::GSE_SEQ)) ||
620 
621  ((nTypeId == SwFieldTypesEnum::Input || nTypeId == SwFieldTypesEnum::Formel) &&
622  (nWhich == SwFieldIds::User ||
623  (nWhich == SwFieldIds::SetExp &&
624  !(static_cast<SwSetExpFieldType*>(pFieldType)->GetType() & nsSwGetSetExpType::GSE_SEQ))) ) )
625  {
626  rToFill.push_back(pFieldType->GetName());
627  }
628  }
629  break;
630  }
635  break;
636 
637  default:
638  {
639  // static SubTypes
640  if(nPos != USHRT_MAX)
641  {
642  sal_uInt16 nCount;
643  if (nTypeId == SwFieldTypesEnum::DocumentInfo)
644  nCount = DI_SUBTYPE_END - DI_SUBTYPE_BEGIN;
645  else
646  nCount = aSwFields[nPos].nSubTypeLength;
647 
648  for(sal_uInt16 i = 0; i < nCount; ++i)
649  {
650  OUString sNew;
651  if (nTypeId == SwFieldTypesEnum::DocumentInfo)
652  {
653  if ( i == DI_CUSTOM )
654  sNew = SwResId(STR_CUSTOM_FIELD);
655  else
657  }
658  else
659  sNew = SwResId(aSwFields[nPos].pSubTypeResIds[i]);
660 
661  rToFill.push_back(sNew);
662  }
663  }
664  }
665  }
666 }
667 
668 // determine format
669 // ACCESS over TYP_...
670 sal_uInt16 SwFieldMgr::GetFormatCount(SwFieldTypesEnum nTypeId, bool bHtmlMode) const
671 {
672  assert(nTypeId < SwFieldTypesEnum::LAST && "forbidden TypeId");
673  {
674  const sal_uInt16 nPos = GetPos(nTypeId);
675 
676  if (nPos == USHRT_MAX || (bHtmlMode && nTypeId == SwFieldTypesEnum::Set))
677  return 0;
678 
679  sal_uInt16 nCount = aSwFields[nPos].nFormatLength;
680 
681  if (nTypeId == SwFieldTypesEnum::Filename)
682  nCount -= 2; // no range or template
683 
684  const char** pStart = aSwFields[nPos].pFormatResIds;
685  if (!pStart)
686  return nCount;
687 
688  if (strcmp(*pStart, FMT_GETVAR_ARY[0]) == 0 || strcmp(*pStart, FMT_SETVAR_ARY[0]) == 0)
689  return VF_COUNT;
690  else if (strcmp(*pStart, FMT_USERVAR_ARY[0]) == 0)
691  return VF_USR_COUNT;
692  else if (strcmp(*pStart, FMT_DBFLD_ARY[0]) == 0)
693  return VF_DB_COUNT;
694  else if (strcmp(*pStart, FMT_NUM_ARY[0]) == 0)
695  {
697  if(m_xNumberingInfo.is())
698  {
699  Sequence<sal_Int16> aTypes = m_xNumberingInfo->getSupportedNumberingTypes();
700  // #i28073# it's not necessarily a sorted sequence
701  //skip all values below or equal to CHARS_LOWER_LETTER_N
702  nCount += std::count_if(aTypes.begin(), aTypes.end(),
703  [](sal_Int16 nCurrent) { return nCurrent > NumberingType::CHARS_LOWER_LETTER_N; });
704  }
705  return nCount;
706  }
707 
708  return nCount;
709  }
710 }
711 
712 // determine FormatString to a type
713 OUString SwFieldMgr::GetFormatStr(SwFieldTypesEnum nTypeId, sal_uInt32 nFormatId) const
714 {
715  assert(nTypeId < SwFieldTypesEnum::LAST && "forbidden TypeId");
716  const sal_uInt16 nPos = GetPos(nTypeId);
717 
718  if (nPos == USHRT_MAX)
719  return OUString();
720 
721  const char** pStart = aSwFields[nPos].pFormatResIds;
722  if (!pStart)
723  return OUString();
724 
725  if (SwFieldTypesEnum::Author == nTypeId || SwFieldTypesEnum::Filename == nTypeId)
726  nFormatId &= ~static_cast<sal_uInt32>(FF_FIXED); // mask out Fixed-Flag
727 
728  if (nFormatId < aSwFields[nPos].nFormatLength)
729  return SwResId(pStart[nFormatId]);
730 
731  OUString aRet;
732  if (*pStart == FMT_NUM_ARY[0])
733  {
734  if (m_xNumberingInfo.is())
735  {
736  Sequence<sal_Int16> aTypes = m_xNumberingInfo->getSupportedNumberingTypes();
737  sal_Int32 nOffset = aSwFields[nPos].nFormatLength;
738  sal_uInt32 nValidEntry = 0;
739  for (const sal_Int16 nCurrent : aTypes)
740  {
741  if(nCurrent > NumberingType::CHARS_LOWER_LETTER_N &&
742  (nCurrent != (NumberingType::BITMAP | LINK_TOKEN)))
743  {
744  if (nValidEntry == nFormatId - nOffset)
745  {
746  sal_uInt32 n = SvxNumberingTypeTable::FindIndex(nCurrent);
747  if (n != RESARRAY_INDEX_NOTFOUND)
748  {
750  }
751  else
752  {
753  aRet = m_xNumberingInfo->getNumberingIdentifier( nCurrent );
754  }
755  break;
756  }
757  ++nValidEntry;
758  }
759  }
760  }
761  }
762 
763  return aRet;
764 }
765 
766 // determine FormatId from Pseudo-ID
767 sal_uInt16 SwFieldMgr::GetFormatId(SwFieldTypesEnum nTypeId, sal_uInt32 nFormatId) const
768 {
769  sal_uInt16 nId = static_cast<sal_uInt16>(nFormatId);
770  switch( nTypeId )
771  {
773  {
774  const OString sId(aSwFields[GetPos(nTypeId)].pFormatResIds[nFormatId]);
775  if (sId == FMT_REG_AUTHOR)
776  nId = DI_SUB_AUTHOR;
777  else if (sId == FMT_REG_TIME)
778  nId = DI_SUB_TIME;
779  else if (sId == FMT_REG_DATE)
780  nId = DI_SUB_DATE;
781  break;
782  }
790  {
791  sal_uInt16 nPos = GetPos(nTypeId);
792  if (nFormatId < aSwFields[nPos].nFormatLength)
793  {
794  const OString sId(aSwFields[nPos].pFormatResIds[nFormatId]);
795  if (sId == FMT_NUM_ABC)
797  else if (sId == FMT_NUM_SABC)
799  else if (sId == FMT_NUM_ROMAN)
800  nId = SVX_NUM_ROMAN_UPPER;
801  else if (sId == FMT_NUM_SROMAN)
802  nId = SVX_NUM_ROMAN_LOWER;
803  else if (sId == FMT_NUM_ARABIC)
804  nId = SVX_NUM_ARABIC;
805  else if (sId == FMT_NUM_PAGEDESC)
806  nId = SVX_NUM_PAGEDESC;
807  else if (sId == FMT_NUM_PAGESPECIAL)
808  nId = SVX_NUM_CHAR_SPECIAL;
809  else if (sId == FMT_NUM_ABC_N)
811  else if (sId == FMT_NUM_SABC_N)
813  }
814  else if (m_xNumberingInfo.is())
815  {
816  Sequence<sal_Int16> aTypes = m_xNumberingInfo->getSupportedNumberingTypes();
817  sal_Int32 nOffset = aSwFields[nPos].nFormatLength;
818  sal_Int32 nValidEntry = 0;
819  for (const sal_Int16 nCurrent : aTypes)
820  {
821  if (nCurrent > NumberingType::CHARS_LOWER_LETTER_N)
822  {
823  if (nValidEntry == static_cast<sal_Int32>(nFormatId) - nOffset)
824  {
825  nId = nCurrent;
826  break;
827  }
828  ++nValidEntry;
829  }
830  }
831  }
832  break;
833  }
835  {
836  const OString sId(aSwFields[GetPos(nTypeId)].pFormatResIds[nFormatId]);
837  if (sId == FMT_DDE_NORMAL)
838  nId = static_cast<sal_uInt16>(SfxLinkUpdateMode::ONCALL);
839  else if (sId == FMT_DDE_HOT)
840  nId = static_cast<sal_uInt16>(SfxLinkUpdateMode::ALWAYS);
841  break;
842  }
843  default: break;
844  }
845  return nId;
846 }
847 
848 // Traveling
849 bool SwFieldMgr::GoNextPrev( bool bNext, SwFieldType* pTyp )
850 {
852  if(!pSh)
853  return false;
854 
855  if( !pTyp && m_pCurField )
856  {
857  const SwFieldTypesEnum nTypeId = m_pCurField->GetTypeId();
858  if( SwFieldTypesEnum::SetInput == nTypeId || SwFieldTypesEnum::UserInput == nTypeId )
859  pTyp = pSh->GetFieldType( 0, SwFieldIds::Input );
860  else
861  pTyp = m_pCurField->GetTyp();
862  }
863 
864  if (pTyp && pTyp->Which() == SwFieldIds::Database)
865  {
866  // for fieldcommand-edit (hop to all DB fields)
867  return pSh->MoveFieldType( nullptr, bNext, SwFieldIds::Database );
868  }
869 
870  return pTyp && pSh->MoveFieldType(pTyp, bNext);
871 }
872 
873 // insert field types
875 {
877  OSL_ENSURE(pSh, "no SwWrtShell found");
878  if(pSh)
879  pSh->InsertFieldType(rType);
880 }
881 
882 // determine current TypeId
884 {
886 }
887 
888 // Over string insert field or update
890  const SwInsertField_Data& rData)
891 {
892  std::unique_ptr<SwField> pField;
893  bool bExp = false;
894  bool bTable = false;
895  bool bPageVar = false;
896  sal_uInt32 nFormatId = rData.m_nFormatId;
897  sal_uInt16 nSubType = rData.m_nSubType;
898  sal_Unicode cSeparator = rData.m_cSeparator;
899  SwWrtShell* pCurShell = rData.m_pSh;
900  if(!pCurShell)
901  pCurShell = m_pWrtShell ? m_pWrtShell : ::lcl_GetShell();
902  OSL_ENSURE(pCurShell, "no SwWrtShell found");
903  if(!pCurShell)
904  return false;
905 
906  switch (rData.m_nTypeId)
907  { // ATTENTION this field is inserted by a separate dialog
909  {
910  SvtUserOptions aUserOpt;
911  SwPostItFieldType* pType = static_cast<SwPostItFieldType*>(pCurShell->GetFieldType(0, SwFieldIds::Postit));
912  pField.reset(
913  new SwPostItField(
914  pType,
915  rData.m_sPar1, // author
916  rData.m_sPar2, // content
917  aUserOpt.GetID(), // author's initials
918  OUString(), // name
920  }
921  break;
923  {
924  SwScriptFieldType* pType =
925  static_cast<SwScriptFieldType*>(pCurShell->GetFieldType(0, SwFieldIds::Script));
926  pField.reset(new SwScriptField(pType, rData.m_sPar1, rData.m_sPar2, static_cast<bool>(nFormatId)));
927  break;
928  }
929 
931  {
932  SwCombinedCharFieldType* pType = static_cast<SwCombinedCharFieldType*>(
933  pCurShell->GetFieldType( 0, SwFieldIds::CombinedChars ));
934  pField.reset(new SwCombinedCharField( pType, rData.m_sPar1 ));
935  }
936  break;
937 
939  {
940  SwAuthorityFieldType* pType =
942  if (!pType)
943  {
944  SwAuthorityFieldType const type(pCurShell->GetDoc());
945  pType = static_cast<SwAuthorityFieldType*>(
946  pCurShell->InsertFieldType(type));
947  }
948  pField.reset(new SwAuthorityField(pType, rData.m_sPar1));
949  }
950  break;
951 
954  {
955  sal_uInt16 nSub = static_cast< sal_uInt16 >(rData.m_nTypeId == SwFieldTypesEnum::Date ? DATEFLD : TIMEFLD);
956  nSub |= nSubType == DATE_VAR ? 0 : FIXEDFLD;
957 
958  SwDateTimeFieldType* pTyp =
959  static_cast<SwDateTimeFieldType*>( pCurShell->GetFieldType(0, SwFieldIds::DateTime) );
960  pField.reset(new SwDateTimeField(pTyp, nSub, nFormatId));
961  pField->SetPar2(rData.m_sPar2);
962  break;
963  }
964 
966  {
967  SwFileNameFieldType* pTyp =
968  static_cast<SwFileNameFieldType*>( pCurShell->GetFieldType(0, SwFieldIds::Filename) );
969  pField.reset(new SwFileNameField(pTyp, nFormatId));
970  break;
971  }
972 
974  {
975  SwTemplNameFieldType* pTyp =
976  static_cast<SwTemplNameFieldType*>( pCurShell->GetFieldType(0, SwFieldIds::TemplateName) );
977  pField.reset(new SwTemplNameField(pTyp, nFormatId));
978  break;
979  }
980 
982  {
983  sal_uInt16 nByte = static_cast<sal_uInt16>(rData.m_sPar2.toInt32());
984  SwChapterFieldType* pTyp =
985  static_cast<SwChapterFieldType*>( pCurShell->GetFieldType(0, SwFieldIds::Chapter) );
986  pField.reset(new SwChapterField(pTyp, nFormatId));
987  nByte = std::max(sal_uInt16(1), nByte);
988  nByte = std::min(nByte, sal_uInt16(MAXLEVEL));
989  nByte -= 1;
990  static_cast<SwChapterField*>(pField.get())->SetLevel(static_cast<sal_uInt8>(nByte));
991  break;
992  }
993 
997  {
998  short nOff = static_cast<short>(rData.m_sPar2.toInt32());
999 
1001  {
1002  if( SVX_NUM_CHAR_SPECIAL == nFormatId )
1003  nOff = 1;
1004  else
1005  nOff += 1;
1006  nSubType = PG_NEXT;
1007  }
1008  else if(rData.m_nTypeId == SwFieldTypesEnum::PreviousPage)
1009  {
1010  if( SVX_NUM_CHAR_SPECIAL == nFormatId )
1011  nOff = -1;
1012  else
1013  nOff -= 1;
1014  nSubType = PG_PREV;
1015  }
1016  else
1017  nSubType = PG_RANDOM;
1018 
1019  SwPageNumberFieldType* pTyp =
1020  static_cast<SwPageNumberFieldType*>( pCurShell->GetFieldType(0, SwFieldIds::PageNumber) );
1021  pField.reset(new SwPageNumberField(pTyp, nSubType, nFormatId, nOff));
1022 
1023  if( SVX_NUM_CHAR_SPECIAL == nFormatId &&
1024  ( PG_PREV == nSubType || PG_NEXT == nSubType ) )
1025  static_cast<SwPageNumberField*>(pField.get())->SetUserString( rData.m_sPar2 );
1026  break;
1027  }
1028 
1030  {
1031  SwDocStatFieldType* pTyp =
1032  static_cast<SwDocStatFieldType*>( pCurShell->GetFieldType(0, SwFieldIds::DocStat) );
1033  pField.reset(new SwDocStatField(pTyp, nSubType, nFormatId));
1034  break;
1035  }
1036 
1038  {
1039  SwAuthorFieldType* pTyp =
1040  static_cast<SwAuthorFieldType*>( pCurShell->GetFieldType(0, SwFieldIds::Author) );
1041  pField.reset(new SwAuthorField(pTyp, nFormatId));
1042  break;
1043  }
1044 
1047  {
1048  SwHiddenTextFieldType* pTyp =
1049  static_cast<SwHiddenTextFieldType*>( pCurShell->GetFieldType(0, SwFieldIds::HiddenText) );
1050  pField.reset(new SwHiddenTextField(pTyp, true, rData.m_sPar1, rData.m_sPar2, false, rData.m_nTypeId));
1051  bExp = true;
1052  break;
1053  }
1054 
1056  {
1057  SwHiddenParaFieldType* pTyp =
1058  static_cast<SwHiddenParaFieldType*>( pCurShell->GetFieldType(0, SwFieldIds::HiddenPara) );
1059  pField.reset(new SwHiddenParaField(pTyp, rData.m_sPar1));
1060  bExp = true;
1061  break;
1062  }
1063 
1065  {
1066  if( !rData.m_sPar1.isEmpty() && CanInsertRefMark( rData.m_sPar1 ) )
1067  {
1068  pCurShell->SetAttrItem( SwFormatRefMark( rData.m_sPar1 ) );
1069  return true;
1070  }
1071  return false;
1072  }
1073 
1075  {
1076  SwGetRefFieldType* pTyp =
1077  static_cast<SwGetRefFieldType*>( pCurShell->GetFieldType(0, SwFieldIds::GetRef) );
1078  sal_uInt16 nSeqNo = static_cast<sal_uInt16>(rData.m_sPar2.toInt32());
1079  OUString sReferenceLanguage;
1080  // handle language-variant formats
1081  if (nFormatId >= SAL_N_ELEMENTS(FMT_REF_ARY))
1082  {
1084  if (nLang == LANGUAGE_HUNGARIAN)
1085  {
1086  if (nFormatId >= SAL_N_ELEMENTS(FMT_REF_ARY) * 2)
1087  sReferenceLanguage = "Hu";
1088  else
1089  sReferenceLanguage = "hu";
1090  }
1091  nFormatId %= SAL_N_ELEMENTS(FMT_REF_ARY);
1092  }
1093  pField.reset(new SwGetRefField(pTyp, rData.m_sPar1, sReferenceLanguage, nSubType, nSeqNo, nFormatId));
1094  bExp = true;
1095  break;
1096  }
1097 
1098  case SwFieldTypesEnum::DDE:
1099  {
1100  //JP 28.08.95: DDE-Topics/-Items can have blanks in their names!
1101  // That's not yet considered here.
1102  sal_Int32 nIndex = 0;
1103  OUString sCmd = rData.m_sPar2.replaceFirst(" ", OUStringChar(sfx2::cTokenSeparator), &nIndex);
1104  if (nIndex>=0 && ++nIndex<sCmd.getLength())
1105  {
1106  sCmd = sCmd.replaceFirst(" ", OUStringChar(sfx2::cTokenSeparator), &nIndex);
1107  }
1108 
1109  SwDDEFieldType aType( rData.m_sPar1, sCmd, static_cast<SfxLinkUpdateMode>(nFormatId) );
1110  SwDDEFieldType* pTyp = static_cast<SwDDEFieldType*>( pCurShell->InsertFieldType( aType ) );
1111  pField.reset(new SwDDEField( pTyp ));
1112  break;
1113  }
1114 
1116  {
1117  SwMacroFieldType* pTyp =
1118  static_cast<SwMacroFieldType*>(pCurShell->GetFieldType(0, SwFieldIds::Macro));
1119 
1120  pField.reset(new SwMacroField(pTyp, rData.m_sPar1, rData.m_sPar2));
1121 
1122  break;
1123  }
1124 
1126  {
1127  SwFormatINetFormat aFormat( rData.m_sPar1, m_sCurFrame );
1128  return pCurShell->InsertURL( aFormat, rData.m_sPar2 );
1129  }
1130 
1132  {
1133  SwJumpEditFieldType* pTyp =
1134  static_cast<SwJumpEditFieldType*>(pCurShell->GetFieldType(0, SwFieldIds::JumpEdit));
1135 
1136  pField.reset(new SwJumpEditField(pTyp, nFormatId, rData.m_sPar1, rData.m_sPar2));
1137  break;
1138  }
1139 
1141  {
1142  SwDocInfoFieldType* pTyp = static_cast<SwDocInfoFieldType*>( pCurShell->GetFieldType(
1143  0, SwFieldIds::DocInfo ) );
1144  pField.reset(new SwDocInfoField(pTyp, nSubType, rData.m_sPar1, nFormatId));
1145  break;
1146  }
1147 
1149  {
1150  SwExtUserFieldType* pTyp = static_cast<SwExtUserFieldType*>( pCurShell->GetFieldType(
1151  0, SwFieldIds::ExtUser) );
1152  pField.reset(new SwExtUserField(pTyp, nSubType, nFormatId));
1153  break;
1154  }
1155 
1157  {
1158 #if HAVE_FEATURE_DBCONNECTIVITY
1159  SwDBData aDBData;
1160  OUString sPar1;
1161 
1162  if (rData.m_sPar1.indexOf(DB_DELIM)<0)
1163  {
1164  aDBData = pCurShell->GetDBData();
1165  sPar1 = rData.m_sPar1;
1166  }
1167  else
1168  {
1169  sal_Int32 nIdx{ 0 };
1170  aDBData.sDataSource = rData.m_sPar1.getToken(0, DB_DELIM, nIdx);
1171  aDBData.sCommand = rData.m_sPar1.getToken(0, DB_DELIM, nIdx);
1172  aDBData.nCommandType = rData.m_sPar1.getToken(0, DB_DELIM, nIdx).toInt32();
1173  sPar1 = rData.m_sPar1.getToken(0, DB_DELIM, nIdx);
1174  }
1175 
1176  if(!aDBData.sDataSource.isEmpty() && pCurShell->GetDBData() != aDBData)
1177  pCurShell->ChgDBData(aDBData);
1178 
1179  SwDBFieldType* pTyp = static_cast<SwDBFieldType*>(pCurShell->InsertFieldType(
1180  SwDBFieldType(pCurShell->GetDoc(), sPar1, aDBData) ) );
1181  pField.reset(new SwDBField(pTyp));
1182  pField->SetSubType(nSubType);
1183 
1184  if( !(nSubType & nsSwExtendedSubType::SUB_OWN_FMT) ) // determine database format
1185  {
1186  Reference< XDataSource> xSource;
1187  rData.m_aDBDataSource >>= xSource;
1188  Reference<XConnection> xConnection;
1189  rData.m_aDBConnection >>= xConnection;
1191  rData.m_aDBColumn >>= xColumn;
1192  if(xColumn.is())
1193  {
1194  nFormatId = SwDBManager::GetColumnFormat(xSource, xConnection, xColumn,
1195  pCurShell->GetNumberFormatter(), GetCurrLanguage() );
1196  }
1197  else
1198  nFormatId = pCurShell->GetDBManager()->GetColumnFormat(
1199  aDBData.sDataSource, aDBData.sCommand, sPar1,
1200  pCurShell->GetNumberFormatter(), GetCurrLanguage() );
1201  }
1202  pField->ChangeFormat( nFormatId );
1203 
1204  bExp = true;
1205 #endif
1206  break;
1207  }
1208 
1213  {
1214 #if HAVE_FEATURE_DBCONNECTIVITY
1215  SwDBData aDBData;
1216 
1217  // extract DBName from rData.m_sPar1. Format: DBName.TableName.CommandType.ExpStrg
1218  sal_Int32 nTablePos = rData.m_sPar1.indexOf(DB_DELIM);
1219  sal_Int32 nCmdTypePos = -1;
1220  sal_Int32 nExpPos = -1;
1221 
1222  if (nTablePos>=0)
1223  {
1224  aDBData.sDataSource = rData.m_sPar1.copy(0, nTablePos++);
1225  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,
1495  false, (INP_VAR == (nSubType & 0xff)) ? 1 : 2, false );
1496  pCurShell->StartInputFieldDlg(pField.get(), false, true, rData.m_pParent);
1497 
1499  }
1500 
1501  if(bExp && m_bEvalExp)
1502  pCurShell->UpdateExpFields(true);
1503 
1504  if(bTable)
1505  {
1506  pCurShell->Left(CRSR_SKIP_CHARS, false, 1, false );
1507  pCurShell->UpdateOneField(*pField);
1508  pCurShell->Right(CRSR_SKIP_CHARS, false, 1, false );
1509  }
1510  else if( bPageVar )
1511  static_cast<SwRefPageGetFieldType*>(pCurShell->GetFieldType( 0, SwFieldIds::RefPageGet ))->UpdateFields();
1512  else if( SwFieldTypesEnum::GetRef == rData.m_nTypeId )
1513  pField->GetTyp()->ModifyNotification( nullptr, nullptr );
1514 
1515  // delete temporary field
1516  pField.reset();
1517 
1518  pCurShell->EndAllAction();
1519  return true;
1520 }
1521 
1522 // fields update
1523 void SwFieldMgr::UpdateCurField(sal_uInt32 nFormat,
1524  const OUString& rPar1,
1525  const OUString& rPar2,
1526  std::unique_ptr<SwField> pTmpField)
1527 {
1528  // change format
1529  OSL_ENSURE(m_pCurField, "no field at CursorPos");
1530 
1531  if (!pTmpField)
1532  pTmpField = m_pCurField->CopyField();
1533 
1534  SwFieldType* pType = pTmpField->GetTyp();
1535  const SwFieldTypesEnum nTypeId = pTmpField->GetTypeId();
1536 
1538  OSL_ENSURE(pSh, "no SwWrtShell found");
1539  if(!pSh)
1540  return;
1541  pSh->StartAllAction();
1542 
1543  bool bSetPar2 = true;
1544  bool bSetPar1 = true;
1545  OUString sPar2( rPar2 );
1546 
1547  // Order to Format
1548  switch( nTypeId )
1549  {
1550  case SwFieldTypesEnum::DDE:
1551  {
1552  // DDE-Topics/-Items can have blanks in their names!
1553  // That's not yet considered here!
1554  sal_Int32 nIndex = 0;
1555  sPar2 = sPar2.replaceFirst(" ", OUStringChar(sfx2::cTokenSeparator), &nIndex );
1556  if (nIndex>=0 && ++nIndex<sPar2.getLength())
1557  {
1558  sPar2 = sPar2.replaceFirst(" ", OUStringChar(sfx2::cTokenSeparator), &nIndex);
1559  }
1560  break;
1561  }
1562 
1564  {
1565  sal_uInt16 nByte = static_cast<sal_uInt16>(rPar2.toInt32());
1566  nByte = std::max(sal_uInt16(1), nByte);
1567  nByte = std::min(nByte, sal_uInt16(MAXLEVEL));
1568  nByte -= 1;
1569  static_cast<SwChapterField*>(pTmpField.get())->SetLevel(static_cast<sal_uInt8>(nByte));
1570  bSetPar2 = false;
1571  break;
1572  }
1573 
1575  static_cast<SwScriptField*>(pTmpField.get())->SetCodeURL(static_cast<bool>(nFormat));
1576  break;
1577 
1579  if( SVX_NUM_CHAR_SPECIAL == nFormat )
1580  {
1581  static_cast<SwPageNumberField*>(m_pCurField)->SetUserString( sPar2 );
1582  sPar2 = "1";
1583  }
1584  else
1585  {
1586  if( nFormat + 2 == SVX_NUM_PAGEDESC )
1587  nFormat = SVX_NUM_PAGEDESC;
1588  short nOff = static_cast<short>(sPar2.toInt32());
1589  nOff += 1;
1590  sPar2 = OUString::number(nOff);
1591  }
1592  break;
1593 
1595  if( SVX_NUM_CHAR_SPECIAL == nFormat )
1596  {
1597  static_cast<SwPageNumberField*>(m_pCurField)->SetUserString( sPar2 );
1598  sPar2 = "-1";
1599  }
1600  else
1601  {
1602  if( nFormat + 2 == SVX_NUM_PAGEDESC )
1603  nFormat = SVX_NUM_PAGEDESC;
1604  short nOff = static_cast<short>(sPar2.toInt32());
1605  nOff -= 1;
1606  sPar2 = OUString::number(nOff);
1607  }
1608  break;
1609 
1612  if( nFormat + 2 == SVX_NUM_PAGEDESC )
1613  nFormat = SVX_NUM_PAGEDESC;
1614  break;
1615 
1617  {
1618  bSetPar2 = false;
1619  static_cast<SwGetRefField*>(pTmpField.get())->SetSubType( static_cast<sal_uInt16>(rPar2.toInt32()) );
1620  const sal_Int32 nPos = rPar2.indexOf( '|' );
1621  if( nPos>=0 )
1622  static_cast<SwGetRefField*>(pTmpField.get())->SetSeqNo( static_cast<sal_uInt16>(rPar2.copy( nPos + 1 ).toInt32()));
1623  }
1624  break;
1626  {
1627  sal_Int32 nTokenCount = comphelper::string::getTokenCount(sPar2, DB_DELIM);
1628  Sequence<OUString> aEntries(nTokenCount);
1629  OUString* pArray = aEntries.getArray();
1630  for(sal_Int32 nToken = 0, nIdx = 0; nToken < nTokenCount; nToken++)
1631  pArray[nToken] = sPar2.getToken(0, DB_DELIM, nIdx);
1632  static_cast<SwDropDownField*>(pTmpField.get())->SetItems(aEntries);
1633  static_cast<SwDropDownField*>(pTmpField.get())->SetName(rPar1);
1634  bSetPar1 = bSetPar2 = false;
1635  }
1636  break;
1638  {
1639  //#i99069# changes to a bibliography field should change the field type
1640  SwAuthorityField* pAuthorityField = static_cast<SwAuthorityField*>(pTmpField.get());
1641  SwAuthorityFieldType* pAuthorityType = static_cast<SwAuthorityFieldType*>(pType);
1642  rtl::Reference<SwAuthEntry> xTempEntry(new SwAuthEntry);
1643  for( sal_Int32 i = 0, nIdx = 0; i < AUTH_FIELD_END; ++i )
1644  xTempEntry->SetAuthorField( static_cast<ToxAuthorityField>(i),
1645  rPar1.getToken( 0, TOX_STYLE_DELIMITER, nIdx ));
1646  if( pAuthorityType->ChangeEntryContent( xTempEntry.get() ) )
1647  {
1648  pType->UpdateFields();
1649  pSh->SetModified();
1650  }
1651 
1652  if( xTempEntry->GetAuthorField( AUTH_FIELD_IDENTIFIER ) ==
1653  pAuthorityField->GetFieldText( AUTH_FIELD_IDENTIFIER ) )
1654  bSetPar1 = false; //otherwise it's a new or changed entry, the field needs to be updated
1655  bSetPar2 = false;
1656  }
1657  break;
1658  default: break;
1659  }
1660 
1661  // set format
1662  // setup format before SetPar2 because of NumberFormatter!
1663  pTmpField->ChangeFormat(nFormat);
1664 
1665  if( bSetPar1 )
1666  pTmpField->SetPar1( rPar1 );
1667  if( bSetPar2 )
1668  pTmpField->SetPar2( sPar2 );
1669 
1670  // kick off update
1671  if(nTypeId == SwFieldTypesEnum::DDE ||
1672  nTypeId == SwFieldTypesEnum::User ||
1673  nTypeId == SwFieldTypesEnum::UserInput)
1674  {
1675  pType->UpdateFields();
1676  pSh->SetModified();
1677  }
1678  else {
1679  // mb: #32157
1680  pSh->SwEditShell::UpdateOneField(*pTmpField);
1681  GetCurField();
1682  }
1683 
1684  pTmpField.reset();
1685 
1686  pSh->EndAllAction();
1687 }
1688 
1689 // explicitly evaluate ExpressionFields
1691 {
1692  if (pSh == nullptr)
1694 
1695  if(pSh)
1696  {
1697  pSh->StartAllAction();
1698  pSh->UpdateExpFields(true);
1699  pSh->EndAllAction();
1700  }
1701 }
1703 {
1705  if( pSh )
1706  return pSh->GetCurLang();
1708 }
1709 
1711 {
1712  static const char* coFieldNms[] =
1713  {
1714  FLD_DATE_STD,
1715  FLD_TIME_STD,
1716  STR_FILENAMEFLD,
1717  STR_DBNAMEFLD,
1718  STR_CHAPTERFLD,
1719  STR_PAGENUMBERFLD,
1720  STR_DOCSTATFLD,
1721  STR_AUTHORFLD,
1722  STR_SETFLD,
1723  STR_GETFLD,
1724  STR_FORMELFLD,
1725  STR_HIDDENTXTFLD,
1726  STR_SETREFFLD,
1727  STR_GETREFFLD,
1728  STR_DDEFLD,
1729  STR_MACROFLD,
1730  STR_INPUTFLD,
1731  STR_HIDDENPARAFLD,
1732  STR_DOCINFOFLD,
1733  STR_DBFLD,
1734  STR_USERFLD,
1735  STR_POSTITFLD,
1736  STR_TEMPLNAMEFLD,
1737  STR_SEQFLD,
1738  STR_DBNEXTSETFLD,
1739  STR_DBNUMSETFLD,
1740  STR_DBSETNUMBERFLD,
1741  STR_CONDTXTFLD,
1742  STR_NEXTPAGEFLD,
1743  STR_PREVPAGEFLD,
1744  STR_EXTUSERFLD,
1745  FLD_DATE_FIX,
1746  FLD_TIME_FIX,
1747  STR_SETINPUTFLD,
1748  STR_USRINPUTFLD,
1749  STR_SETREFPAGEFLD,
1750  STR_GETREFPAGEFLD,
1751  STR_INTERNETFLD,
1752  STR_JUMPEDITFLD,
1753  STR_SCRIPTFLD,
1754  STR_AUTHORITY,
1755  STR_COMBINED_CHARS,
1756  STR_DROPDOWN,
1757  STR_CUSTOM_FIELD,
1758  STR_PARAGRAPH_SIGNATURE
1759  };
1760 
1761  // insert infos for fields
1762  SwFieldType::s_pFieldNames = new std::vector<OUString>;
1763  SwFieldType::s_pFieldNames->reserve(SAL_N_ELEMENTS(coFieldNms));
1764  for (const char* id : coFieldNms)
1765  {
1766  const OUString aTmp(SwResId(id));
1768  }
1769 }
1770 
1772 {
1773  bool bRet = false;
1774 
1775  // choose script dialog
1776  OUString aScriptURL = SfxApplication::ChooseScript(pDialogParent);
1777 
1778  // the script selector dialog returns a valid script URL
1779  if ( !aScriptURL.isEmpty() )
1780  {
1781  SetMacroPath( aScriptURL );
1782  bRet = true;
1783  }
1784 
1785  return bRet;
1786 }
1787 
1788 void SwFieldMgr::SetMacroPath(const OUString& rPath)
1789 {
1790  m_sMacroPath = rPath;
1791  m_sMacroName = rPath;
1792 
1793  // try to set sMacroName member variable by parsing the macro path
1794  // using the new URI parsing services
1795 
1797  ::comphelper::getProcessComponentContext();
1798 
1800  xFactory = uri::UriReferenceFactory::create( xContext );
1801 
1803  xUrl( xFactory->parse( m_sMacroPath ), UNO_QUERY );
1804 
1805  if ( xUrl.is() )
1806  {
1807  m_sMacroName = xUrl->getName();
1808  }
1809 }
1810 
1811 sal_uInt32 SwFieldMgr::GetDefaultFormat(SwFieldTypesEnum nTypeId, bool bIsText, SvNumberFormatter* pFormatter)
1812 {
1813  SvNumFormatType nDefFormat;
1814 
1815  switch (nTypeId)
1816  {
1819  {
1820  nDefFormat = (nTypeId == SwFieldTypesEnum::Date) ? SvNumFormatType::DATE : SvNumFormatType::TIME;
1821  }
1822  break;
1823 
1824  default:
1825  if (bIsText)
1826  {
1827  nDefFormat = SvNumFormatType::TEXT;
1828  }
1829  else
1830  {
1831  nDefFormat = SvNumFormatType::ALL;
1832  }
1833  break;
1834  }
1835 
1836  return pFormatter->GetStandardFormat(nDefFormat, GetCurrLanguage());
1837 }
1838 
1840 {
1841  if(!m_xNumberingInfo.is())
1842  {
1844  Reference<XDefaultNumberingProvider> xDefNum = text::DefaultNumberingProvider::create(xContext);
1845  const_cast<SwFieldMgr*>(this)->m_xNumberingInfo.set(xDefNum, UNO_QUERY);
1846  }
1847  return m_xNumberingInfo;
1848 }
1849 
1850 /* 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:409
static const char * FLD_EU_ARY[]
Definition: fldmgr.cxx:127
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:272
SVX_NUM_CHARS_UPPER_LETTER_N
void EvalExpFields(SwWrtShell *pSh)
Definition: fldmgr.cxx:1690
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:158
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:2485
sal_uInt32 GetFormat() const
Query parameters for dialog and for BASIC.
Definition: fldbas.hxx:401
static void GetFieldName_()
Sets up FieldNames; fldmgr.cxx!
Definition: fldmgr.cxx:1710
SvNumberFormatter * GetNumberFormatter(bool bCreate=true)
Definition: doc.hxx:1407
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:254
bool MoveFieldType(const SwFieldType *pFieldType, const bool bNext, const SwFieldIds nResType=SwFieldIds::Unknown, const bool bAddSetExpressionFieldsToInputFields=true)
Definition: crstrvl.cxx:692
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:124
const sal_Unicode cTokenSeparator
Base class of all fields.
Definition: fldbas.hxx:293
SVX_NUM_CHARS_UPPER_LETTER
bool Pop(SwCursorShell::PopMode=SwCursorShell::PopMode::DeleteStack)
Definition: wrtsh1.cxx:1718
#define TOX_STYLE_DELIMITER
Definition: tox.hxx:422
sal_Int64 n
void UpdateCurField(sal_uInt32 nFormat, const OUString &rPar1, const OUString &rPar2, std::unique_ptr< SwField > _pField=nullptr)
Definition: fldmgr.cxx:1523
const sal_uInt16 VF_COUNT
Definition: fldmgr.cxx:123
std::unique_ptr< SwField > CopyField() const
Definition: fldbas.cxx:463
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:235
static SwWrtShell * lcl_GetShell()
Definition: fldmgr.cxx:350
void SetModified()
Definition: edws.cxx:70
void SignParagraph()
Sign the paragraph at the cursor.
Definition: edfcol.cxx:1742
#define FN_NUMBER_FORMAT
Definition: cmdid.h:443
SwWrtShell * m_pSh
Definition: fldmgr.hxx:76
bool InsertField(const SwInsertField_Data &rData)
Definition: fldmgr.cxx:889
static sal_uInt16 GetPos(SwFieldTypesEnum nTypeId)
Definition: fldmgr.cxx:548
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:1702
sal_Int32 getTokenCount(const OString &rIn, char cTok)
SwFieldTypesEnum GetCurTypeId() const
Definition: fldmgr.cxx:883
#define LANGUAGE_HUNGARIAN
static LanguageType nLang
Definition: srtdlg.cxx:51
static OUString GetString(sal_uInt32 i)
void UpdateFields() const
Definition: fldbas.hxx:285
LanguageType GetCurLang() const
Definition: edattr.cxx:811
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:302
bool m_bIsAutomaticLanguage
Definition: fldmgr.hxx:78
sal_uInt16 sal_Unicode
void SetMacroPath(const OUString &rPath)
Definition: fldmgr.cxx:1788
const SwView & GetView() const
Definition: wrtsh.hxx:428
static SwFieldTypesEnum GetTypeId(sal_uInt16 nPos)
Definition: fldmgr.cxx:520
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:125
const BorderLinePrimitive2D *pCandidateB assert(pCandidateA)
size_t GetFieldTypeCount() const
Definition: fldmgr.cxx:402
static std::vector< OUString > * s_pFieldNames
field names
Definition: fldbas.hxx:247
SwField * GetCurField(const bool bIncludeInputFieldAtStart=false) const
Definition: crstrvl.cxx:905
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:670
SVX_NUM_ROMAN_UPPER
sal_uInt32 GetDefaultFormat(SwFieldTypesEnum nTypeId, bool bIsText, SvNumberFormatter *pFormatter)
Definition: fldmgr.cxx:1811
SwFieldTypesEnum m_nTypeId
Definition: fldmgr.hxx:71
SVX_NUM_ROMAN_LOWER
static const char * FMT_REF_ARY[]
Definition: fldmgr.cxx:220
SwDoc * GetDoc() const
Definition: viewsh.hxx:282
css::uno::Any m_aDBConnection
Definition: fldmgr.hxx:80
static const char * FMT_AUTHOR_ARY[]
Definition: fldmgr.cxx:146
bool ChooseMacro(weld::Window *pDialogParent)
Definition: fldmgr.cxx:1771
void Insert(SwField const &, SwPaM *pAnnotationRange=nullptr)
Definition: wrtsh2.cxx:61
static const char * FLD_STAT_ARY[]
Definition: fldmgr.cxx:187
static sal_uInt8 nTablePos
Definition: basesh.cxx:109
virtual void ModifyNotification(const SfxPoolItem *pOldValue, const SfxPoolItem *pNewValue)
Definition: calbck.hxx:154
void SetTableBoxFormulaAttrs(const SfxItemSet &rSet)
Definition: edtab.cxx:343
static const char * FMT_FF_ARY[]
Definition: fldmgr.cxx:177
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:242
SwDBManager * GetDBManager() const
For evaluation of DB fields (new DB-manager).
Definition: edfld.cxx:337
const SfxItemPool & GetAttrPool() const
Definition: viewsh.hxx:612
static OUString GetTypeStr(SwFieldTypesEnum nTypeId)
Definition: fldbas.cxx:120
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:101
SwFieldType * InsertFieldType(const SwFieldType &)
insert field type
Definition: edfld.cxx:347
const OUString m_sPar1
Definition: fldmgr.hxx:73
void Push()
store a copy of the current cursor on the cursor stack
Definition: crsrsh.cxx:2236
bool CanInsertRefMark(const OUString &rStr)
Definition: fldmgr.cxx:375
void RemoveFieldType(SwFieldIds nResId, const OUString &rName)
Definition: fldmgr.cxx:394
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:359
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:424
std::vector< OUString > aDocInfoLst
Definition: shellres.hxx:61
SwDBData const & GetDBData() const
Database information.
Definition: edfld.cxx:295
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:2718
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:307
void UpdateOneField(SwField &)
One single field.
Definition: edfld.cxx:204
sal_uInt16 GetFormatId(SwFieldTypesEnum nTypeId, sal_uInt32 nFormatId) const
Definition: fldmgr.cxx:767
bool GoNextPrev(bool bNext=true, SwFieldType *pTyp=nullptr)
Definition: fldmgr.cxx:849
static const char * FMT_MARK_ARY[]
Definition: fldmgr.cxx:211
SVX_NUM_CHARS_LOWER_LETTER_N
const SvXMLTokenMapEntry aTypes[]
#define DB_DELIM
Definition: swtypes.hxx:137
void UpdateTable()
update fields of a listing
Definition: edtab.cxx:256
Dropdown field.
Definition: flddropdown.hxx:58
SwFieldType * GetTyp() const
Definition: fldbas.hxx:396
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:238
DefTokenId nToken
SAL_DLLPRIVATE css::uno::Reference< css::text::XNumberingTypeInfo > const & GetNumberingInfo() const
Definition: fldmgr.cxx:1839
void UpdateExpFields(bool bCloseDB=false)
only every expression fields update
Definition: edfld.cxx:323
SVX_NUM_PAGEDESC
const SwGetSetExpType GSE_SEQ
Sequence.
Definition: fldbas.hxx:204
SwWrtShell * GetWrtShellPtr() const
Definition: view.hxx:399
bool ChangeEntryContent(const SwAuthEntry *pNewEntry)
Definition: authfld.cxx:148
static const char * FMT_CHAPTER_ARY[]
Definition: fldmgr.cxx:198
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:152
virtual OUString GetName() const
Only in derived classes.
Definition: fldbas.cxx:135
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
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:492
sal_uInt32 GetStandardFormat(SvNumFormatType eType, LanguageType eLnge=LANGUAGE_DONTKNOW)
static const char * FMT_NUM_ARY[]
Definition: fldmgr.cxx:164
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:266
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:266
Get reference.
Definition: reffld.hxx:65
Reference< XColumn > xColumn
static OUString GetTypeStr(sal_uInt16 nPos)
Definition: fldmgr.cxx:526
OUString sId
const sal_uInt16 CRSR_SKIP_CHARS
Definition: swcrsr.hxx:63
ScXMLEditAttributeMap::Entry const aEntries[]
ResultType type
const LanguageTag & GetLanguageTag() const
Reference< XSingleServiceFactory > xFactory
OUString GetFormatStr(SwFieldTypesEnum nTypeId, sal_uInt32 nFormatId) const
Definition: fldmgr.cxx:713
~SwFieldMgr()
Definition: fldmgr.cxx:370
SwFieldMgr(SwWrtShell *pSh=nullptr)
Definition: fldmgr.cxx:362
static OUString EraseAllMnemonicChars(const OUString &rStr)
void ChgDBData(const SwDBData &SwDBData)
Definition: wrtsh1.cxx:1754
sal_uInt16 GetType() const
Definition: expfld.hxx:194
static const SwFieldGroupRgn & GetGroupRange(bool bHtmlMode, sal_uInt16 nGrpId)
Definition: fldmgr.cxx:464
static const char * FMT_SETVAR_ARY[]
Definition: fldmgr.cxx:248
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:874
static const char * FLD_INPUT_ARY[]
Definition: fldmgr.cxx:206
sal_Unicode m_cSeparator
Definition: fldmgr.hxx:77
const SwFieldPack aSwFields[]
Definition: fldmgr.cxx:295
Definition: view.hxx:144
sal_uInt16 nPos
void SetContent(const OUString &rStr, sal_uInt32 nFormat=0)
Definition: usrfld.cxx:282
static const char * FMT_DDE_ARY[]
Definition: fldmgr.cxx:260
void GetSubTypes(SwFieldTypesEnum nId, std::vector< OUString > &rToFill)
Definition: fldmgr.cxx:567