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