LibreOffice Module sw (master)  1
unofield.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 <sal/config.h>
21 #include <algorithm>
22 #include <memory>
23 
24 #include <unofield.hxx>
25 #include <unofieldcoll.hxx>
26 #include <unobookmark.hxx>
27 #include <swtypes.hxx>
28 #include <cmdid.h>
29 #include <doc.hxx>
31 #include <IDocumentStatistics.hxx>
34 #include <IDocumentState.hxx>
35 #include <fmtfld.hxx>
36 #include <txtfld.hxx>
37 #include <ndtxt.hxx>
38 #include <unomap.hxx>
39 #include <unoprnms.hxx>
40 #include <unotextrange.hxx>
41 #include <unotextcursor.hxx>
42 #include <unocoll.hxx>
43 #include <sfx2/linkmgr.hxx>
44 #include <editsh.hxx>
45 #include <viewsh.hxx>
47 #include <comphelper/string.hxx>
49 #include <com/sun/star/util/DateTime.hpp>
50 #include <com/sun/star/util/Date.hpp>
51 #include <com/sun/star/beans/PropertyAttribute.hpp>
52 
53 //undef to prevent error (from sfx2/docfile.cxx)
54 #undef SEQUENCE
55 #include <com/sun/star/text/SetVariableType.hpp>
56 #include <com/sun/star/text/WrapTextMode.hpp>
57 #include <com/sun/star/text/TextContentAnchorType.hpp>
58 #include <authfld.hxx>
59 #include <flddat.hxx>
60 #include <dbfld.hxx>
61 #include <usrfld.hxx>
62 #include <docufld.hxx>
63 #include <expfld.hxx>
64 #include <chpfld.hxx>
65 #include <flddropdown.hxx>
66 #include <poolfmt.hxx>
67 #include <strings.hrc>
68 #include <pagedesc.hxx>
69 #include <docary.hxx>
70 #include <reffld.hxx>
71 #include <ddefld.hxx>
72 #include <SwStyleNameMapper.hxx>
73 #include <swunohelper.hxx>
74 #include <unofldmid.h>
75 #include <scriptinfo.hxx>
76 #include <tools/datetime.hxx>
77 #include <tools/urlobj.hxx>
78 #include <svl/itemprop.hxx>
79 #include <svl/listener.hxx>
81 #include <o3tl/any.hxx>
82 #include <o3tl/safeint.hxx>
83 #include <osl/mutex.hxx>
84 #include <vcl/svapp.hxx>
85 #include <textapi.hxx>
86 #include <fmtmeta.hxx>
87 #include <vector>
88 
89 using namespace ::com::sun::star;
90 using namespace nsSwDocInfoSubType;
91 
92 // case-corrected version of the first part for the service names (see #i67811)
93 #define COM_TEXT_FLDMASTER_CC "com.sun.star.text.fieldmaster."
94 
95 // note: this thing is indexed as an array, so do not insert/remove entries!
96 const sal_uInt16 aDocInfoSubTypeFromService[] =
97 {
98  DI_CHANGE | DI_SUB_AUTHOR, //PROPERTY_MAP_FLDTYP_DOCINFO_CHANGE_AUTHOR
99  DI_CHANGE | DI_SUB_DATE, //PROPERTY_MAP_FLDTYP_DOCINFO_CHANGE_DATE_TIME
100  DI_EDIT | DI_SUB_TIME, //PROPERTY_MAP_FLDTYP_DOCINFO_EDIT_TIME
101  DI_COMMENT, //PROPERTY_MAP_FLDTYP_DOCINFO_DESCRIPTION
102  DI_CREATE | DI_SUB_AUTHOR, //PROPERTY_MAP_FLDTYP_DOCINFO_CREATE_AUTHOR
103  DI_CREATE | DI_SUB_DATE, //PROPERTY_MAP_FLDTYP_DOCINFO_CREATE_DATE_TIME
104  0, //DUMMY
105  0, //DUMMY
106  0, //DUMMY
107  0, //DUMMY
108  DI_CUSTOM, //PROPERTY_MAP_FLDTYP_DOCINFO_CUSTOM
109  DI_PRINT | DI_SUB_AUTHOR, //PROPERTY_MAP_FLDTYP_DOCINFO_PRINT_AUTHOR
110  DI_PRINT | DI_SUB_DATE, //PROPERTY_MAP_FLDTYP_DOCINFO_PRINT_DATE_TIME
111  DI_KEYS, //PROPERTY_MAP_FLDTYP_DOCINFO_KEY_WORDS
112  DI_SUBJECT, //PROPERTY_MAP_FLDTYP_DOCINFO_SUBJECT
113  DI_TITLE, //PROPERTY_MAP_FLDTYP_DOCINFO_TITLE
114  DI_DOCNO //PROPERTY_MAP_FLDTYP_DOCINFO_REVISION
115 };
116 
117 namespace {
118 
119 struct ServiceIdResId
120 {
121  SwFieldIds nResId;
122  SwServiceType nServiceId;
123 };
124 
125 }
126 
127 const ServiceIdResId aServiceToRes[] =
128 {
181 };
182 
184 {
185  for (size_t i=0; i<SAL_N_ELEMENTS(aServiceToRes); ++i)
186  if (aServiceToRes[i].nServiceId == nServiceId)
187  return aServiceToRes[i].nResId;
188 #if OSL_DEBUG_LEVEL > 0
189  OSL_FAIL("service id not found");
190 #endif
191  return SwFieldIds::Unknown;
192 }
193 
195 {
196  const SwFieldIds nWhich = rField.Which();
198  //special handling for some fields
199  switch( nWhich )
200  {
201  case SwFieldIds::Input:
202  if( INP_USR == (rField.GetSubType() & 0x00ff) )
204  break;
205 
206  case SwFieldIds::DocInfo:
207  {
208  const sal_uInt16 nSubType = rField.GetSubType();
209  switch( nSubType & 0xff )
210  {
211  case DI_CHANGE:
212  nSrvId = ((nSubType&0x300) == DI_SUB_AUTHOR)
215  break;
216  case DI_CREATE:
217  nSrvId = ((nSubType&0x300) == DI_SUB_AUTHOR)
220  break;
221  case DI_PRINT:
222  nSrvId = ((nSubType&0x300) == DI_SUB_AUTHOR)
225  break;
230  case DI_TITLE: nSrvId = SwServiceType::FieldTypeDocInfoTitle; break;
232  case DI_CUSTOM: nSrvId = SwServiceType::FieldTypeDocInfoCustom; break;
233  }
234  }
235  break;
236 
238  nSrvId = SwFieldTypesEnum::ConditionalText == static_cast<SwFieldTypesEnum>(rField.GetSubType())
241  break;
242 
243  case SwFieldIds::DocStat:
244  {
245  switch( rField.GetSubType() )
246  {
247  case DS_PAGE: nSrvId = SwServiceType::FieldTypePageCount; break;
248  case DS_PARA: nSrvId = SwServiceType::FieldTypeParagraphCount; break;
249  case DS_WORD: nSrvId = SwServiceType::FieldTypeWordCount ; break;
250  case DS_CHAR: nSrvId = SwServiceType::FieldTypeCharacterCount; break;
251  case DS_TBL: nSrvId = SwServiceType::FieldTypeTableCount ; break;
254  }
255  }
256  break;
257  default: break;
258  }
259  if( SwServiceType::Invalid == nSrvId )
260  {
261  for( const ServiceIdResId* pMap = aServiceToRes;
262  SwFieldIds::Unknown != pMap->nResId; ++pMap )
263  if( nWhich == pMap->nResId )
264  {
265  nSrvId = pMap->nServiceId;
266  break;
267  }
268  }
269 #if OSL_DEBUG_LEVEL > 0
270  if( SwServiceType::Invalid == nSrvId )
271  OSL_FAIL("resid not found");
272 #endif
273  return nSrvId;
274 }
275 
276 static sal_uInt16 lcl_GetPropMapIdForFieldType( SwFieldIds nWhich )
277 {
278  sal_uInt16 nId;
279  switch( nWhich )
280  {
281  case SwFieldIds::User: nId = PROPERTY_MAP_FLDMSTR_USER; break;
284  case SwFieldIds::Dde: nId = PROPERTY_MAP_FLDMSTR_DDE; break;
287  default: nId = PROPERTY_MAP_FLDMSTR_DUMMY0;
288  }
289  return nId;
290 }
291 
292 static sal_Int32 lcl_PropName2TokenPos(std::u16string_view rPropertyName)
293 {
294  if (rPropertyName == u"" UNO_NAME_DDE_COMMAND_TYPE)
295  return 0;
296 
297  if (rPropertyName == u"" UNO_NAME_DDE_COMMAND_FILE)
298  return 1;
299 
300  if (rPropertyName == u"" UNO_NAME_DDE_COMMAND_ELEMENT)
301  return 2;
302 
303  if (rPropertyName == u"" UNO_NAME_IS_AUTOMATIC_UPDATE)
304  return 3;
305 
306  return SAL_MAX_INT32;
307 }
308 
309 static sal_uInt16 GetFieldTypeMId( std::u16string_view rProperty, const SwFieldType& rTyp )
310 {
311  sal_uInt16 nId = lcl_GetPropMapIdForFieldType( rTyp.Which() );
312  const SfxItemPropertySet* pSet = aSwMapProvider.GetPropertySet( nId );
313  if( !pSet )
314  nId = USHRT_MAX;
315  else
316  {
317  const SfxItemPropertyMapEntry* pEntry = pSet->getPropertyMap().getByName(rProperty);
318  nId = pEntry ? pEntry->nWID : USHRT_MAX;
319  }
320  return nId;
321 }
322 
323 static sal_uInt16 lcl_GetPropertyMapOfService( SwServiceType nServiceId )
324 {
325  sal_uInt16 nRet;
326  switch ( nServiceId)
327  {
385  nRet = PROPERTY_MAP_FLDTYP_DUMMY_0; break;
396  default:
397  nRet = USHRT_MAX;
398  }
399  assert(nRet != USHRT_MAX && "wrong service id");
400  return nRet;
401 }
402 
404  : public SvtListener
405 {
406 private:
407  ::osl::Mutex m_Mutex; // just for OInterfaceContainerHelper2
408 
409 public:
410  uno::WeakReference<uno::XInterface> m_wThis;
412 
415 
417 
418  OUString m_sParam1; // Content / Database / NumberingSeparator
419  OUString m_sParam2; // - /DataTablename
420  OUString m_sParam3; // - /DataFieldName
421  OUString m_sParam5; // - /DataBaseURL
422  double m_fParam1; // Value / -
423  sal_Int8 m_nParam1; // ChapterNumberingLevel
424  bool m_bParam1; // IsExpression
425  sal_Int32 m_nParam2;
426 
427  Impl(SwPageDesc* const pPageDesc, SwDoc* pDoc, SwFieldIds nResId)
428  : m_EventListeners(m_Mutex)
429  , m_pDoc(pDoc)
430  , m_pType(nullptr)
431  , m_nResTypeId(nResId)
432  , m_fParam1(0.0)
433  , m_nParam1(-1)
434  , m_bParam1(false)
435  , m_nParam2(0)
436  {
437  StartListening(pPageDesc->GetNotifier());
438  }
439 
440  Impl(SwFieldType* const pType, SwDoc* pDoc, SwFieldIds nResId)
441  : m_EventListeners(m_Mutex)
442  , m_pDoc(pDoc)
443  , m_pType(pType)
444  , m_nResTypeId(nResId)
445  , m_fParam1(0.0)
446  , m_nParam1(-1)
447  , m_bParam1(false)
448  , m_nParam2(0)
449  {
450  StartListening(m_pType->GetNotifier());
451  }
453  {
454  EndListeningAll();
455  m_pType = pType;
456  StartListening(m_pType->GetNotifier());
457  }
458 protected:
459  virtual void Notify(const SfxHint& rHint) override;
460 };
461 
462 const uno::Sequence< sal_Int8 > & SwXFieldMaster::getUnoTunnelId()
463 {
464  static const UnoTunnelIdInit theSwXFieldMasterUnoTunnelId;
465  return theSwXFieldMasterUnoTunnelId.getSeq();
466 }
467 
468 sal_Int64 SAL_CALL
469 SwXFieldMaster::getSomething(const uno::Sequence< sal_Int8 >& rId)
470 {
471  return ::sw::UnoTunnelImpl<SwXFieldMaster>(rId, this);
472 }
473 
474 OUString SAL_CALL
476 {
477  return "SwXFieldMaster";
478 }
479 
480 namespace
481 {
482 
483 OUString getServiceName(const SwFieldIds aId)
484 {
485  const char* pEntry;
486  switch (aId)
487  {
488  case SwFieldIds::User:
489  pEntry = "User";
490  break;
492  pEntry = "Database";
493  break;
494  case SwFieldIds::SetExp:
495  pEntry = "SetExpression";
496  break;
497  case SwFieldIds::Dde:
498  pEntry = "DDE";
499  break;
501  pEntry = "Bibliography";
502  break;
503  default:
504  return OUString();
505  }
506 
507  return "com.sun.star.text.fieldmaster." + OUString::createFromAscii(pEntry);
508 }
509 
510 }
511 
512 sal_Bool SAL_CALL SwXFieldMaster::supportsService(const OUString& rServiceName)
513 {
514  return cppu::supportsService(this, rServiceName);
515 }
516 
517 uno::Sequence< OUString > SAL_CALL
519 {
520  return { "com.sun.star.text.TextFieldMaster", getServiceName(m_pImpl->m_nResTypeId) };
521 }
522 
524  : m_pImpl(new Impl(pDoc->getIDocumentStylePoolAccess().GetPageDescFromPool(RES_POOLPAGE_STANDARD), pDoc, nResId))
525 {
526 }
527 
529  : m_pImpl(new Impl(&rType, pDoc, rType.Which()))
530 {
531 }
532 
534 {
535 }
536 
537 uno::Reference<beans::XPropertySet>
539  SwFieldIds nResId)
540 {
541  // re-use existing SwXFieldMaster
542  uno::Reference<beans::XPropertySet> xFM;
543  if (pType)
544  {
545  xFM = pType->GetXObject();
546  }
547  if (!xFM.is())
548  {
549  SwXFieldMaster *const pFM( pType
550  ? new SwXFieldMaster(*pType, pDoc)
551  : new SwXFieldMaster(pDoc, nResId));
552  xFM.set(pFM);
553  if (pType)
554  {
555  pType->SetXObject(xFM);
556  }
557  // need a permanent Reference to initialize m_wThis
558  pFM->m_pImpl->m_wThis = xFM;
559  }
560  return xFM;
561 }
562 
563 uno::Reference<beans::XPropertySetInfo> SAL_CALL
565 {
566  SolarMutexGuard aGuard;
567  uno::Reference< beans::XPropertySetInfo > aRef =
570  return aRef;
571 }
572 
574  const OUString& rPropertyName, const uno::Any& rValue)
575 {
576  SolarMutexGuard aGuard;
577  SwFieldType* pType = GetFieldType(true);
578  if(pType)
579  {
580  bool bSetValue = true;
581  if( rPropertyName == UNO_NAME_SUB_TYPE )
582  {
583  const std::vector<OUString>& rExtraArr(
585  const OUString sTypeName = pType->GetName();
586  static sal_uInt16 nIds[] =
587  {
593  0
594  };
595  for(const sal_uInt16 * pIds = nIds; *pIds; ++pIds)
596  {
597  if(sTypeName == rExtraArr[ *pIds ] )
598  {
599  bSetValue = false;
600  break;
601  }
602  }
603  }
604  if ( bSetValue )
605  {
606  // nothing special to be done here for the properties
607  // UNO_NAME_DATA_BASE_NAME and UNO_NAME_DATA_BASE_URL.
608  // We just call PutValue (empty string is allowed).
609  // Thus the last property set will be used as Data Source.
610 
611  const sal_uInt16 nMemberValueId = GetFieldTypeMId( rPropertyName, *pType );
612  if ( USHRT_MAX == nMemberValueId )
613  {
614  throw beans::UnknownPropertyException(
615  "Unknown property: " + rPropertyName,
616  static_cast< cppu::OWeakObject * >( this ) );
617  }
618 
619  pType->PutValue( rValue, nMemberValueId );
620  if ( pType->Which() == SwFieldIds::User )
621  {
622  // trigger update of User field in order to get depending Input Fields updated.
623  pType->UpdateFields();
624  }
625 
626  }
627  }
628  else if (m_pImpl->m_pDoc && rPropertyName == UNO_NAME_NAME)
629  {
630  OUString sTypeName;
631  rValue >>= sTypeName;
632  SwFieldType * pType2 = m_pImpl->m_pDoc->getIDocumentFieldsAccess().GetFieldType(
633  m_pImpl->m_nResTypeId, sTypeName, false);
634 
635  if(pType2 ||
636  (SwFieldIds::SetExp == m_pImpl->m_nResTypeId &&
637  ( sTypeName == SwResId(STR_POOLCOLL_LABEL_TABLE) ||
638  sTypeName == SwResId(STR_POOLCOLL_LABEL_DRAWING) ||
639  sTypeName == SwResId(STR_POOLCOLL_LABEL_FRAME) ||
640  sTypeName == SwResId(STR_POOLCOLL_LABEL_ABB) ||
641  sTypeName == SwResId(STR_POOLCOLL_LABEL_FIGURE) )))
642  {
643  throw lang::IllegalArgumentException();
644  }
645 
646  switch (m_pImpl->m_nResTypeId)
647  {
648  case SwFieldIds::User :
649  {
650  SwUserFieldType aType(m_pImpl->m_pDoc, sTypeName);
651  pType2 = m_pImpl->m_pDoc->getIDocumentFieldsAccess().InsertFieldType(aType);
652  static_cast<SwUserFieldType*>(pType2)->SetContent(m_pImpl->m_sParam1);
653  static_cast<SwUserFieldType*>(pType2)->SetValue(m_pImpl->m_fParam1);
654  static_cast<SwUserFieldType*>(pType2)->SetType(m_pImpl->m_bParam1
656  }
657  break;
658  case SwFieldIds::Dde :
659  {
660  SwDDEFieldType aType(sTypeName, m_pImpl->m_sParam1,
661  m_pImpl->m_bParam1 ? SfxLinkUpdateMode::ALWAYS : SfxLinkUpdateMode::ONCALL);
662  pType2 = m_pImpl->m_pDoc->getIDocumentFieldsAccess().InsertFieldType(aType);
663  }
664  break;
665  case SwFieldIds::SetExp :
666  {
667  SwSetExpFieldType aType(m_pImpl->m_pDoc, sTypeName);
668  if (!m_pImpl->m_sParam1.isEmpty())
669  aType.SetDelimiter(OUString(m_pImpl->m_sParam1[0]));
670  if (m_pImpl->m_nParam1 > -1 && m_pImpl->m_nParam1 < MAXLEVEL)
671  aType.SetOutlineLvl(m_pImpl->m_nParam1);
672  pType2 = m_pImpl->m_pDoc->getIDocumentFieldsAccess().InsertFieldType(aType);
673  }
674  break;
675  case SwFieldIds::Database :
676  {
677  rValue >>= m_pImpl->m_sParam3;
678  pType2 = GetFieldType();
679  }
680  break;
681  default: break;
682  }
683  if (!pType2)
684  {
685  throw uno::RuntimeException("no field type found!", *this);
686  }
687  m_pImpl->SetFieldType(pType2);
688  }
689  else
690  {
691  switch (m_pImpl->m_nResTypeId)
692  {
693  case SwFieldIds::User:
694  if(rPropertyName == UNO_NAME_CONTENT)
695  rValue >>= m_pImpl->m_sParam1;
696  else if(rPropertyName == UNO_NAME_VALUE)
697  {
698  if(rValue.getValueType() != ::cppu::UnoType<double>::get())
699  throw lang::IllegalArgumentException();
700  rValue >>= m_pImpl->m_fParam1;
701  }
702  else if(rPropertyName == UNO_NAME_IS_EXPRESSION)
703  {
704  if(rValue.getValueType() != cppu::UnoType<bool>::get())
705  throw lang::IllegalArgumentException();
706  rValue >>= m_pImpl->m_bParam1;
707  }
708 
709  break;
711  if(rPropertyName == UNO_NAME_DATA_BASE_NAME)
712  rValue >>= m_pImpl->m_sParam1;
713  else if(rPropertyName == UNO_NAME_DATA_TABLE_NAME)
714  rValue >>= m_pImpl->m_sParam2;
715  else if(rPropertyName == UNO_NAME_DATA_COLUMN_NAME)
716  rValue >>= m_pImpl->m_sParam3;
717  else if(rPropertyName == UNO_NAME_DATA_COMMAND_TYPE)
718  rValue >>= m_pImpl->m_nParam2;
719  if(rPropertyName == UNO_NAME_DATA_BASE_URL)
720  rValue >>= m_pImpl->m_sParam5;
721 
722  if ( ( !m_pImpl->m_sParam1.isEmpty()
723  || !m_pImpl->m_sParam5.isEmpty())
724  && !m_pImpl->m_sParam2.isEmpty()
725  && !m_pImpl->m_sParam3.isEmpty())
726  {
727  GetFieldType();
728  }
729  break;
730  case SwFieldIds::SetExp:
731  if(rPropertyName == UNO_NAME_NUMBERING_SEPARATOR)
732  rValue >>= m_pImpl->m_sParam1;
733  else if(rPropertyName == UNO_NAME_CHAPTER_NUMBERING_LEVEL)
734  rValue >>= m_pImpl->m_nParam1;
735  break;
736  case SwFieldIds::Dde:
737  {
738  sal_Int32 nPart = lcl_PropName2TokenPos(rPropertyName);
739  if(nPart < 3 )
740  {
741  if (m_pImpl->m_sParam1.isEmpty())
742  {
743  m_pImpl->m_sParam1
744  = OUStringChar(sfx2::cTokenSeparator)
745  + OUStringChar(sfx2::cTokenSeparator);
746  }
747  OUString sTmp;
748  rValue >>= sTmp;
749  sal_Int32 nIndex(0);
750  sal_Int32 nStart(0);
751  while (nIndex < m_pImpl->m_sParam1.getLength())
752  {
753  if (m_pImpl->m_sParam1[nIndex] == sfx2::cTokenSeparator)
754  {
755  if (0 == nPart)
756  break;
757  nStart = nIndex + 1;
758  --nPart;
759  }
760  ++nIndex;
761  }
762  assert(0 == nPart);
763  m_pImpl->m_sParam1 = m_pImpl->m_sParam1.replaceAt(
764  nStart, nIndex - nStart, sTmp);
765  }
766  else if(3 == nPart)
767  {
768  rValue >>= m_pImpl->m_bParam1;
769  }
770  }
771  break;
772  default:
773  throw beans::UnknownPropertyException( "Unknown property: " + rPropertyName, static_cast < cppu::OWeakObject * > ( this ) );
774  }
775  }
776 }
777 
778 SwFieldType* SwXFieldMaster::GetFieldType(bool const bDontCreate) const
779 {
780  if (!bDontCreate && SwFieldIds::Database == m_pImpl->m_nResTypeId
781  && !m_pImpl->m_pType && m_pImpl->m_pDoc)
782  {
783  SwDBData aData;
784 
785  // set DataSource
787  if (!m_pImpl->m_sParam1.isEmpty())
788  aAcc[svx::DataAccessDescriptorProperty::DataSource] <<= m_pImpl->m_sParam1; // DataBaseName
789  else if (!m_pImpl->m_sParam5.isEmpty())
790  aAcc[svx::DataAccessDescriptorProperty::DatabaseLocation] <<= m_pImpl->m_sParam5; // DataBaseURL
791  aData.sDataSource = aAcc.getDataSource();
792 
793  aData.sCommand = m_pImpl->m_sParam2;
794  aData.nCommandType = m_pImpl->m_nParam2;
795 
796  SwDBFieldType aType(m_pImpl->m_pDoc, m_pImpl->m_sParam3, aData);
797  SwFieldType *const pType = m_pImpl->m_pDoc->getIDocumentFieldsAccess().InsertFieldType(aType);
798  m_pImpl->SetFieldType(pType);
799  }
800  return m_pImpl->m_pType;
801 }
802 
803 uno::Any SAL_CALL
804 SwXFieldMaster::getPropertyValue(const OUString& rPropertyName)
805 {
806  SolarMutexGuard aGuard;
807  uno::Any aRet;
808  SwFieldType* pType = GetFieldType(true);
809  if( rPropertyName == UNO_NAME_INSTANCE_NAME )
810  {
811  OUString sName;
812  if(pType)
814  aRet <<= sName;
815  }
816  else if(pType)
817  {
818  if(rPropertyName == UNO_NAME_NAME)
819  {
820  aRet <<= SwXFieldMaster::GetProgrammaticName(*pType, *m_pImpl->m_pDoc);
821  }
822  else if(rPropertyName == UNO_NAME_DEPENDENT_TEXT_FIELDS)
823  {
824  //fill all text fields into a sequence
825  std::vector<SwFormatField*> vpFields;
826  pType->GatherFields(vpFields);
827  uno::Sequence<uno::Reference <text::XDependentTextField> > aSeq(vpFields.size());
828  std::transform(vpFields.begin(), vpFields.end(), aSeq.begin(),
829  [this](SwFormatField* pF) { return uno::Reference<text::XDependentTextField>(SwXTextField::CreateXTextField(m_pImpl->m_pDoc, pF), uno::UNO_QUERY); });
830  aRet <<= aSeq;
831  }
832  else
833  {
834  //TODO: add properties for the other field types
835  const sal_uInt16 nMId = GetFieldTypeMId( rPropertyName, *pType );
836  if (USHRT_MAX == nMId)
837  {
838  throw beans::UnknownPropertyException(
839  "Unknown property: " + rPropertyName,
840  static_cast<cppu::OWeakObject *>(this));
841  }
842  pType->QueryValue( aRet, nMId );
843 
844  if (rPropertyName == UNO_NAME_DATA_BASE_NAME ||
845  rPropertyName == UNO_NAME_DATA_BASE_URL)
846  {
847  OUString aDataSource;
848  aRet >>= aDataSource;
849  aRet <<= OUString();
850 
851  OUString *pStr = nullptr; // only one of this properties will return
852  // a non-empty string.
853  INetURLObject aObj;
854  aObj.SetURL( aDataSource );
855  bool bIsURL = aObj.GetProtocol() != INetProtocol::NotValid;
856  if (bIsURL && rPropertyName == UNO_NAME_DATA_BASE_URL)
857  pStr = &aDataSource; // DataBaseURL
858  else if (!bIsURL && rPropertyName == UNO_NAME_DATA_BASE_NAME)
859  pStr = &aDataSource; // DataBaseName
860 
861  if (pStr)
862  aRet <<= *pStr;
863  }
864  }
865  }
866  else
867  {
868  if(rPropertyName == UNO_NAME_DATA_COMMAND_TYPE)
869  aRet <<= m_pImpl->m_nParam2;
870  else if(rPropertyName == UNO_NAME_DEPENDENT_TEXT_FIELDS )
871  {
872  uno::Sequence<uno::Reference <text::XDependentTextField> > aRetSeq(0);
873  aRet <<= aRetSeq;
874  }
875  else
876  {
877  switch (m_pImpl->m_nResTypeId)
878  {
879  case SwFieldIds::User:
880  if( rPropertyName == UNO_NAME_CONTENT )
881  aRet <<= m_pImpl->m_sParam1;
882  else if(rPropertyName == UNO_NAME_VALUE)
883  aRet <<= m_pImpl->m_fParam1;
884  else if(rPropertyName == UNO_NAME_IS_EXPRESSION)
885  aRet <<= m_pImpl->m_bParam1;
886  break;
888  if(rPropertyName == UNO_NAME_DATA_BASE_NAME ||
889  rPropertyName == UNO_NAME_DATA_BASE_URL)
890  {
891  // only one of these properties returns a non-empty string.
892  INetURLObject aObj;
893  aObj.SetURL(m_pImpl->m_sParam5); // SetSmartURL
894  bool bIsURL = aObj.GetProtocol() != INetProtocol::NotValid;
895  if (bIsURL && rPropertyName == UNO_NAME_DATA_BASE_URL)
896  aRet <<= m_pImpl->m_sParam5; // DataBaseURL
897  else if ( rPropertyName == UNO_NAME_DATA_BASE_NAME)
898  aRet <<= m_pImpl->m_sParam1; // DataBaseName
899  }
900  else if(rPropertyName == UNO_NAME_DATA_TABLE_NAME)
901  aRet <<= m_pImpl->m_sParam2;
902  else if(rPropertyName == UNO_NAME_DATA_COLUMN_NAME)
903  aRet <<= m_pImpl->m_sParam3;
904  break;
905  case SwFieldIds::SetExp:
906  if(rPropertyName == UNO_NAME_NUMBERING_SEPARATOR)
907  aRet <<= m_pImpl->m_sParam1;
908  else if(rPropertyName == UNO_NAME_CHAPTER_NUMBERING_LEVEL)
909  aRet <<= m_pImpl->m_nParam1;
910  break;
911  case SwFieldIds::Dde:
912  {
913  const sal_Int32 nPart = lcl_PropName2TokenPos(rPropertyName);
914  if(nPart < 3 )
915  aRet <<= m_pImpl->m_sParam1.getToken(nPart, sfx2::cTokenSeparator);
916  else if(3 == nPart)
917  aRet <<= m_pImpl->m_bParam1;
918  }
919  break;
920  default:
921  throw beans::UnknownPropertyException( "Unknown property: " + rPropertyName, static_cast < cppu::OWeakObject * > ( this ) );
922  }
923  }
924  }
925  return aRet;
926 }
927 
928 void SwXFieldMaster::addPropertyChangeListener(const OUString& /*PropertyName*/, const uno::Reference< beans::XPropertyChangeListener > & /*aListener*/)
929 {
930  OSL_FAIL("not implemented");
931 }
932 
933 void SwXFieldMaster::removePropertyChangeListener(const OUString& /*PropertyName*/, const uno::Reference< beans::XPropertyChangeListener > & /*aListener*/)
934 {
935  OSL_FAIL("not implemented");
936 }
937 
938 void SwXFieldMaster::addVetoableChangeListener(const OUString& /*PropertyName*/, const uno::Reference< beans::XVetoableChangeListener > & /*aListener*/)
939 {
940  OSL_FAIL("not implemented");
941 }
942 
943 void SwXFieldMaster::removeVetoableChangeListener(const OUString& /*PropertyName*/, const uno::Reference< beans::XVetoableChangeListener > & /*aListener*/)
944 {
945  OSL_FAIL("not implemented");
946 }
947 
948 void SAL_CALL SwXFieldMaster::dispose()
949 {
950  SolarMutexGuard aGuard;
951  SwFieldType *const pFieldType = GetFieldType(true);
952  if (!pFieldType)
953  throw uno::RuntimeException();
954  size_t nTypeIdx = SIZE_MAX;
955  const SwFieldTypes* pTypes = m_pImpl->m_pDoc->getIDocumentFieldsAccess().GetFieldTypes();
956  for( size_t i = 0; i < pTypes->size(); i++ )
957  {
958  if((*pTypes)[i].get()== pFieldType)
959  nTypeIdx = i;
960  }
961 
962  // first delete all fields
963  std::vector<SwFormatField*> vpFields;
964  pFieldType->GatherFields(vpFields);
965  for(auto pField : vpFields)
966  SwTextField::DeleteTextField(*pField->GetTextField());
967  // then delete FieldType
968  m_pImpl->m_pDoc->getIDocumentFieldsAccess().RemoveFieldType(nTypeIdx);
969 }
970 
972  const uno::Reference<lang::XEventListener> & xListener)
973 {
974  // no need to lock here as m_pImpl is const and container threadsafe
975  m_pImpl->m_EventListeners.addInterface(xListener);
976 }
977 
979  const uno::Reference<lang::XEventListener> & xListener)
980 {
981  // no need to lock here as m_pImpl is const and container threadsafe
982  m_pImpl->m_EventListeners.removeInterface(xListener);
983 }
984 
986 {
987  if(rHint.GetId() == SfxHintId::Dying)
988  {
989  m_pDoc = nullptr;
990  m_pType = nullptr;
991  uno::Reference<uno::XInterface> const xThis(m_wThis);
992  if (!xThis.is())
993  { // fdo#72695: if UNO object is already dead, don't revive it with event
994  return;
995  }
996  lang::EventObject const ev(xThis);
998  }
999 }
1000 
1002 {
1003  const OUString sName(rType.GetName());
1004  if(SwFieldIds::SetExp == rType.Which())
1005  {
1006  const SwFieldTypes* pTypes = rDoc.getIDocumentFieldsAccess().GetFieldTypes();
1007  for( size_t i = 0; i <= o3tl::make_unsigned(INIT_FLDTYPES); i++ )
1008  {
1009  if((*pTypes)[i].get() == &rType)
1010  {
1012  }
1013  }
1014  }
1015  return sName;
1016 }
1017 
1019  const SwSetExpField& rField,
1020  const OUString& rFormula,
1021  bool bQuery)
1022 {
1023  const OUString sTypeName(rField.GetTyp()->GetName());
1024  const OUString sProgName(
1026  if(sProgName != sTypeName)
1027  {
1028  const OUString sSource = bQuery ? sTypeName : sProgName;
1029  const OUString sDest = bQuery ? sProgName : sTypeName;
1030  if(rFormula.startsWith(sSource))
1031  {
1032  return sDest + rFormula.subView(sSource.getLength());
1033  }
1034  }
1035  return rFormula;
1036 }
1037 
1038 namespace {
1039 
1040 struct SwFieldProperties_Impl
1041 {
1042  OUString sPar1;
1043  OUString sPar2;
1044  OUString sPar3;
1045  OUString sPar4;
1046  Date aDate;
1047  double fDouble;
1048  uno::Sequence<beans::PropertyValue> aPropSeq;
1049  uno::Sequence<OUString> aStrings;
1050  std::unique_ptr<util::DateTime> pDateTime;
1051 
1052  sal_Int32 nSubType;
1053  sal_Int32 nFormat;
1054  sal_uInt16 nUSHORT1;
1055  sal_uInt16 nUSHORT2;
1056  sal_Int16 nSHORT1;
1057  sal_Int8 nByte1;
1058  bool bFormatIsDefault;
1059  bool bBool1;
1060  bool bBool2;
1061  bool bBool3;
1062  bool bBool4;
1063 
1064  SwFieldProperties_Impl():
1065  aDate( Date::EMPTY ),
1066  fDouble(0.),
1067  nSubType(0),
1068  nFormat(0),
1069  nUSHORT1(0),
1070  nUSHORT2(0),
1071  nSHORT1(0),
1072  nByte1(0),
1073  bFormatIsDefault(true),
1074  bBool1(false),
1075  bBool2(false),
1076  bBool3(false),
1077  bBool4(true) //Automatic language
1078  {}
1079 };
1080 
1081 }
1082 
1084  : public SvtListener
1085 {
1086 private:
1087  ::osl::Mutex m_Mutex; // just for OInterfaceContainerHelper2
1090 
1091 public:
1092  uno::WeakReference<uno::XInterface> m_wThis;
1094 
1100  OUString m_sTypeName;
1101  std::unique_ptr<SwFieldProperties_Impl> m_pProps;
1102 
1103  Impl(SwDoc *const pDoc, SwFormatField *const pFormat, SwServiceType nServiceId)
1104  : m_pFieldType(nullptr)
1105  , m_pFormatField(pFormat)
1106  , m_EventListeners(m_Mutex)
1107  , m_pDoc(pDoc)
1108  , m_bIsDescriptor(pFormat == nullptr)
1109  , m_bCallUpdate(false)
1110  , m_nServiceId(pFormat
1111  ? lcl_GetServiceForField(*pFormat->GetField())
1112  : nServiceId)
1113  , m_pProps(pFormat ? nullptr : new SwFieldProperties_Impl)
1114  {
1115  if(m_pFormatField)
1116  StartListening(m_pFormatField->GetNotifier());
1117  }
1118 
1119  virtual ~Impl() override
1120  {
1121  if (m_xTextObject.is())
1122  {
1123  m_xTextObject->DisposeEditSource();
1124  }
1125  }
1126 
1127  void SetFormatField(SwFormatField* pFormatField, SwDoc* pDoc)
1128  {
1129  m_pFormatField = pFormatField;
1130  m_pDoc = pDoc;
1131  if(m_pFormatField)
1132  {
1133  EndListeningAll();
1134  StartListening(m_pFormatField->GetNotifier());
1135  }
1136  }
1138  {
1139  return m_pFormatField;
1140  }
1141  bool IsDescriptor() const
1142  {
1143  // ideally should be: !m_pFormatField && m_pDoc
1144  // but: SwXServiceProvider::MakeInstance() passes nullptr SwDoc, see comment there
1145  return m_bIsDescriptor;
1146  }
1147  void Invalidate();
1148 
1149  const SwField* GetField() const;
1150 
1152  {
1153  if(!m_pDoc && !IsDescriptor())
1154  throw uno::RuntimeException();
1155  else if (IsDescriptor())
1156  return m_pFieldType;
1157 
1158  return m_pFormatField->GetField()->GetTyp();
1159  }
1161  {
1162  EndListeningAll();
1163  m_pFieldType = &rType;
1164  StartListening(m_pFieldType->GetNotifier());
1165  }
1167  {
1169  m_pFieldType = nullptr;
1170  }
1171  virtual void Notify(const SfxHint&) override;
1172 };
1173 
1174 const uno::Sequence< sal_Int8 > & SwXTextField::getUnoTunnelId()
1175 {
1176  static const UnoTunnelIdInit theSwXTextFieldUnoTunnelId;
1177  return theSwXTextFieldUnoTunnelId.getSeq();
1178 }
1179 
1180 sal_Int64 SAL_CALL
1181 SwXTextField::getSomething(const uno::Sequence< sal_Int8 >& rId)
1182 {
1183  return ::sw::UnoTunnelImpl<SwXTextField>(rId, this);
1184 }
1185 
1187  SwServiceType nServiceId,
1188  SwDoc* pDoc)
1189  : m_pImpl(new Impl(pDoc, nullptr, nServiceId))
1190 {
1191  //Set visible as default!
1192  if ( SwServiceType::FieldTypeSetExp == nServiceId
1194  || SwServiceType::FieldTypeDatabase == nServiceId
1195  || SwServiceType::FieldTypeDatabaseName == nServiceId )
1196  {
1197  m_pImpl->m_pProps->bBool2 = true;
1198  }
1199  else if(SwServiceType::FieldTypeTableFormula == nServiceId)
1200  {
1201  m_pImpl->m_pProps->bBool1 = true;
1202  }
1203  if(SwServiceType::FieldTypeSetExp == nServiceId)
1204  {
1205  m_pImpl->m_pProps->nUSHORT2 = USHRT_MAX;
1206  }
1207 }
1208 
1210  : m_pImpl(new Impl(&rDoc, &rFormat, SwServiceType::Invalid))
1211 {
1212 }
1213 
1215 {
1216 }
1217 
1218 uno::Reference<text::XTextField>
1220  SwServiceType nServiceId)
1221 {
1222  assert(!pFormat || pDoc);
1223  assert(pFormat || nServiceId != SwServiceType::Invalid);
1224  // re-use existing SwXTextField
1225  uno::Reference<text::XTextField> xField;
1226  if (pFormat)
1227  {
1228  xField = pFormat->GetXTextField();
1229  }
1230  if (!xField.is())
1231  {
1232  SwXTextField *const pField( pFormat
1233  ? new SwXTextField(const_cast<SwFormatField&>(*pFormat), *pDoc)
1234  : new SwXTextField(nServiceId, pDoc));
1235  xField.set(pField);
1236  if (pFormat)
1237  {
1238  const_cast<SwFormatField *>(pFormat)->SetXTextField(xField);
1239  }
1240  // need a permanent Reference to initialize m_wThis
1241  pField->m_pImpl->m_wThis = xField;
1242  }
1243  return xField;
1244 }
1245 
1247 {
1248  return m_pImpl->m_nServiceId;
1249 }
1250 
1264 {
1265  assert(rField.GetFormatField()->Which() == (rField.GetInputFlag() ? RES_TXTATR_INPUTFIELD : RES_TXTATR_FIELD));
1266  uno::Reference<text::XTextField> const xField(
1267  rField.GetFormatField()->GetXTextField());
1268  SwXTextField *const pXField = xField.is()
1269  ? reinterpret_cast<SwXTextField*>(
1270  sal::static_int_cast<sal_IntPtr>(
1271  uno::Reference<lang::XUnoTunnel>(xField, uno::UNO_QUERY_THROW)
1273  : nullptr;
1274  if (pXField)
1275  pXField->m_pImpl->SetFormatField(nullptr, nullptr);
1276  SwTextField *const pOldAttr(rField.GetFormatField()->GetTextField());
1277  SwSetExpField tempField(rField);
1278  tempField.SetInputFlag(!rField.GetInputFlag());
1279  SwFormatField tempFormat(tempField);
1280  assert(tempFormat.GetField() != &rField);
1281  assert(tempFormat.GetField() != &tempField); // this copies it again?
1282  assert(tempFormat.Which() == (static_cast<SwSetExpField const*>(tempFormat.GetField())->GetInputFlag() ? RES_TXTATR_INPUTFIELD : RES_TXTATR_FIELD));
1283  SwTextNode & rNode(pOldAttr->GetTextNode());
1284  std::shared_ptr<SwPaM> pPamForTextField;
1285  IDocumentContentOperations & rIDCO(rNode.GetDoc().getIDocumentContentOperations());
1286  SwTextField::GetPamForTextField(*pOldAttr, pPamForTextField);
1287  assert(pPamForTextField);
1288  sal_Int32 const nStart(pPamForTextField->Start()->nContent.GetIndex());
1289  rIDCO.DeleteAndJoin(*pPamForTextField);
1290  // ATTENTION: rField is dead now! hope nobody accesses it...
1291  bool bSuccess = rIDCO.InsertPoolItem(*pPamForTextField, tempFormat);
1292  assert(bSuccess);
1293  (void) bSuccess;
1294  SwTextField const* pNewAttr(rNode.GetFieldTextAttrAt(nStart, true));
1295  assert(pNewAttr);
1296  SwFormatField const& rNewFormat(pNewAttr->GetFormatField());
1297  assert(rNewFormat.Which() == (static_cast<SwSetExpField const*>(rNewFormat.GetField())->GetInputFlag() ? RES_TXTATR_INPUTFIELD : RES_TXTATR_FIELD));
1298  assert(static_cast<SwSetExpField const*>(rNewFormat.GetField())->GetInputFlag() == (dynamic_cast<SwTextInputField const*>(pNewAttr) != nullptr));
1299  if (xField.is())
1300  {
1301  pXField->m_pImpl->SetFormatField(const_cast<SwFormatField*>(&rNewFormat), &rNode.GetDoc());
1302  const_cast<SwFormatField&>(rNewFormat).SetXTextField(xField);
1303  }
1304 }
1305 
1307  const uno::Reference< beans::XPropertySet > & xFieldMaster)
1308 {
1309  SolarMutexGuard aGuard;
1310 
1311  if (!m_pImpl->IsDescriptor())
1312  throw uno::RuntimeException();
1313  uno::Reference< lang::XUnoTunnel > xMasterTunnel(xFieldMaster, uno::UNO_QUERY);
1314  if (!xMasterTunnel.is())
1315  throw lang::IllegalArgumentException();
1316  SwXFieldMaster* pMaster = reinterpret_cast< SwXFieldMaster * >(
1317  sal::static_int_cast< sal_IntPtr >( xMasterTunnel->getSomething( SwXFieldMaster::getUnoTunnelId()) ));
1318 
1319  SwFieldType* pFieldType = pMaster ? pMaster->GetFieldType() : nullptr;
1320  if (!pFieldType ||
1321  pFieldType->Which() != lcl_ServiceIdToResId(m_pImpl->m_nServiceId))
1322  {
1323  throw lang::IllegalArgumentException();
1324  }
1325  m_pImpl->m_sTypeName = pFieldType->GetName();
1326  m_pImpl->SetFieldType(*pFieldType);
1327 }
1328 
1329 uno::Reference< beans::XPropertySet > SAL_CALL
1331 {
1332  SolarMutexGuard aGuard;
1333 
1334  SwFieldType* pType = m_pImpl->GetFieldType();
1335  uno::Reference<beans::XPropertySet> const xRet(
1337  return xRet;
1338 }
1339 
1340 OUString SAL_CALL SwXTextField::getPresentation(sal_Bool bShowCommand)
1341 {
1342  SolarMutexGuard aGuard;
1343 
1344  SwField const*const pField = m_pImpl->GetField();
1345  if (!pField)
1346  {
1347  throw uno::RuntimeException();
1348  }
1349  return bShowCommand ? pField->GetFieldName() : pField->ExpandField(true, nullptr);
1350 }
1351 
1352 void SAL_CALL SwXTextField::attach(
1353  const uno::Reference< text::XTextRange > & xTextRange)
1354 {
1355  SolarMutexGuard aGuard;
1356  if (m_pImpl->IsDescriptor())
1357  {
1358  uno::Reference<lang::XUnoTunnel> xRangeTunnel( xTextRange, uno::UNO_QUERY);
1359  SwXTextRange* pRange = nullptr;
1360  OTextCursorHelper* pCursor = nullptr;
1361  if(xRangeTunnel.is())
1362  {
1363  pRange = reinterpret_cast< SwXTextRange * >(
1364  sal::static_int_cast< sal_IntPtr >( xRangeTunnel->getSomething( SwXTextRange::getUnoTunnelId()) ));
1365  pCursor = reinterpret_cast< OTextCursorHelper * >(
1366  sal::static_int_cast< sal_IntPtr >( xRangeTunnel->getSomething( OTextCursorHelper::getUnoTunnelId()) ));
1367  }
1368 
1369  SwDoc* pDoc = pRange ? &pRange->GetDoc() : pCursor ? pCursor->GetDoc() : nullptr;
1370  // if a FieldMaster was attached, then the document is already fixed!
1371  // NOTE: sw.SwXAutoTextEntry unoapi test depends on m_pDoc = 0 being valid
1372  if (!pDoc || (m_pImpl->m_pDoc && m_pImpl->m_pDoc != pDoc))
1373  throw lang::IllegalArgumentException();
1374 
1375  SwUnoInternalPaM aPam(*pDoc);
1376  // this now needs to return TRUE
1377  ::sw::XTextRangeToSwPaM(aPam, xTextRange);
1378  std::unique_ptr<SwField> xField;
1379  switch (m_pImpl->m_nServiceId)
1380  {
1382  {
1384 
1385  DateTime aDateTime( DateTime::EMPTY );
1386  if (m_pImpl->m_pProps->pDateTime)
1387  {
1388  aDateTime = *(m_pImpl->m_pProps->pDateTime);
1389  }
1390  SwPostItField* pPostItField = new SwPostItField(
1391  static_cast<SwPostItFieldType*>(pFieldType),
1392  m_pImpl->m_pProps->sPar1, // author
1393  m_pImpl->m_pProps->sPar2, // content
1394  m_pImpl->m_pProps->sPar3, // author's initials
1395  m_pImpl->m_pProps->sPar4, // name
1396  aDateTime,
1397  m_pImpl->m_pProps->bBool1 // resolvedflag
1398  );
1399  if ( m_pImpl->m_xTextObject.is() )
1400  {
1401  pPostItField->SetTextObject( m_pImpl->m_xTextObject->CreateText() );
1402  pPostItField->SetPar2(m_pImpl->m_xTextObject->GetText());
1403  }
1404  xField.reset(pPostItField);
1405  }
1406  break;
1408  {
1410  xField.reset(new SwScriptField(static_cast<SwScriptFieldType*>(pFieldType),
1411  m_pImpl->m_pProps->sPar1, m_pImpl->m_pProps->sPar2,
1412  m_pImpl->m_pProps->bBool1));
1413  }
1414  break;
1416  {
1417  sal_uInt16 nSub = 0;
1418  if (m_pImpl->m_pProps->bBool1)
1419  nSub |= FIXEDFLD;
1420  if (m_pImpl->m_pProps->bBool2)
1421  nSub |= DATEFLD;
1422  else
1423  nSub |= TIMEFLD;
1425  SwDateTimeField *const pDTField = new SwDateTimeField(
1426  static_cast<SwDateTimeFieldType*>(pFieldType),
1427  nSub, m_pImpl->m_pProps->nFormat);
1428  xField.reset(pDTField);
1429  if (m_pImpl->m_pProps->fDouble > 0.)
1430  {
1431  pDTField->SetValue(m_pImpl->m_pProps->fDouble);
1432  }
1433  if (m_pImpl->m_pProps->pDateTime)
1434  {
1435  uno::Any aVal; aVal <<= *m_pImpl->m_pProps->pDateTime;
1436  xField->PutValue( aVal, FIELD_PROP_DATE_TIME );
1437  }
1438  pDTField->SetOffset(m_pImpl->m_pProps->nSubType);
1439  }
1440  break;
1442  {
1444  sal_Int32 nFormat = m_pImpl->m_pProps->nFormat;
1445  if (m_pImpl->m_pProps->bBool2)
1446  nFormat |= FF_FIXED;
1447  SwFileNameField *const pFNField = new SwFileNameField(
1448  static_cast<SwFileNameFieldType*>(pFieldType), nFormat);
1449  xField.reset(pFNField);
1450  if (!m_pImpl->m_pProps->sPar3.isEmpty())
1451  pFNField->SetExpansion(m_pImpl->m_pProps->sPar3);
1452  uno::Any aFormat;
1453  aFormat <<= m_pImpl->m_pProps->nFormat;
1454  xField->PutValue( aFormat, FIELD_PROP_FORMAT );
1455  }
1456  break;
1458  {
1460  xField.reset(new SwTemplNameField(static_cast<SwTemplNameFieldType*>(pFieldType),
1461  m_pImpl->m_pProps->nFormat));
1462  uno::Any aFormat;
1463  aFormat <<= m_pImpl->m_pProps->nFormat;
1464  xField->PutValue(aFormat, FIELD_PROP_FORMAT);
1465  }
1466  break;
1468  {
1470  SwChapterField *const pChapterField = new SwChapterField(
1471  static_cast<SwChapterFieldType*>(pFieldType),
1472  m_pImpl->m_pProps->nUSHORT1);
1473  xField.reset(pChapterField);
1474  pChapterField->SetLevel(m_pImpl->m_pProps->nByte1);
1475  uno::Any aVal;
1476  aVal <<= static_cast<sal_Int16>(m_pImpl->m_pProps->nUSHORT1);
1477  xField->PutValue(aVal, FIELD_PROP_USHORT1 );
1478  }
1479  break;
1481  {
1482  tools::Long nFormat = m_pImpl->m_pProps->bBool1 ? AF_NAME : AF_SHORTCUT;
1483  if (m_pImpl->m_pProps->bBool2)
1484  nFormat |= AF_FIXED;
1485 
1487  SwAuthorField *const pAuthorField = new SwAuthorField(
1488  static_cast<SwAuthorFieldType*>(pFieldType), nFormat);
1489  xField.reset(pAuthorField);
1490  pAuthorField->SetExpansion(m_pImpl->m_pProps->sPar1);
1491  }
1492  break;
1495  {
1497  SwHiddenTextField *const pHTField = new SwHiddenTextField(
1498  static_cast<SwHiddenTextFieldType*>(pFieldType),
1499  m_pImpl->m_pProps->sPar1,
1500  m_pImpl->m_pProps->sPar2, m_pImpl->m_pProps->sPar3,
1501  SwServiceType::FieldTypeHiddenText == m_pImpl->m_nServiceId ?
1503  xField.reset(pHTField);
1504  pHTField->SetValue(m_pImpl->m_pProps->bBool1);
1505  uno::Any aVal;
1506  aVal <<= m_pImpl->m_pProps->sPar4;
1507  xField->PutValue(aVal, FIELD_PROP_PAR4 );
1508  }
1509  break;
1511  {
1513  SwHiddenParaField *const pHPField = new SwHiddenParaField(
1514  static_cast<SwHiddenParaFieldType*>(pFieldType),
1515  m_pImpl->m_pProps->sPar1);
1516  xField.reset(pHPField);
1517  pHPField->SetHidden(m_pImpl->m_pProps->bBool1);
1518  }
1519  break;
1521  {
1523  xField.reset(new SwGetRefField(static_cast<SwGetRefFieldType*>(pFieldType),
1524  m_pImpl->m_pProps->sPar1,
1525  m_pImpl->m_pProps->sPar4,
1526  0,
1527  0,
1528  0));
1529  if (!m_pImpl->m_pProps->sPar3.isEmpty())
1530  static_cast<SwGetRefField*>(xField.get())->SetExpand(m_pImpl->m_pProps->sPar3);
1531  uno::Any aVal;
1532  aVal <<= static_cast<sal_Int16>(m_pImpl->m_pProps->nUSHORT1);
1533  xField->PutValue(aVal, FIELD_PROP_USHORT1 );
1534  aVal <<= static_cast<sal_Int16>(m_pImpl->m_pProps->nUSHORT2);
1535  xField->PutValue(aVal, FIELD_PROP_USHORT2 );
1536  aVal <<= m_pImpl->m_pProps->nSHORT1;
1537  xField->PutValue(aVal, FIELD_PROP_SHORT1 );
1538  }
1539  break;
1541  {
1543  xField.reset(new SwJumpEditField(static_cast<SwJumpEditFieldType*>(pFieldType),
1544  m_pImpl->m_pProps->nUSHORT1, m_pImpl->m_pProps->sPar2,
1545  m_pImpl->m_pProps->sPar1));
1546  }
1547  break;
1562  {
1564  sal_uInt16 nSubType = aDocInfoSubTypeFromService[
1565  static_cast<sal_uInt16>(m_pImpl->m_nServiceId) - sal_uInt16(SwServiceType::FieldTypeDocInfoChangeAuthor)];
1570  {
1571  if (m_pImpl->m_pProps->bBool2) //IsDate
1572  {
1573  nSubType &= 0xf0ff;
1574  nSubType |= DI_SUB_DATE;
1575  }
1576  else
1577  {
1578  nSubType &= 0xf0ff;
1579  nSubType |= DI_SUB_TIME;
1580  }
1581  }
1582  if (m_pImpl->m_pProps->bBool1)
1583  nSubType |= DI_SUB_FIXED;
1584  xField.reset(new SwDocInfoField(
1585  static_cast<SwDocInfoFieldType*>(pFieldType), nSubType,
1586  m_pImpl->m_pProps->sPar4, m_pImpl->m_pProps->nFormat));
1587  if (!m_pImpl->m_pProps->sPar3.isEmpty())
1588  static_cast<SwDocInfoField*>(xField.get())->SetExpansion(m_pImpl->m_pProps->sPar3);
1589  }
1590  break;
1592  {
1593  sal_Int32 nFormat = 0;
1594  if (m_pImpl->m_pProps->bBool1)
1595  nFormat = AF_FIXED;
1596 
1598  SwExtUserField *const pEUField = new SwExtUserField(
1599  static_cast<SwExtUserFieldType*>(pFieldType),
1600  m_pImpl->m_pProps->nUSHORT1, nFormat);
1601  xField.reset(pEUField);
1602  pEUField->SetExpansion(m_pImpl->m_pProps->sPar1);
1603  }
1604  break;
1606  {
1607  SwFieldType* pFieldType =
1608  pDoc->getIDocumentFieldsAccess().GetFieldType(SwFieldIds::User, m_pImpl->m_sTypeName, true);
1609  if (!pFieldType)
1610  throw uno::RuntimeException();
1611  sal_uInt16 nUserSubType = (m_pImpl->m_pProps->bBool1)
1613  if (m_pImpl->m_pProps->bBool2)
1614  nUserSubType |= nsSwExtendedSubType::SUB_CMD;
1615  if (m_pImpl->m_pProps->bFormatIsDefault &&
1616  nsSwGetSetExpType::GSE_STRING == static_cast<SwUserFieldType*>(pFieldType)->GetType())
1617  {
1618  m_pImpl->m_pProps->nFormat = -1;
1619  }
1620  xField.reset(new SwUserField(static_cast<SwUserFieldType*>(pFieldType),
1621  nUserSubType,
1622  m_pImpl->m_pProps->nFormat));
1623  }
1624  break;
1626  {
1628  xField.reset(new SwRefPageSetField( static_cast<SwRefPageSetFieldType*>(pFieldType),
1629  m_pImpl->m_pProps->nUSHORT1,
1630  m_pImpl->m_pProps->bBool1 ));
1631  }
1632  break;
1634  {
1636  SwRefPageGetField *const pRGField = new SwRefPageGetField(
1637  static_cast<SwRefPageGetFieldType*>(pFieldType),
1638  m_pImpl->m_pProps->nUSHORT1 );
1639  xField.reset(pRGField);
1640  pRGField->SetText(m_pImpl->m_pProps->sPar1, nullptr);
1641  }
1642  break;
1644  {
1646  SwPageNumberField *const pPNField = new SwPageNumberField(
1647  static_cast<SwPageNumberFieldType*>(pFieldType), PG_RANDOM,
1648  m_pImpl->m_pProps->nFormat,
1649  m_pImpl->m_pProps->nUSHORT1);
1650  xField.reset(pPNField);
1651  pPNField->SetUserString(m_pImpl->m_pProps->sPar1);
1652  uno::Any aVal;
1653  aVal <<= m_pImpl->m_pProps->nSubType;
1654  xField->PutValue( aVal, FIELD_PROP_SUBTYPE );
1655  }
1656  break;
1658  {
1659  SwFieldType* pFieldType =
1660  pDoc->getIDocumentFieldsAccess().GetFieldType(SwFieldIds::Dde, m_pImpl->m_sTypeName, true);
1661  if (!pFieldType)
1662  throw uno::RuntimeException();
1663  xField.reset(new SwDDEField( static_cast<SwDDEFieldType*>(pFieldType) ));
1664  }
1665  break;
1667  {
1669  SwDBData aData;
1670  aData.sDataSource = m_pImpl->m_pProps->sPar1;
1671  aData.sCommand = m_pImpl->m_pProps->sPar2;
1672  aData.nCommandType = m_pImpl->m_pProps->nSHORT1;
1673  xField.reset(new SwDBNameField(static_cast<SwDBNameFieldType*>(pFieldType), aData));
1674  sal_uInt16 nSubType = xField->GetSubType();
1675  if (m_pImpl->m_pProps->bBool2)
1677  else
1679  xField->SetSubType(nSubType);
1680  }
1681  break;
1683  {
1684  SwDBData aData;
1685  aData.sDataSource = m_pImpl->m_pProps->sPar1;
1686  aData.sCommand = m_pImpl->m_pProps->sPar2;
1687  aData.nCommandType = m_pImpl->m_pProps->nSHORT1;
1689  xField.reset(new SwDBNextSetField(static_cast<SwDBNextSetFieldType*>(pFieldType),
1690  m_pImpl->m_pProps->sPar3, aData));
1691  }
1692  break;
1694  {
1695  SwDBData aData;
1696  aData.sDataSource = m_pImpl->m_pProps->sPar1;
1697  aData.sCommand = m_pImpl->m_pProps->sPar2;
1698  aData.nCommandType = m_pImpl->m_pProps->nSHORT1;
1699  xField.reset(new SwDBNumSetField( static_cast<SwDBNumSetFieldType*>(
1701  m_pImpl->m_pProps->sPar3,
1702  OUString::number(m_pImpl->m_pProps->nFormat),
1703  aData ));
1704  }
1705  break;
1707  {
1708  SwDBData aData;
1709  aData.sDataSource = m_pImpl->m_pProps->sPar1;
1710  aData.sCommand = m_pImpl->m_pProps->sPar2;
1711  aData.nCommandType = m_pImpl->m_pProps->nSHORT1;
1712  SwDBSetNumberField *const pDBSNField =
1713  new SwDBSetNumberField(static_cast<SwDBSetNumberFieldType*>(
1715  m_pImpl->m_pProps->nUSHORT1);
1716  xField.reset(pDBSNField);
1717  pDBSNField->SetSetNumber(m_pImpl->m_pProps->nFormat);
1718  sal_uInt16 nSubType = xField->GetSubType();
1719  if (m_pImpl->m_pProps->bBool2)
1721  else
1723  xField->SetSubType(nSubType);
1724  }
1725  break;
1727  {
1728  SwFieldType* pFieldType =
1729  pDoc->getIDocumentFieldsAccess().GetFieldType(SwFieldIds::Database, m_pImpl->m_sTypeName, false);
1730  if (!pFieldType)
1731  throw uno::RuntimeException();
1732  xField.reset(new SwDBField(static_cast<SwDBFieldType*>(pFieldType),
1733  m_pImpl->m_pProps->nFormat));
1734  static_cast<SwDBField*>(xField.get())->InitContent(m_pImpl->m_pProps->sPar1);
1735  sal_uInt16 nSubType = xField->GetSubType();
1736  if (m_pImpl->m_pProps->bBool2)
1738  else
1740  xField->SetSubType(nSubType);
1741  }
1742  break;
1744  {
1745  SwFieldType* pFieldType =
1746  pDoc->getIDocumentFieldsAccess().GetFieldType(SwFieldIds::SetExp, m_pImpl->m_sTypeName, true);
1747  if (!pFieldType)
1748  throw uno::RuntimeException();
1749  // detect the field type's sub type and set an appropriate number format
1750  if (m_pImpl->m_pProps->bFormatIsDefault &&
1751  nsSwGetSetExpType::GSE_STRING == static_cast<SwSetExpFieldType*>(pFieldType)->GetType())
1752  {
1753  m_pImpl->m_pProps->nFormat = -1;
1754  }
1755  SwSetExpField *const pSEField = new SwSetExpField(
1756  static_cast<SwSetExpFieldType*>(pFieldType),
1757  m_pImpl->m_pProps->sPar2,
1758  m_pImpl->m_pProps->nUSHORT2 != USHRT_MAX ? //#i79471# the field can have a number format or a number_ing_ format
1759  m_pImpl->m_pProps->nUSHORT2 : m_pImpl->m_pProps->nFormat);
1760  xField.reset(pSEField);
1761 
1762  sal_uInt16 nSubType = xField->GetSubType();
1763  if (m_pImpl->m_pProps->bBool2)
1765  else
1767  if (m_pImpl->m_pProps->bBool3)
1768  nSubType |= nsSwExtendedSubType::SUB_CMD;
1769  else
1770  nSubType &= ~nsSwExtendedSubType::SUB_CMD;
1771  xField->SetSubType(nSubType);
1772  pSEField->SetSeqNumber(m_pImpl->m_pProps->nUSHORT1);
1773  pSEField->SetInputFlag(m_pImpl->m_pProps->bBool1);
1774  pSEField->SetPromptText(m_pImpl->m_pProps->sPar3);
1775  if (!m_pImpl->m_pProps->sPar4.isEmpty())
1776  pSEField->ChgExpStr(m_pImpl->m_pProps->sPar4, nullptr);
1777 
1778  }
1779  break;
1781  {
1782  sal_uInt16 nSubType;
1783  switch (m_pImpl->m_pProps->nSubType)
1784  {
1785  case text::SetVariableType::STRING: nSubType = nsSwGetSetExpType::GSE_STRING; break;
1786  case text::SetVariableType::VAR: nSubType = nsSwGetSetExpType::GSE_EXPR; break;
1787  //case text::SetVariableType::SEQUENCE: nSubType = nsSwGetSetExpType::GSE_SEQ; break;
1788  case text::SetVariableType::FORMULA: nSubType = nsSwGetSetExpType::GSE_FORMULA; break;
1789  default:
1790  OSL_FAIL("wrong value");
1791  nSubType = nsSwGetSetExpType::GSE_EXPR;
1792  }
1793  //make sure the SubType matches the field type
1794  SwFieldType* pSetExpField = pDoc->getIDocumentFieldsAccess().GetFieldType(
1795  SwFieldIds::SetExp, m_pImpl->m_pProps->sPar1, false);
1796  bool bSetGetExpFieldUninitialized = false;
1797  if (pSetExpField)
1798  {
1799  if (nSubType != nsSwGetSetExpType::GSE_STRING &&
1800  static_cast< SwSetExpFieldType* >(pSetExpField)->GetType() == nsSwGetSetExpType::GSE_STRING)
1801  nSubType = nsSwGetSetExpType::GSE_STRING;
1802  }
1803  else
1804  bSetGetExpFieldUninitialized = true; // #i82544#
1805 
1806  if (m_pImpl->m_pProps->bBool2)
1807  nSubType |= nsSwExtendedSubType::SUB_CMD;
1808  else
1809  nSubType &= ~nsSwExtendedSubType::SUB_CMD;
1810  SwGetExpField *const pGEField = new SwGetExpField(
1811  static_cast<SwGetExpFieldType*>(
1813  m_pImpl->m_pProps->sPar1, nSubType,
1814  m_pImpl->m_pProps->nFormat);
1815  xField.reset(pGEField);
1816  //TODO: evaluate SubType!
1817  if (!m_pImpl->m_pProps->sPar4.isEmpty())
1818  pGEField->ChgExpStr(m_pImpl->m_pProps->sPar4, nullptr);
1819  // #i82544#
1820  if (bSetGetExpFieldUninitialized)
1821  pGEField->SetLateInitialization();
1822  }
1823  break;
1826  {
1827  SwFieldType* pFieldType =
1828  pDoc->getIDocumentFieldsAccess().GetFieldType(SwFieldIds::Input, m_pImpl->m_sTypeName, true);
1829  if (!pFieldType)
1830  throw uno::RuntimeException();
1831  sal_uInt16 nInpSubType =
1832  sal::static_int_cast<sal_uInt16>(
1834  ? INP_USR : INP_TXT);
1835  SwInputField * pTextField =
1836  new SwInputField(static_cast<SwInputFieldType*>(pFieldType),
1837  m_pImpl->m_pProps->sPar1,
1838  m_pImpl->m_pProps->sPar2,
1839  nInpSubType);
1840  pTextField->SetHelp(m_pImpl->m_pProps->sPar3);
1841  pTextField->SetToolTip(m_pImpl->m_pProps->sPar4);
1842 
1843  xField.reset(pTextField);
1844  }
1845  break;
1847  {
1849  OUString aName;
1850 
1851  // support for Scripting Framework macros
1852  if (!m_pImpl->m_pProps->sPar4.isEmpty())
1853  {
1854  aName = m_pImpl->m_pProps->sPar4;
1855  }
1856  else
1857  {
1859  m_pImpl->m_pProps->sPar1, m_pImpl->m_pProps->sPar3);
1860  }
1861  xField.reset(new SwMacroField(static_cast<SwMacroFieldType*>(pFieldType), aName,
1862  m_pImpl->m_pProps->sPar2));
1863  }
1864  break;
1872  {
1873  sal_uInt16 nSubType = DS_PAGE;
1874  switch (m_pImpl->m_nServiceId)
1875  {
1876  case SwServiceType::FieldTypeParagraphCount : nSubType = DS_PARA; break;
1877  case SwServiceType::FieldTypeWordCount : nSubType = DS_WORD; break;
1878  case SwServiceType::FieldTypeCharacterCount : nSubType = DS_CHAR; break;
1879  case SwServiceType::FieldTypeTableCount : nSubType = DS_TBL; break;
1880  case SwServiceType::FieldTypeGraphicObjectCount : nSubType = DS_GRF; break;
1881  case SwServiceType::FieldTypeEmbeddedObjectCount : nSubType = DS_OLE; break;
1882  default: break;
1883  }
1885  xField.reset(new SwDocStatField(
1886  static_cast<SwDocStatFieldType*>(pFieldType),
1887  nSubType, m_pImpl->m_pProps->nUSHORT2));
1888  }
1889  break;
1891  {
1892  SwAuthorityFieldType const type(pDoc);
1893  xField.reset(new SwAuthorityField(static_cast<SwAuthorityFieldType*>(
1895  OUString()));
1896  if (m_pImpl->m_pProps->aPropSeq.hasElements())
1897  {
1898  uno::Any aVal;
1899  aVal <<= m_pImpl->m_pProps->aPropSeq;
1900  xField->PutValue( aVal, FIELD_PROP_PROP_SEQ );
1901  }
1902  }
1903  break;
1905  // create field
1906  xField.reset(new SwCombinedCharField( static_cast<SwCombinedCharFieldType*>(
1908  m_pImpl->m_pProps->sPar1));
1909  break;
1911  {
1912  SwDropDownField *const pDDField = new SwDropDownField(
1913  static_cast<SwDropDownFieldType *>(
1915  xField.reset(pDDField);
1916 
1917  pDDField->SetItems(m_pImpl->m_pProps->aStrings);
1918  pDDField->SetSelectedItem(m_pImpl->m_pProps->sPar1);
1919  pDDField->SetName(m_pImpl->m_pProps->sPar2);
1920  pDDField->SetHelp(m_pImpl->m_pProps->sPar3);
1921  pDDField->SetToolTip(m_pImpl->m_pProps->sPar4);
1922  }
1923  break;
1924 
1926  {
1927  // create field
1929  if (m_pImpl->m_pProps->bBool1)
1930  {
1932  if (m_pImpl->m_pProps->bFormatIsDefault)
1933  m_pImpl->m_pProps->nFormat = -1;
1934  }
1935  xField.reset(new SwTableField( static_cast<SwTableFieldType*>(
1937  m_pImpl->m_pProps->sPar2,
1938  nType,
1939  m_pImpl->m_pProps->nFormat));
1940  static_cast<SwTableField*>(xField.get())->ChgExpStr(m_pImpl->m_pProps->sPar1);
1941  }
1942  break;
1943  default: OSL_FAIL("What kind of type is that?");
1944  }
1945 
1946  if (!xField)
1947  throw uno::RuntimeException("no SwField created?");
1948 
1949  xField->SetAutomaticLanguage(!m_pImpl->m_pProps->bBool4);
1950  SwFormatField aFormat(*xField);
1951 
1952  UnoActionContext aCont(pDoc);
1953  if (aPam.HasMark() &&
1955  {
1957  }
1958 
1959  SwXTextCursor const*const pTextCursor(dynamic_cast<SwXTextCursor*>(pCursor));
1960  const bool bForceExpandHints(
1961  pTextCursor
1962  && pTextCursor->IsAtEndOfMeta() );
1963  const SetAttrMode nInsertFlags =
1964  bForceExpandHints
1967 
1968  if (*aPam.GetPoint() != *aPam.GetMark() &&
1970  {
1971  // Make sure we always insert the field at the end
1972  SwPaM aEnd(*aPam.End(), *aPam.End());
1973  pDoc->getIDocumentContentOperations().InsertPoolItem(aEnd, aFormat, nInsertFlags);
1974  }
1975  else
1976  pDoc->getIDocumentContentOperations().InsertPoolItem(aPam, aFormat, nInsertFlags);
1977 
1978  SwTextAttr* pTextAttr = aPam.GetNode().GetTextNode()->GetFieldTextAttrAt( aPam.GetPoint()->nContent.GetIndex()-1, true );
1979 
1980  // What about updating the fields? (see fldmgr.cxx)
1981  if (!pTextAttr)
1982  throw uno::RuntimeException("no SwTextAttr inserted?"); // could theoretically happen, if paragraph is full
1983 
1984  const SwFormatField& rField = pTextAttr->GetFormatField();
1985  m_pImpl->SetFormatField(const_cast<SwFormatField*>(&rField), pDoc);
1986 
1987  if ( pTextAttr->Which() == RES_TXTATR_ANNOTATION
1988  && *aPam.GetPoint() != *aPam.GetMark() )
1989  {
1990  // create annotation mark
1991  const SwPostItField* pPostItField = dynamic_cast< const SwPostItField* >(pTextAttr->GetFormatField().GetField());
1992  OSL_ENSURE( pPostItField != nullptr, "<SwXTextField::attachToRange(..)> - annotation field missing!" );
1993  if ( pPostItField != nullptr )
1994  {
1995  IDocumentMarkAccess* pMarksAccess = pDoc->getIDocumentMarkAccess();
1996  pMarksAccess->makeAnnotationMark( aPam, pPostItField->GetName() );
1997  }
1998  }
1999 
2000  xField.reset();
2001 
2002  assert(m_pImpl->GetFormatField());
2003  m_pImpl->m_pDoc = pDoc;
2004  m_pImpl->GetFormatField()->SetXTextField(this);
2005  m_pImpl->m_wThis = *this;
2006  m_pImpl->m_bIsDescriptor = false;
2007  m_pImpl->ClearFieldType();
2008  m_pImpl->m_pProps.reset();
2009  if (m_pImpl->m_bCallUpdate)
2010  update();
2011  }
2012  else if ( !m_pImpl->IsDescriptor()
2013  && m_pImpl->m_pDoc != nullptr
2014  && m_pImpl->m_nServiceId == SwServiceType::FieldTypeAnnotation )
2015  {
2016  SwUnoInternalPaM aIntPam( *m_pImpl->m_pDoc );
2017  if ( !::sw::XTextRangeToSwPaM( aIntPam, xTextRange ) )
2018  throw lang::IllegalArgumentException();
2019 
2020  // Nothing to do, if the text range has a separate start and end, but they have the same
2021  // value.
2022  if (!aIntPam.HasMark() || *aIntPam.Start() != *aIntPam.End())
2023  {
2024  UnoActionContext aCont( m_pImpl->m_pDoc );
2025  // insert copy of annotation at new text range
2026  std::unique_ptr<SwPostItField> pPostItField(static_cast< SwPostItField* >(m_pImpl->GetFormatField()->GetField()->CopyField().release()));
2027  SwFormatField aFormatField( *pPostItField );
2028  pPostItField.reset();
2029  SwPaM aEnd( *aIntPam.End(), *aIntPam.End() );
2030  m_pImpl->m_pDoc->getIDocumentContentOperations().InsertPoolItem( aEnd, aFormatField );
2031  // delete former annotation
2032  {
2033  const SwTextField* pTextField = m_pImpl->GetFormatField()->GetTextField();
2034  SwTextNode& rTextNode = *pTextField->GetpTextNode();
2035  SwPaM aPam( rTextNode, pTextField->GetStart() );
2036  aPam.SetMark();
2037  aPam.Move();
2038  m_pImpl->m_pDoc->getIDocumentContentOperations().DeleteAndJoin(aPam);
2039  }
2040  // keep inserted annotation
2041  {
2042  SwTextField* pTextAttr = aEnd.GetNode().GetTextNode()->GetFieldTextAttrAt( aEnd.End()->nContent.GetIndex()-1, true );
2043  if ( pTextAttr != nullptr )
2044  {
2045  m_pImpl->SetFormatField(const_cast<SwFormatField*>(&pTextAttr->GetFormatField()), m_pImpl->m_pDoc);
2046 
2047  if ( *aIntPam.GetPoint() != *aIntPam.GetMark() )
2048  {
2049  // create annotation mark
2050  const SwPostItField* pField = dynamic_cast< const SwPostItField* >(pTextAttr->GetFormatField().GetField());
2051  OSL_ENSURE( pField != nullptr, "<SwXTextField::attach(..)> - annotation field missing!" );
2052  if ( pField != nullptr )
2053  {
2054  IDocumentMarkAccess* pMarksAccess = aIntPam.GetDoc().getIDocumentMarkAccess();
2055  pMarksAccess->makeAnnotationMark( aIntPam, pField->GetName() );
2056  }
2057  }
2058  }
2059  }
2060  }
2061 
2062  }
2063  else
2064  throw lang::IllegalArgumentException();
2065 }
2066 
2067 uno::Reference< text::XTextRange > SAL_CALL
2069 {
2070  SolarMutexGuard aGuard;
2071 
2072  SwField const*const pField = m_pImpl->GetField();
2073  if (!pField)
2074  return nullptr;
2075 
2076  const SwTextField* pTextField = m_pImpl->GetFormatField()->GetTextField();
2077  if (!pTextField)
2078  throw uno::RuntimeException();
2079 
2080  std::shared_ptr< SwPaM > pPamForTextField;
2081  SwTextField::GetPamForTextField(*pTextField, pPamForTextField);
2082  if (pPamForTextField == nullptr)
2083  return nullptr;
2084 
2085  // If this is a postit field, then return the range of its annotation mark if it has one.
2086  if (pField->Which() == SwFieldIds::Postit)
2087  {
2088  const SwPostItField* pPostItField = static_cast<const SwPostItField*>(pField);
2089  IDocumentMarkAccess* pMarkAccess = m_pImpl->m_pDoc->getIDocumentMarkAccess();
2090  for (IDocumentMarkAccess::const_iterator_t ppMark = pMarkAccess->getAnnotationMarksBegin(); ppMark != pMarkAccess->getAnnotationMarksEnd(); ++ppMark)
2091  {
2092  if ((*ppMark)->GetName() == pPostItField->GetName())
2093  {
2094  pPamForTextField = std::make_shared<SwPaM>((*ppMark)->GetMarkStart(), (*ppMark)->GetMarkEnd());
2095  break;
2096  }
2097  }
2098  }
2099 
2100  uno::Reference<text::XTextRange> xRange = SwXTextRange::CreateXTextRange(
2101  *m_pImpl->m_pDoc, *(pPamForTextField->GetPoint()), pPamForTextField->GetMark());
2102  return xRange;
2103 }
2104 
2105 void SAL_CALL SwXTextField::dispose()
2106 {
2107  SolarMutexGuard aGuard;
2108  SwField const*const pField = m_pImpl->GetField();
2109  if(pField && m_pImpl->m_pDoc)
2110  {
2111  UnoActionContext aContext(m_pImpl->m_pDoc);
2112  assert(m_pImpl->GetFormatField()->GetTextField() && "<SwXTextField::dispose()> - missing <SwTextField> --> crash");
2113  SwTextField::DeleteTextField(*(m_pImpl->GetFormatField()->GetTextField()));
2114  }
2115 
2116  if (m_pImpl->m_xTextObject.is())
2117  {
2118  m_pImpl->m_xTextObject->DisposeEditSource();
2119  m_pImpl->m_xTextObject.clear();
2120  }
2121  m_pImpl->Invalidate();
2122 }
2123 
2125  const uno::Reference<lang::XEventListener> & xListener)
2126 {
2127  // no need to lock here as m_pImpl is const and container threadsafe
2128  m_pImpl->m_EventListeners.addInterface(xListener);
2129 }
2130 
2132  const uno::Reference<lang::XEventListener> & xListener)
2133 {
2134  // no need to lock here as m_pImpl is const and container threadsafe
2135  m_pImpl->m_EventListeners.removeInterface(xListener);
2136 }
2137 
2138 uno::Reference< beans::XPropertySetInfo > SAL_CALL
2140 {
2141  SolarMutexGuard aGuard;
2142  // no static
2143  uno::Reference< beans::XPropertySetInfo > aRef;
2144  if (m_pImpl->m_nServiceId == SwServiceType::Invalid)
2145  {
2146  throw uno::RuntimeException();
2147  }
2149  lcl_GetPropertyMapOfService(m_pImpl->m_nServiceId));
2150  const uno::Reference<beans::XPropertySetInfo>& xInfo = pPropSet->getPropertySetInfo();
2151  // extend PropertySetInfo!
2152  const uno::Sequence<beans::Property> aPropSeq = xInfo->getProperties();
2153  aRef = new SfxExtItemPropertySetInfo(
2155  aPropSeq );
2156  return aRef;
2157 }
2158 
2159 void SAL_CALL
2161  const OUString& rPropertyName, const uno::Any& rValue)
2162 {
2163  SolarMutexGuard aGuard;
2164  SwField const*const pField = m_pImpl->GetField();
2166  lcl_GetPropertyMapOfService(m_pImpl->m_nServiceId));
2167  const SfxItemPropertyMapEntry* pEntry = _pPropSet->getPropertyMap().getByName(rPropertyName);
2168 
2169  if (!pEntry)
2170  throw beans::UnknownPropertyException( "Unknown property: " + rPropertyName, static_cast < cppu::OWeakObject * > ( this ) );
2171  if ( pEntry->nFlags & beans::PropertyAttribute::READONLY)
2172  throw beans::PropertyVetoException( "Property is read-only: " + rPropertyName, static_cast < cppu::OWeakObject * > ( this ) );
2173 
2174  if(pField)
2175  {
2176  // special treatment for mail merge fields
2177  const SwFieldIds nWhich = pField->Which();
2178  if( SwFieldIds::Database == nWhich &&
2179  (rPropertyName == UNO_NAME_DATA_BASE_NAME ||
2180  rPropertyName == UNO_NAME_DATA_BASE_URL||
2181  rPropertyName == UNO_NAME_DATA_TABLE_NAME||
2182  rPropertyName == UNO_NAME_DATA_COLUMN_NAME))
2183  {
2184  // here a new field type must be created and the field must
2185  // be registered at the new type
2186  OSL_FAIL("not implemented");
2187  }
2188  else
2189  {
2190  SwDoc * pDoc = m_pImpl->m_pDoc;
2191  assert(pDoc);
2192  const SwTextField* pTextField = m_pImpl->GetFormatField()->GetTextField();
2193  if(!pTextField)
2194  throw uno::RuntimeException();
2195  SwPosition aPosition( pTextField->GetTextNode() );
2196  aPosition.nContent = pTextField->GetStart();
2197  pDoc->getIDocumentFieldsAccess().PutValueToField( aPosition, rValue, pEntry->nWID);
2198  }
2199 
2200  //#i100374# notify SwPostIt about new field content
2201  assert(m_pImpl->GetFormatField());
2202  if (SwFieldIds::Postit == nWhich)
2203  {
2204  m_pImpl->GetFormatField()->Broadcast(
2206  }
2207 
2208  // fdo#42073 notify SwTextField about changes of the expanded string
2209  if (m_pImpl->GetFormatField()->GetTextField())
2210  {
2211  m_pImpl->GetFormatField()->GetTextField()->ExpandTextField();
2212  }
2213 
2214  //#i100374# changing a document field should set the modify flag
2215  SwDoc* pDoc = m_pImpl->m_pDoc;
2216  if (pDoc)
2217  pDoc->getIDocumentState().SetModified();
2218 
2219  }
2220  else if (m_pImpl->m_pProps)
2221  {
2222  bool* pBool = nullptr;
2223  switch(pEntry->nWID)
2224  {
2225  case FIELD_PROP_PAR1:
2226  rValue >>= m_pImpl->m_pProps->sPar1;
2227  break;
2228  case FIELD_PROP_PAR2:
2229  rValue >>= m_pImpl->m_pProps->sPar2;
2230  break;
2231  case FIELD_PROP_PAR3:
2232  rValue >>= m_pImpl->m_pProps->sPar3;
2233  break;
2234  case FIELD_PROP_PAR4:
2235  rValue >>= m_pImpl->m_pProps->sPar4;
2236  break;
2237  case FIELD_PROP_FORMAT:
2238  rValue >>= m_pImpl->m_pProps->nFormat;
2239  m_pImpl->m_pProps->bFormatIsDefault = false;
2240  break;
2241  case FIELD_PROP_SUBTYPE:
2242  m_pImpl->m_pProps->nSubType = SWUnoHelper::GetEnumAsInt32(rValue);
2243  break;
2244  case FIELD_PROP_BYTE1 :
2245  rValue >>= m_pImpl->m_pProps->nByte1;
2246  break;
2247  case FIELD_PROP_BOOL1 :
2248  pBool = &m_pImpl->m_pProps->bBool1;
2249  break;
2250  case FIELD_PROP_BOOL2 :
2251  pBool = &m_pImpl->m_pProps->bBool2;
2252  break;
2253  case FIELD_PROP_BOOL3 :
2254  pBool = &m_pImpl->m_pProps->bBool3;
2255  break;
2256  case FIELD_PROP_BOOL4:
2257  pBool = &m_pImpl->m_pProps->bBool4;
2258  break;
2259  case FIELD_PROP_DATE :
2260  {
2261  auto aTemp = o3tl::tryAccess<util::Date>(rValue);
2262  if(!aTemp)
2263  throw lang::IllegalArgumentException();
2264 
2265  m_pImpl->m_pProps->aDate = Date(aTemp->Day, aTemp->Month, aTemp->Year);
2266  }
2267  break;
2268  case FIELD_PROP_USHORT1:
2269  case FIELD_PROP_USHORT2:
2270  {
2271  sal_Int16 nVal = 0;
2272  rValue >>= nVal;
2273  if( FIELD_PROP_USHORT1 == pEntry->nWID)
2274  m_pImpl->m_pProps->nUSHORT1 = nVal;
2275  else
2276  m_pImpl->m_pProps->nUSHORT2 = nVal;
2277  }
2278  break;
2279  case FIELD_PROP_SHORT1:
2280  rValue >>= m_pImpl->m_pProps->nSHORT1;
2281  break;
2282  case FIELD_PROP_DOUBLE:
2283  if(rValue.getValueType() != ::cppu::UnoType<double>::get())
2284  throw lang::IllegalArgumentException();
2285  rValue >>= m_pImpl->m_pProps->fDouble;
2286  break;
2287 
2288  case FIELD_PROP_DATE_TIME :
2289  if (!m_pImpl->m_pProps->pDateTime)
2290  m_pImpl->m_pProps->pDateTime.reset( new util::DateTime );
2291  rValue >>= *m_pImpl->m_pProps->pDateTime;
2292  break;
2293  case FIELD_PROP_PROP_SEQ:
2294  rValue >>= m_pImpl->m_pProps->aPropSeq;
2295  break;
2296  case FIELD_PROP_STRINGS:
2297  rValue >>= m_pImpl->m_pProps->aStrings;
2298  break;
2299  }
2300  if (pBool)
2301  {
2302  auto b = o3tl::tryAccess<bool>(rValue);
2303  if( !b )
2304  throw lang::IllegalArgumentException();
2305  *pBool = *b;
2306 
2307  }
2308  }
2309  else
2310  throw uno::RuntimeException();
2311 }
2312 
2313 uno::Any SAL_CALL SwXTextField::getPropertyValue(const OUString& rPropertyName)
2314 {
2315  SolarMutexGuard aGuard;
2316  uno::Any aRet;
2317  SwField const*const pField = m_pImpl->GetField();
2319  lcl_GetPropertyMapOfService(m_pImpl->m_nServiceId));
2320  const SfxItemPropertyMapEntry* pEntry = _pPropSet->getPropertyMap().getByName(rPropertyName);
2321  if(!pEntry )
2322  {
2324  pEntry = _pParaPropSet->getPropertyMap().getByName(rPropertyName);
2325  }
2326  if (!pEntry)
2327  throw beans::UnknownPropertyException( "Unknown property: " + rPropertyName, static_cast < cppu::OWeakObject * > ( this ) );
2328 
2329  switch( pEntry->nWID )
2330  {
2331  case FN_UNO_TEXT_WRAP:
2332  aRet <<= text::WrapTextMode_NONE;
2333  break;
2334  case FN_UNO_ANCHOR_TYPE:
2335  aRet <<= text::TextContentAnchorType_AS_CHARACTER;
2336  break;
2337  case FN_UNO_ANCHOR_TYPES:
2338  {
2339  uno::Sequence<text::TextContentAnchorType> aTypes { text::TextContentAnchorType_AS_CHARACTER };
2340  aRet <<= aTypes;
2341  }
2342  break;
2343 
2344  default:
2345  if( pField )
2346  {
2347  if (FIELD_PROP_IS_FIELD_USED == pEntry->nWID ||
2349  {
2350  bool bIsFieldUsed = false;
2351  bool bIsFieldDisplayed = false;
2352 
2353  // in order to have the information about fields
2354  // correctly evaluated the document needs a layout
2355  // (has to be already formatted)
2356  SwDoc *pDoc = m_pImpl->m_pDoc;
2357  SwViewShell *pViewShell = nullptr;
2358  SwEditShell *pEditShell = nullptr;
2359  if( pDoc )
2360  {
2361  pViewShell = pDoc->getIDocumentLayoutAccess().GetCurrentViewShell();
2362  pEditShell = pDoc->GetEditShell();
2363  }
2364 
2365  if (pEditShell)
2366  pEditShell->CalcLayout();
2367  else if (pViewShell) // a page preview has no SwEditShell it should only have a view shell
2368  pViewShell->CalcLayout();
2369  else
2370  throw uno::RuntimeException();
2371 
2372  // get text node for the text field
2373  const SwFormatField *pFieldFormat =
2374  (m_pImpl->GetField()) ? m_pImpl->GetFormatField() : nullptr;
2375  const SwTextField* pTextField = pFieldFormat
2376  ? m_pImpl->GetFormatField()->GetTextField() : nullptr;
2377  if(!pTextField)
2378  throw uno::RuntimeException();
2379  const SwTextNode& rTextNode = pTextField->GetTextNode();
2380 
2381  // skip fields that are currently not in the document
2382  // e.g. fields in undo or redo array
2383  if (rTextNode.GetNodes().IsDocNodes())
2384  {
2385  bool bFrame = 0 != rTextNode.FindLayoutRect().Width(); // or so
2386  bool bHidden = rTextNode.IsHidden();
2387  if ( !bHidden )
2388  {
2389  sal_Int32 nHiddenStart;
2390  sal_Int32 nHiddenEnd;
2391  bHidden = SwScriptInfo::GetBoundsOfHiddenRange( pTextField->GetTextNode(),
2392  pTextField->GetStart(),
2393  nHiddenStart, nHiddenEnd );
2394  }
2395 
2396  // !bFrame && !bHidden: most probably a field in an unused page style
2397 
2398  // FME: Problem: hidden field in unused page template =>
2399  // bIsFieldUsed = true
2400  // bIsFieldDisplayed = false
2401  bIsFieldUsed = bFrame || bHidden;
2402  bIsFieldDisplayed = bIsFieldUsed && !bHidden;
2403  }
2404  aRet <<= (FIELD_PROP_IS_FIELD_USED == pEntry->nWID) ? bIsFieldUsed : bIsFieldDisplayed;
2405  }
2406  else
2407  pField->QueryValue( aRet, pEntry->nWID );
2408  }
2409  else if (m_pImpl->m_pProps) // currently just a descriptor...
2410  {
2411  switch(pEntry->nWID)
2412  {
2413  case FIELD_PROP_TEXT:
2414  {
2415  if (!m_pImpl->m_xTextObject.is())
2416  {
2417  m_pImpl->m_xTextObject
2418  = new SwTextAPIObject( std::make_unique<SwTextAPIEditSource>(m_pImpl->m_pDoc) );
2419  }
2420 
2421  uno::Reference<text::XText> xText(m_pImpl->m_xTextObject);
2422  aRet <<= xText;
2423  break;
2424  }
2425  case FIELD_PROP_PAR1:
2426  aRet <<= m_pImpl->m_pProps->sPar1;
2427  break;
2428  case FIELD_PROP_PAR2:
2429  aRet <<= m_pImpl->m_pProps->sPar2;
2430  break;
2431  case FIELD_PROP_PAR3:
2432  aRet <<= m_pImpl->m_pProps->sPar3;
2433  break;
2434  case FIELD_PROP_PAR4:
2435  aRet <<= m_pImpl->m_pProps->sPar4;
2436  break;
2437  case FIELD_PROP_FORMAT:
2438  aRet <<= m_pImpl->m_pProps->nFormat;
2439  break;
2440  case FIELD_PROP_SUBTYPE:
2441  aRet <<= m_pImpl->m_pProps->nSubType;
2442  break;
2443  case FIELD_PROP_BYTE1 :
2444  aRet <<= m_pImpl->m_pProps->nByte1;
2445  break;
2446  case FIELD_PROP_BOOL1 :
2447  aRet <<= m_pImpl->m_pProps->bBool1;
2448  break;
2449  case FIELD_PROP_BOOL2 :
2450  aRet <<= m_pImpl->m_pProps->bBool2;
2451  break;
2452  case FIELD_PROP_BOOL3 :
2453  aRet <<= m_pImpl->m_pProps->bBool3;
2454  break;
2455  case FIELD_PROP_BOOL4 :
2456  aRet <<= m_pImpl->m_pProps->bBool4;
2457  break;
2458  case FIELD_PROP_DATE :
2459  aRet <<= m_pImpl->m_pProps->aDate.GetUNODate();
2460  break;
2461  case FIELD_PROP_USHORT1:
2462  aRet <<= static_cast<sal_Int16>(m_pImpl->m_pProps->nUSHORT1);
2463  break;
2464  case FIELD_PROP_USHORT2:
2465  aRet <<= static_cast<sal_Int16>(m_pImpl->m_pProps->nUSHORT2);
2466  break;
2467  case FIELD_PROP_SHORT1:
2468  aRet <<= m_pImpl->m_pProps->nSHORT1;
2469  break;
2470  case FIELD_PROP_DOUBLE:
2471  aRet <<= m_pImpl->m_pProps->fDouble;
2472  break;
2473  case FIELD_PROP_DATE_TIME :
2474  if (m_pImpl->m_pProps->pDateTime)
2475  aRet <<= *m_pImpl->m_pProps->pDateTime;
2476  break;
2477  case FIELD_PROP_PROP_SEQ:
2478  aRet <<= m_pImpl->m_pProps->aPropSeq;
2479  break;
2480  case FIELD_PROP_STRINGS:
2481  aRet <<= m_pImpl->m_pProps->aStrings;
2482  break;
2485  aRet <<= false;
2486  break;
2487  }
2488  }
2489  else
2490  throw uno::RuntimeException();
2491  }
2492  return aRet;
2493 }
2494 
2495 void SwXTextField::addPropertyChangeListener(const OUString& /*PropertyName*/, const uno::Reference< beans::XPropertyChangeListener > & /*aListener*/)
2496 {
2497  OSL_FAIL("not implemented");
2498 }
2499 
2500 void SwXTextField::removePropertyChangeListener(const OUString& /*PropertyName*/, const uno::Reference< beans::XPropertyChangeListener > & /*aListener*/)
2501 {
2502  OSL_FAIL("not implemented");
2503 }
2504 
2505 void SwXTextField::addVetoableChangeListener(const OUString& /*PropertyName*/, const uno::Reference< beans::XVetoableChangeListener > & /*aListener*/)
2506 {
2507  OSL_FAIL("not implemented");
2508 }
2509 
2510 void SwXTextField::removeVetoableChangeListener(const OUString& /*PropertyName*/, const uno::Reference< beans::XVetoableChangeListener > & /*aListener*/)
2511 {
2512  OSL_FAIL("not implemented");
2513 }
2514 
2515 void SAL_CALL SwXTextField::update()
2516 {
2517  SolarMutexGuard aGuard;
2518  SwField * pField = const_cast<SwField*>(m_pImpl->GetField());
2519  if (pField)
2520  {
2521  switch(pField->Which())
2522  {
2523  case SwFieldIds::DateTime:
2524  static_cast<SwDateTimeField*>(pField)->SetDateTime( ::DateTime( ::DateTime::SYSTEM ) );
2525  break;
2526 
2527  case SwFieldIds::ExtUser:
2528  {
2529  SwExtUserField* pExtUserField = static_cast<SwExtUserField*>(pField);
2530  pExtUserField->SetExpansion( SwExtUserFieldType::Expand(
2531  pExtUserField->GetSubType() ) );
2532  }
2533  break;
2534 
2535  case SwFieldIds::Author:
2536  {
2537  SwAuthorField* pAuthorField = static_cast<SwAuthorField*>(pField);
2538  pAuthorField->SetExpansion( SwAuthorFieldType::Expand(
2539  pAuthorField->GetFormat() ) );
2540  }
2541  break;
2542 
2543  case SwFieldIds::Filename:
2544  {
2545  SwFileNameField* pFileNameField = static_cast<SwFileNameField*>(pField);
2546  pFileNameField->SetExpansion( static_cast<SwFileNameFieldType*>(pField->GetTyp())->Expand(
2547  pFileNameField->GetFormat() ) );
2548  }
2549  break;
2550 
2551  case SwFieldIds::DocInfo:
2552  {
2553  SwDocInfoField* pDocInfField = static_cast<SwDocInfoField*>(pField);
2554  pDocInfField->SetExpansion( static_cast<SwDocInfoFieldType*>(pField->GetTyp())->Expand(
2555  pDocInfField->GetSubType(),
2556  pDocInfField->GetFormat(),
2557  pDocInfField->GetLanguage(),
2558  pDocInfField->GetName() ) );
2559  }
2560  break;
2561  default: break;
2562  }
2563  // Text formatting has to be triggered.
2564  m_pImpl->GetFormatField()->UpdateTextNode(nullptr, nullptr);
2565  }
2566  else
2567  m_pImpl->m_bCallUpdate = true;
2568 }
2569 
2571 {
2572  return "SwXTextField";
2573 }
2574 
2575 static OUString OldNameToNewName_Impl( const OUString &rOld )
2576 {
2577  static const char aOldNamePart1[] = ".TextField.DocInfo.";
2578  static const char aOldNamePart2[] = ".TextField.";
2579  OUString sServiceNameCC( rOld );
2580  sal_Int32 nIdx = sServiceNameCC.indexOf( aOldNamePart1 );
2581  if (nIdx >= 0)
2582  sServiceNameCC = sServiceNameCC.replaceAt( nIdx, strlen(aOldNamePart1), ".textfield.docinfo." );
2583  nIdx = sServiceNameCC.indexOf( aOldNamePart2 );
2584  if (nIdx >= 0)
2585  sServiceNameCC = sServiceNameCC.replaceAt( nIdx, strlen(aOldNamePart2), ".textfield." );
2586  return sServiceNameCC;
2587 }
2588 
2589 sal_Bool SAL_CALL SwXTextField::supportsService(const OUString& rServiceName)
2590 {
2591  return cppu::supportsService(this, rServiceName);
2592 }
2593 
2594 uno::Sequence< OUString > SAL_CALL SwXTextField::getSupportedServiceNames()
2595 {
2596  const OUString sServiceName =
2598 
2599  // case-corrected version of service-name (see #i67811)
2600  // (need to supply both because of compatibility to older versions)
2601  const OUString sServiceNameCC( OldNameToNewName_Impl( sServiceName ) );
2602  sal_Int32 nLen = sServiceName == sServiceNameCC ? 2 : 3;
2603 
2604  uno::Sequence< OUString > aRet( nLen );
2605  OUString* pArray = aRet.getArray();
2606  *pArray++ = sServiceName;
2607  if (nLen == 3)
2608  *pArray++ = sServiceNameCC;
2609  *pArray++ = "com.sun.star.text.TextContent";
2610  return aRet;
2611 }
2612 
2614 {
2615  EndListeningAll();
2616  m_pFormatField = nullptr;
2617  m_pDoc = nullptr;
2618  uno::Reference<uno::XInterface> const xThis(m_wThis);
2619  if (!xThis.is())
2620  { // fdo#72695: if UNO object is already dead, don't revive it with event
2621  return;
2622  }
2623  lang::EventObject const ev(xThis);
2625 }
2626 
2628 {
2629 
2630  if(rHint.GetId() == SfxHintId::Dying)
2631  Invalidate();
2632  else if (rHint.GetId() == SfxHintId::SwLegacyModify)
2633  {
2634  auto pLegacyHint = static_cast<const sw::LegacyModifyHint*>(&rHint);
2635  switch(pLegacyHint->m_pOld ? pLegacyHint->m_pOld->Which() : 0)
2636  {
2637  case RES_REMOVE_UNO_OBJECT:
2638  case RES_OBJECTDYING:
2639  Invalidate();
2640  break;
2641  }
2642  }
2643 }
2644 
2646 {
2647  return m_pFormatField ? m_pFormatField->GetField() : nullptr;
2648 }
2649 
2651 {
2652  return "SwXTextFieldMasters";
2653 }
2654 
2655 sal_Bool SwXTextFieldMasters::supportsService(const OUString& rServiceName)
2656 {
2657  return cppu::supportsService(this, rServiceName);
2658 }
2659 
2661 {
2662  uno::Sequence<OUString> aRet { "com.sun.star.text.TextFieldMasters" };
2663  return aRet;
2664 }
2665 
2667  SwUnoCollection(_pDoc)
2668 {
2669 }
2670 
2672 {
2673 
2674 }
2675 
2676 /*
2677  Iteration over non-standard field types
2678  USER/SETEXP/DDE/DATABASE
2679  Thus the names are:
2680  "com.sun.star.text.fieldmaster.User" + <field type name>
2681  "com.sun.star.text.fieldmaster.DDE" + <field type name>
2682  "com.sun.star.text.fieldmaster.SetExpression" + <field type name>
2683  "com.sun.star.text.fieldmaster.DataBase" + <field type name>
2684 
2685  If too much, maybe one could leave out the "com.sun.star.text".
2686  */
2687 static SwFieldIds lcl_GetIdByName( OUString& rName, OUString& rTypeName )
2688 {
2689  if (rName.startsWithIgnoreAsciiCase(COM_TEXT_FLDMASTER_CC))
2690  rName = rName.copy(RTL_CONSTASCII_LENGTH(COM_TEXT_FLDMASTER_CC));
2691 
2693  sal_Int32 nIdx = 0;
2694  rTypeName = rName.getToken( 0, '.', nIdx );
2695  if (rTypeName == "User")
2696  nResId = SwFieldIds::User;
2697  else if (rTypeName == "DDE")
2698  nResId = SwFieldIds::Dde;
2699  else if (rTypeName == "SetExpression")
2700  {
2701  nResId = SwFieldIds::SetExp;
2702 
2703  const OUString sFieldTypName( rName.getToken( 0, '.', nIdx ));
2704  const OUString sUIName( SwStyleNameMapper::GetSpecialExtraUIName( sFieldTypName ) );
2705 
2706  if( sUIName != sFieldTypName )
2707  rName = comphelper::string::setToken(rName, 1, '.', sUIName);
2708  }
2709  else if (rTypeName.equalsIgnoreAsciiCase("DataBase"))
2710  {
2711  rName = rName.copy(RTL_CONSTASCII_LENGTH("DataBase."));
2712  if (!rName.isEmpty())
2713  {
2714  // #i51815#
2715  rName = "DataBase." + rName;
2716  nResId = SwFieldIds::Database;
2717  }
2718  }
2719  else if (rTypeName == "Bibliography")
2721  return nResId;
2722 }
2723 
2725 {
2726  SolarMutexGuard aGuard;
2727  if(!GetDoc())
2728  throw uno::RuntimeException();
2729 
2730  OUString sName(rName), sTypeName;
2731  const SwFieldIds nResId = lcl_GetIdByName( sName, sTypeName );
2732  if( SwFieldIds::Unknown == nResId )
2733  throw container::NoSuchElementException(
2734  "SwXTextFieldMasters::getByName(" + rName + ")",
2735  css::uno::Reference<css::uno::XInterface>());
2736 
2737  sName = sName.copy(std::min(sTypeName.getLength()+1, sName.getLength()));
2738  SwFieldType* pType = GetDoc()->getIDocumentFieldsAccess().GetFieldType(nResId, sName, true);
2739  if(!pType)
2740  throw container::NoSuchElementException(
2741  "SwXTextFieldMasters::getByName(" + rName + ")",
2742  css::uno::Reference<css::uno::XInterface>());
2743 
2744  uno::Reference<beans::XPropertySet> const xRet(
2746  return uno::makeAny(xRet);
2747 }
2748 
2750  const SwFieldType& rFieldType, OUString& rName)
2751 {
2752  OUString sField;
2753 
2754  switch( rFieldType.Which() )
2755  {
2756  case SwFieldIds::User:
2757  sField = "User." + rFieldType.GetName();
2758  break;
2759  case SwFieldIds::Dde:
2760  sField = "DDE." + rFieldType.GetName();
2761  break;
2762 
2763  case SwFieldIds::SetExp:
2764  sField = "SetExpression." + SwStyleNameMapper::GetSpecialExtraProgName( rFieldType.GetName() );
2765  break;
2766 
2767  case SwFieldIds::Database:
2768  sField = "DataBase." + rFieldType.GetName().replaceAll(OUStringChar(DB_DELIM), ".");
2769  break;
2770 
2772  sField = "Bibliography";
2773  break;
2774 
2775  default:
2776  return false;
2777  }
2778 
2779  rName += COM_TEXT_FLDMASTER_CC + sField;
2780  return true;
2781 }
2782 
2783 uno::Sequence< OUString > SwXTextFieldMasters::getElementNames()
2784 {
2785  SolarMutexGuard aGuard;
2786  if(!GetDoc())
2787  throw uno::RuntimeException();
2788 
2789  const SwFieldTypes* pFieldTypes = GetDoc()->getIDocumentFieldsAccess().GetFieldTypes();
2790  const size_t nCount = pFieldTypes->size();
2791 
2792  std::vector<OUString> aFieldNames;
2793  for( size_t i = 0; i < nCount; ++i )
2794  {
2795  SwFieldType& rFieldType = *((*pFieldTypes)[i]);
2796 
2797  OUString sFieldName;
2798  if (SwXTextFieldMasters::getInstanceName(rFieldType, sFieldName))
2799  {
2800  aFieldNames.push_back(sFieldName);
2801  }
2802  }
2803 
2804  return comphelper::containerToSequence(aFieldNames);
2805 }
2806 
2808 {
2809  SolarMutexGuard aGuard;
2810  if(!GetDoc())
2811  throw uno::RuntimeException();
2812 
2813  OUString sName(rName), sTypeName;
2814  const SwFieldIds nResId = lcl_GetIdByName( sName, sTypeName );
2815  bool bRet = false;
2816  if( SwFieldIds::Unknown != nResId )
2817  {
2818  sName = sName.copy(std::min(sTypeName.getLength()+1, sName.getLength()));
2819  bRet = nullptr != GetDoc()->getIDocumentFieldsAccess().GetFieldType(nResId, sName, true);
2820  }
2821  return bRet;
2822 }
2823 
2825 {
2827 
2828 }
2829 
2831 {
2832  SolarMutexGuard aGuard;
2833  if(!IsValid())
2834  throw uno::RuntimeException();
2835  return true;
2836 }
2837 
2839 {
2840 private:
2841  ::osl::Mutex m_Mutex; // just for OInterfaceContainerHelper2
2842 
2843 public:
2845 
2846  Impl() : m_RefreshListeners(m_Mutex) { }
2847 };
2848 
2850 {
2851  return "SwXTextFieldTypes";
2852 }
2853 
2854 sal_Bool SwXTextFieldTypes::supportsService(const OUString& rServiceName)
2855 {
2856  return cppu::supportsService(this, rServiceName);
2857 }
2858 
2860 {
2861  uno::Sequence<OUString> aRet { "com.sun.star.text.TextFields" };
2862  return aRet;
2863 }
2864 
2866  : SwUnoCollection (_pDoc)
2867  , m_pImpl(new Impl)
2868 {
2869 }
2870 
2872 {
2873 }
2874 
2876 {
2878  lang::EventObject const ev(static_cast< ::cppu::OWeakObject&>(*this));
2879  m_pImpl->m_RefreshListeners.disposeAndClear(ev);
2880 }
2881 
2882 uno::Reference< container::XEnumeration > SwXTextFieldTypes::createEnumeration()
2883 {
2884  SolarMutexGuard aGuard;
2885  if(!IsValid())
2886  throw uno::RuntimeException();
2887  return new SwXFieldEnumeration(*GetDoc());
2888 }
2889 
2891 {
2893 }
2894 
2896 {
2897  SolarMutexGuard aGuard;
2898  if(!IsValid())
2899  throw uno::RuntimeException();
2900  return true; // they always exist
2901 }
2902 
2904 {
2905  {
2906  SolarMutexGuard aGuard;
2907  if (!IsValid())
2908  throw uno::RuntimeException();
2909  UnoActionContext aContext(GetDoc());
2910  GetDoc()->getIDocumentStatistics().UpdateDocStat( false, true );
2912  }
2913  // call refresh listeners (without SolarMutex locked)
2914  lang::EventObject const event(static_cast< ::cppu::OWeakObject*>(this));
2915  m_pImpl->m_RefreshListeners.notifyEach(
2916  & util::XRefreshListener::refreshed, event);
2917 }
2918 
2920  const uno::Reference<util::XRefreshListener> & xListener)
2921 {
2922  // no need to lock here as m_pImpl is const and container threadsafe
2923  m_pImpl->m_RefreshListeners.addInterface(xListener);
2924 }
2925 
2927  const uno::Reference<util::XRefreshListener> & xListener)
2928 {
2929  // no need to lock here as m_pImpl is const and container threadsafe
2930  m_pImpl->m_RefreshListeners.removeInterface(xListener);
2931 }
2932 
2934  : public SvtListener
2935 {
2936 public:
2938  std::vector<uno::Reference<text::XTextField>> m_Items;
2939  sal_Int32 m_nNextIndex;
2940 
2941  explicit Impl(SwDoc& rDoc)
2942  : m_pDoc(&rDoc)
2943  , m_nNextIndex(0)
2944  {
2946  }
2947 
2948  virtual void Notify(const SfxHint& rHint) override
2949  {
2950  if(rHint.GetId() == SfxHintId::Dying)
2951  m_pDoc = nullptr;
2952  }
2953 };
2954 
2955 OUString SAL_CALL
2957 {
2958  return "SwXFieldEnumeration";
2959 }
2960 
2961 sal_Bool SAL_CALL SwXFieldEnumeration::supportsService(const OUString& rServiceName)
2962 {
2963  return cppu::supportsService(this, rServiceName);
2964 }
2965 
2966 uno::Sequence<OUString> SAL_CALL
2968 {
2969  return { "com.sun.star.text.FieldEnumeration" };
2970 }
2971 
2973  : m_pImpl(new Impl(rDoc))
2974 {
2975  // build sequence
2976  m_pImpl->m_Items.clear();
2977 
2978  const SwFieldTypes* pFieldTypes = m_pImpl->m_pDoc->getIDocumentFieldsAccess().GetFieldTypes();
2979  const size_t nCount = pFieldTypes->size();
2980  for(size_t nType = 0; nType < nCount; ++nType)
2981  {
2982  const SwFieldType* pCurType = (*pFieldTypes)[nType].get();
2983  std::vector<SwFormatField*> vFormatFields;
2984  pCurType->GatherFields(vFormatFields);
2985  std::for_each(vFormatFields.begin(), vFormatFields.end(),
2986  [this](SwFormatField* pF) { m_pImpl->m_Items.push_back(SwXTextField::CreateXTextField(m_pImpl->m_pDoc, pF)); });
2987  }
2988  // now handle meta-fields, which are not SwFields
2989  const std::vector< uno::Reference<text::XTextField> > MetaFields(
2990  m_pImpl->m_pDoc->GetMetaFieldManager().getMetaFields() );
2991  for (const auto & rMetaField : MetaFields)
2992  {
2993  m_pImpl->m_Items.push_back( rMetaField );
2994  }
2995  // also add fieldmarks
2996  IDocumentMarkAccess& rMarksAccess(*rDoc.getIDocumentMarkAccess());
2997  for (auto iter = rMarksAccess.getFieldmarksBegin(); iter != rMarksAccess.getFieldmarksEnd(); ++iter)
2998  {
2999  m_pImpl->m_Items.emplace_back(SwXFieldmark::CreateXFieldmark(rDoc, *iter), uno::UNO_QUERY);
3000  }
3001 }
3002 
3004 {
3005 }
3006 
3008 {
3009  SolarMutexGuard aGuard;
3010 
3011  return m_pImpl->m_nNextIndex < static_cast<sal_Int32>(m_pImpl->m_Items.size());
3012 }
3013 
3015 {
3016  SolarMutexGuard aGuard;
3017 
3018  if (m_pImpl->m_nNextIndex >= static_cast<sal_Int32>(m_pImpl->m_Items.size()))
3019  throw container::NoSuchElementException(
3020  "SwXFieldEnumeration::nextElement",
3021  css::uno::Reference<css::uno::XInterface>());
3022 
3023  uno::Reference< text::XTextField > &rxField =
3024  m_pImpl->m_Items[ m_pImpl->m_nNextIndex++ ];
3025  uno::Any aRet;
3026  aRet <<= rxField;
3027  rxField = nullptr; // free memory for item that is no longer used
3028  return aRet;
3029 }
3030 
3031 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
void SetToolTip(const OUString &rToolTip)
Sets the tool tip of the field.
#define PROPERTY_MAP_FLDTYP_CHAPTER
Definition: unomap.hxx:73
SwDoc * GetDoc() const
Definition: unocoll.hxx:59
Instances of SwFields and those derived from it occur 0 to n times.
Definition: fldbas.hxx:240
const SwDocInfoSubType DI_SUB_TIME
Definition: docufld.hxx:83
void SetValue(bool bHidden)
Definition: docufld.hxx:329
virtual void SAL_CALL removeEventListener(const css::uno::Reference< css::lang::XEventListener > &xListener) override
Definition: unofield.cxx:2131
void SetDelimiter(const OUString &s)
Definition: expfld.hxx:178
IDocumentStatistics const & getIDocumentStatistics() const
Definition: doc.cxx:373
SwNode & GetNode(bool bPoint=true) const
Definition: pam.hxx:223
#define UNO_NAME_VALUE
Definition: unoprnms.hxx:326
#define PROPERTY_MAP_FLDTYP_DATABASE_SET_NUM
Definition: unomap.hxx:91
sal_Int32 nCommandType
Definition: swdbdata.hxx:32
sal_Int32 nIndex
virtual const SwDoc * GetDoc() const =0
The shared part of a user field.
Definition: usrfld.hxx:34
#define FIELD_PROP_DATE_TIME
Definition: unofldmid.h:38
Marks a position in the document model.
Definition: pam.hxx:35
SwServiceType m_nServiceId
Definition: unofield.cxx:1099
#define UNO_NAME_DDE_COMMAND_FILE
Definition: unoprnms.hxx:152
const SwField * GetField() const
Definition: fmtfld.hxx:110
LanguageType GetLanguage() const
Language at field position.
Definition: fldbas.hxx:402
virtual void SAL_CALL addVetoableChangeListener(const OUString &rPropertyName, const css::uno::Reference< css::beans::XVetoableChangeListener > &xListener) override
Definition: unofield.cxx:938
SwXTextFieldMasters(SwDoc *pDoc)
Definition: unofield.cxx:2666
virtual const_iterator_t getAnnotationMarksEnd() const =0
#define UNO_NAME_IS_AUTOMATIC_UPDATE
Definition: unoprnms.hxx:154
std::unique_ptr< SwFieldProperties_Impl > m_pProps
Definition: unofield.cxx:1101
void Notify(SwFlyFrame *pFly, SwPageFrame *pOld, const SwRect &rOld, const SwRect *pOldRect=nullptr)
Notify the background based on the difference between old and new rectangle.
Definition: frmtool.cxx:3191
virtual void SAL_CALL setPropertyValue(const OUString &rPropertyName, const css::uno::Any &rValue) override
Definition: unofield.cxx:573
static SwServiceType lcl_GetServiceForField(const SwField &rField)
Definition: unofield.cxx:194
::sw::UnoImplPtr< Impl > m_pImpl
Definition: unofield.hxx:128
#define PROPERTY_MAP_FLDTYP_HIDDEN_TEXT
Definition: unomap.hxx:76
virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo() override
Definition: unofield.cxx:2139
sal_uInt32 GetFormat() const
Query parameters for dialog and for BASIC.
Definition: fldbas.hxx:397
virtual void CalcLayout()
Definition: viewsh.cxx:977
virtual sal_uInt16 GetSubType() const override
Definition: docufld.cxx:2017
#define PROPERTY_MAP_FLDTYP_COMBINED_CHARACTERS
Definition: unomap.hxx:102
SwRect FindLayoutRect(const bool bPrtArea=false, const Point *pPoint=nullptr) const
Definition: node.cxx:1221
SwFormatField * m_pFormatField
Definition: unofield.cxx:1089
const SwExtendedSubType SUB_INVISIBLE
Invisible.
Definition: fldbas.hxx:212
#define PROPERTY_MAP_FLDTYP_DDE
Definition: unomap.hxx:80
constexpr TypedWhichId< SwPtrMsgPoolItem > RES_REMOVE_UNO_OBJECT(181)
virtual ~SwXTextFieldTypes() override
Definition: unofield.cxx:2871
#define FIELD_PROP_STRINGS
Definition: unofldmid.h:42
#define PROPERTY_MAP_FLDTYP_DATABASE_NEXT_SET
Definition: unomap.hxx:89
virtual css::uno::Any SAL_CALL getByName(const OUString &rName) override
Definition: unofield.cxx:2724
signed char sal_Int8
virtual SwFieldType * GetFieldType(SwFieldIds nResId, const OUString &rName, bool bDbFieldMatching) const =0
SwFieldIds m_nResTypeId
Definition: unofield.cxx:416
void ChgExpStr(const OUString &rExpand, SwRootFrame const *pLayout)
Definition: expfld.cxx:541
void SetPromptText(const OUString &rStr)
Definition: expfld.hxx:255
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
Definition: unofield.cxx:2967
::comphelper::OInterfaceContainerHelper2 m_EventListeners
Definition: unofield.cxx:411
SwServiceType GetServiceId() const
Definition: unofield.cxx:1246
virtual css::uno::Any SAL_CALL getPropertyValue(const OUString &rPropertyName) override
Definition: unofield.cxx:804
#define PROPERTY_MAP_FLDTYP_GET_REFERENCE
Definition: unomap.hxx:74
wrapper iterator: wraps iterator of implementation while hiding MarkBase class; only IMark instances ...
void SetOutlineLvl(sal_uInt8 n)
Definition: expfld.hxx:180
virtual void SetModified()=0
Must be called manually at changes of format.
long Long
OUString sDataSource
Definition: swdbdata.hxx:30
static OUString LocalizeFormula(const SwSetExpField &rField, const OUString &rFormula, bool bQuery)
Definition: unofield.cxx:1018
virtual void SAL_CALL dispose() override
Definition: unofield.cxx:948
const SwPosition * GetMark() const
Definition: pam.hxx:209
const sal_Unicode cTokenSeparator
Base class of all fields.
Definition: fldbas.hxx:289
virtual void SetPar2(const OUString &rStr) override
set the PostIt's text
Definition: docufld.cxx:1804
#define FIELD_PROP_USHORT1
Definition: unofldmid.h:31
virtual sal_Int64 SAL_CALL getSomething(const css::uno::Sequence< sal_Int8 > &rIdentifier) override
Definition: unofield.cxx:469
Special ranges.
Definition: poolfmt.hxx:327
Provides access to the marks of a document.
#define PROPERTY_MAP_FLDTYP_GET_EXP
Definition: unomap.hxx:69
const SfxItemPropertySet * GetPropertySet(sal_uInt16 PropertyId)
Definition: unomap1.cxx:1061
Definition: doc.hxx:188
Impl(SwFieldType *const pType, SwDoc *pDoc, SwFieldIds nResId)
Definition: unofield.cxx:440
#define PROPERTY_MAP_FLDMSTR_USER
Definition: unomap.hxx:105
virtual void Invalidate() override
Definition: unofield.cxx:2875
#define FIELD_PROP_BOOL4
Definition: unofldmid.h:41
virtual sal_Bool SAL_CALL supportsService(const OUString &rServiceName) override
Definition: unofield.cxx:2854
sal_Int16 nId
virtual void Notify(const SfxHint &rHint) override
Definition: unofield.cxx:2948
void disposeAndClear(const css::lang::EventObject &rEvt)
bool IsAtEndOfMeta() const
Definition: unoobj.cxx:795
const SwDocInfoSubType DI_COMMENT
Definition: docufld.hxx:73
virtual OUString SAL_CALL getPresentation(sal_Bool bShowCommand) override
Definition: unofield.cxx:1340
SwFieldType * GetFieldType() const
Definition: unofield.cxx:1151
SwTextNode * GetpTextNode() const
Definition: txtfld.hxx:49
void SetTextObject(std::unique_ptr< OutlinerParaObject > pText)
Definition: docufld.cxx:1822
const sal_uInt16 aDocInfoSubTypeFromService[]
Definition: unofield.cxx:96
static void CreateMacroString(OUString &rMacro, std::u16string_view rMacroName, const OUString &rLibraryName)
create an internally used macro name from the library and macro name parts
Definition: macrofld.cxx:195
IDocumentMarkAccess * getIDocumentMarkAccess()
Definition: docbm.cxx:1794
virtual bool InsertPoolItem(const SwPaM &rRg, const SfxPoolItem &, const SetAttrMode nFlags=SetAttrMode::DEFAULT, SwRootFrame const *pLayout=nullptr, SwTextAttr **ppNewTextAttr=nullptr)=0
Insert an attribute.
const OUString & GetName() const
Definition: docufld.hxx:535
#define PROPERTY_MAP_FLDTYP_DOCINFO_REVISION
Definition: unomap.hxx:101
void SetLevel(sal_uInt8)
Definition: chpfld.cxx:81
sal_uInt16 Which() const
Definition: txatbase.hxx:114
static css::uno::Reference< css::text::XTextField > CreateXTextField(SwDoc *pDoc, SwFormatField const *pFormat, SwServiceType nServiceId=SwServiceType::Invalid)
Definition: unofield.cxx:1219
virtual bool DeleteAndJoin(SwPaM &, const bool bForceJoinNext=false)=0
complete delete of a given PaM
virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo() override
Definition: unofield.cxx:564
IDocumentContentOperations const & getIDocumentContentOperations() const
Definition: doc.cxx:315
#define PROPERTY_MAP_FLDMSTR_DUMMY0
Definition: unomap.hxx:109
SAL_DLLPRIVATE css::uno::WeakReference< css::beans::XPropertySet > const & GetXObject() const
Definition: fldbas.hxx:257
#define UNO_NAME_DDE_COMMAND_ELEMENT
Definition: unoprnms.hxx:153
constexpr TypedWhichId< SwFormatField > RES_TXTATR_ANNOTATION(59)
std::unique_ptr< Impl > m_pImpl
For old documents the Field-Which IDs must be preserved !!!
const SwDocInfoSubType DI_EDIT
Definition: docufld.hxx:78
css::uno::Reference< css::beans::XPropertySetInfo > const & getPropertySetInfo() const
#define FIELD_PROP_SUBTYPE
Definition: unofldmid.h:27
SfxHintId GetId() const
#define UNO_NAME_SUB_TYPE
Definition: unoprnms.hxx:309
#define PROPERTY_MAP_FLDTYP_DOCINFO_DATE_TIME
Definition: unomap.hxx:96
virtual sal_Bool SAL_CALL hasElements() override
Definition: unofield.cxx:2830
virtual void SAL_CALL removeVetoableChangeListener(const OUString &rPropertyName, const css::uno::Reference< css::beans::XVetoableChangeListener > &xListener) override
Definition: unofield.cxx:2510
const SfxItemPropertyMapEntry * getByName(std::u16string_view rName) const
void GatherFields(std::vector< SwFormatField * > &rvFormatFields, bool bCollectOnlyInDocNodes=true) const
Definition: fldbas.cxx:207
uno::WeakReference< uno::XInterface > m_wThis
Definition: unofield.cxx:1092
#define FIELD_PROP_FORMAT
Definition: unofldmid.h:26
static sal_uInt16 lcl_GetPropMapIdForFieldType(SwFieldIds nWhich)
Definition: unofield.cxx:276
void UpdateFields() const
Definition: fldbas.cxx:148
virtual ~SwXFieldEnumeration() override
Definition: unofield.cxx:3003
OUString m_sTypeName
Definition: unofield.cxx:1100
IDocumentFieldsAccess const & getIDocumentFieldsAccess() const
Definition: doc.cxx:357
static void TransmuteLeadToInputField(SwSetExpField &rField)
Convert between SwSetExpField with InputFlag false and InputFlag true.
Definition: unofield.cxx:1263
virtual void SAL_CALL addPropertyChangeListener(const OUString &rPropertyName, const css::uno::Reference< css::beans::XPropertyChangeListener > &xListener) override
Definition: unofield.cxx:2495
const SwDoc & GetDoc() const
Definition: unoobj2.cxx:767
void SetFormatField(SwFormatField *pFormatField, SwDoc *pDoc)
Definition: unofield.cxx:1127
uno::WeakReference< uno::XInterface > m_wThis
Definition: unofield.cxx:410
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
Definition: unofield.cxx:2594
virtual css::uno::Any SAL_CALL getPropertyValue(const OUString &rPropertyName) override
Definition: unofield.cxx:2313
virtual void SAL_CALL removeVetoableChangeListener(const OUString &rPropertyName, const css::uno::Reference< css::beans::XVetoableChangeListener > &xListener) override
Definition: unofield.cxx:943
virtual css::uno::Reference< css::container::XEnumeration > SAL_CALL createEnumeration() override
Definition: unofield.cxx:2882
invariant for SwAuthorityField is that it is always registered at its SwAuthorityFieldType via AddFie...
Definition: authfld.hxx:154
SwXFieldEnumeration(SwDoc &rDoc)
Definition: unofield.cxx:2972
SwIndex nContent
Definition: pam.hxx:38
SwXTextFieldTypes(SwDoc *pDoc)
Definition: unofield.cxx:2865
::sw::UnoImplPtr< Impl > m_pImpl
Definition: unofield.hxx:51
const SwTextField * GetTextField() const
Definition: fmtfld.hxx:128
#define FN_UNO_TEXT_WRAP
Definition: cmdid.h:565
void ChgExpStr(const OUString &rExpand, SwRootFrame const *pLayout)
Definition: expfld.cxx:297
A wrapper around SfxPoolItem to store the start position of (usually) a text portion, with an optional end.
Definition: txatbase.hxx:41
IDocumentStylePoolAccess const & getIDocumentStylePoolAccess() const
Definition: doc.cxx:426
bool IsValid() const
Definition: unocoll.hxx:57
virtual sw::mark::IMark * makeAnnotationMark(const SwPaM &rPaM, const OUString &rName)=0
constexpr OUStringLiteral sServiceName
Definition: accdoc.cxx:55
virtual sal_uInt16 GetSubType() const override
Definition: docufld.cxx:1133
SwFieldType * m_pFieldType
Definition: unofield.cxx:1088
virtual void SAL_CALL dispose() override
Definition: unofield.cxx:2105
#define PROPERTY_MAP_FLDMSTR_BIBLIOGRAPHY
Definition: unomap.hxx:111
int nCount
static SwFieldIds lcl_GetIdByName(OUString &rName, OUString &rTypeName)
Definition: unofield.cxx:2687
bool CPPUHELPER_DLLPUBLIC supportsService(css::lang::XServiceInfo *implementation, rtl::OUString const &name)
virtual void SAL_CALL removePropertyChangeListener(const OUString &rPropertyName, const css::uno::Reference< css::beans::XPropertyChangeListener > &xListener) override
Definition: unofield.cxx:2500
static bool getInstanceName(const SwFieldType &rFieldType, OUString &rName)
Definition: unofield.cxx:2749
const SwDocInfoSubType DI_SUBJECT
Definition: docufld.hxx:71
static const css::uno::Sequence< sal_Int8 > & getUnoTunnelId()
Definition: unofield.cxx:1174
sal_Int32 GetStart() const
Definition: txatbase.hxx:86
const sal_uInt8 MAXLEVEL
Definition: swtypes.hxx:91
virtual OUString SAL_CALL getImplementationName() override
Definition: unofield.cxx:2570
#define PROPERTY_MAP_FLDTYP_REF_PAGE_SET
Definition: unomap.hxx:85
bool IsDescriptor() const
Definition: unofield.cxx:1141
static css::uno::Reference< css::text::XTextContent > CreateXFieldmark(SwDoc &rDoc,::sw::mark::IMark *pMark, bool isReplacementObject=false)
Definition: unobkm.cxx:688
void Width(tools::Long nNew)
Definition: swrect.hxx:187
#define PROPERTY_MAP_FLDTYP_DOCINFO_CUSTOM
Definition: unomap.hxx:122
void SetExpansion(const OUString &rStr)
Definition: docufld.hxx:197
#define UNO_NAME_CHAPTER_NUMBERING_LEVEL
Definition: unoprnms.hxx:464
const SwFormatField & GetFormatField() const
Definition: txatbase.hxx:195
virtual void Notify(const SfxHint &) override
Definition: unofield.cxx:2627
void SetSelectedItem(const OUString &rItem)
Sets the selected item.
#define PROPERTY_MAP_FLDTYP_DOCINFO_AUTHOR
Definition: unomap.hxx:95
const ServiceIdResId aServiceToRes[]
Definition: unofield.cxx:127
#define UNO_NAME_CONTENT
Definition: unoprnms.hxx:237
void SetExpansion(const OUString &rStr)
Definition: docufld.hxx:537
#define FIELD_PROP_DOUBLE
Definition: unofldmid.h:34
const char * sName
const SwGetSetExpType GSE_EXPR
Expression.
Definition: fldbas.hxx:203
virtual bool QueryValue(css::uno::Any &rVal, sal_uInt16 nWhichId) const
Definition: fldbas.cxx:346
#define UNO_NAME_DATA_COMMAND_TYPE
Definition: unoprnms.hxx:245
sal_Int32 m_nNextIndex
index of next element to be returned
Definition: unofield.cxx:2939
::sw::UnoImplPtr< Impl > m_pImpl
Definition: unofield.hxx:217
#define PROPERTY_MAP_FLDTYP_DUMMY_0
Definition: unomap.hxx:103
virtual SwPageDesc * GetPageDescFromPool(sal_uInt16 nId, bool bRegardLanguage=true)=0
Return required automatic page style.
#define PROPERTY_MAP_FLDTYP_DOCINFO_MISC
Definition: unomap.hxx:100
virtual OUString SAL_CALL getImplementationName() override
Definition: unofield.cxx:2956
constexpr OUStringLiteral aData
Definition: ww8scan.hxx:48
#define SAL_N_ELEMENTS(arr)
const SwDocInfoSubType DI_CUSTOM
Definition: docufld.hxx:79
Impl(SwPageDesc *const pPageDesc, SwDoc *pDoc, SwFieldIds nResId)
Definition: unofield.cxx:427
#define UNO_NAME_DDE_COMMAND_TYPE
Definition: unoprnms.hxx:151
static SW_DLLPUBLIC const OUString & GetSpecialExtraProgName(const OUString &rExtraUIName)
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
Definition: unofield.cxx:2660
virtual void SAL_CALL addVetoableChangeListener(const OUString &rPropertyName, const css::uno::Reference< css::beans::XVetoableChangeListener > &xListener) override
Definition: unofield.cxx:2505
static sal_Int32 lcl_PropName2TokenPos(std::u16string_view rPropertyName)
Definition: unofield.cxx:292
virtual css::uno::Sequence< OUString > SAL_CALL getElementNames() override
Definition: unofield.cxx:2783
virtual sal_Int64 SAL_CALL getSomething(const css::uno::Sequence< sal_Int8 > &rIdentifier) override
Definition: unofield.cxx:1181
void EndListeningAll()
PaM is Point and Mark: a selection of the document model.
Definition: pam.hxx:136
static OUString GetProviderName(SwServiceType nObjectType)
Definition: unocoll.cxx:472
const SwDocInfoSubType DI_PRINT
Definition: docufld.hxx:76
SwFormatField * GetFormatField()
Definition: unofield.cxx:1137
virtual void SAL_CALL setPropertyValue(const OUString &rPropertyName, const css::uno::Any &rValue) override
Definition: unofield.cxx:2160
constexpr TypedWhichId< SwFormatField > RES_TXTATR_FIELD(RES_TXTATR_NOEND_BEGIN)
#define PROPERTY_MAP_FLDTYP_REF_PAGE_GET
Definition: unomap.hxx:86
void SetExpansion(const OUString &rStr)
Definition: docufld.hxx:223
#define SAL_MAX_INT32
Impl(SwDoc *const pDoc, SwFormatField *const pFormat, SwServiceType nServiceId)
Definition: unofield.cxx:1103
#define UNO_NAME_DEPENDENT_TEXT_FIELDS
Definition: unoprnms.hxx:470
void SetSetNumber(tools::Long nNum)
Definition: dbfld.hxx:285
int i
The non-shared part of a user field.
Definition: usrfld.hxx:102
rtl::Reference< SwTextAPIObject > m_xTextObject
Definition: unofield.cxx:1096
const SwPosition * GetPoint() const
Definition: pam.hxx:207
const SwExtendedSubType SUB_CMD
Show command.
Definition: fldbas.hxx:211
static sal_uInt16 GetFieldTypeMId(std::u16string_view rProperty, const SwFieldType &rTyp)
Definition: unofield.cxx:309
SwEditShell const * GetEditShell() const
Definition: doccorr.cxx:328
const SwDocInfoSubType DI_KEYS
Definition: docufld.hxx:72
#define FIELD_PROP_TEXT
Definition: unofldmid.h:48
#define FIELD_PROP_BOOL2
Definition: unofldmid.h:29
virtual OUString SAL_CALL getImplementationName() override
Definition: unofield.cxx:2650
SetAttrMode
Definition: swtypes.hxx:133
SAL_DLLPRIVATE void SetXObject(css::uno::Reference< css::beans::XPropertySet > const &xFieldMaster)
Definition: fldbas.hxx:260
#define COM_TEXT_FLDMASTER_CC
Definition: unofield.cxx:93
#define FIELD_PROP_USHORT2
Definition: unofldmid.h:32
static sal_uInt16 lcl_GetPropertyMapOfService(SwServiceType nServiceId)
Definition: unofield.cxx:323
virtual ~Impl() override
Definition: unofield.cxx:1119
const SwDocInfoSubType DI_CREATE
Definition: docufld.hxx:74
SwFieldTypesEnum
List of FieldTypes at UI.
Definition: fldbas.hxx:93
#define PROPERTY_MAP_FLDTYP_DATABASE
Definition: unomap.hxx:92
SwFieldIds
Definition: fldbas.hxx:44
bool HasMark() const
A PaM marks a selection if Point and Mark are distinct positions.
Definition: pam.hxx:205
virtual sal_Bool SAL_CALL hasMoreElements() override
Definition: unofield.cxx:3007
constexpr std::enable_if_t< std::is_signed_v< T >, std::make_unsigned_t< T > > make_unsigned(T value)
#define PROPERTY_MAP_FLDTYP_SCRIPT
Definition: unomap.hxx:88
Force hint expand (only matters for hints with CH_TXTATR).
float u
unsigned char sal_Bool
virtual sal_Bool SAL_CALL supportsService(const OUString &rServiceName) override
Definition: unofield.cxx:2655
const SfxItemPropertyMap & getPropertyMap() const
virtual OUString SAL_CALL getImplementationName() override
Definition: unofield.cxx:2849
std::vector< uno::Reference< text::XTextField > > m_Items
Definition: unofield.cxx:2938
IDocumentState const & getIDocumentState() const
Definition: doc.cxx:394
#define FIELD_PROP_BYTE1
Definition: unofldmid.h:33
virtual const_iterator_t getAnnotationMarksBegin() const =0
Label drawing objects.
Definition: poolfmt.hxx:358
const SwDocInfoSubType DI_SUB_DATE
Definition: docufld.hxx:84
virtual void SAL_CALL addPropertyChangeListener(const OUString &rPropertyName, const css::uno::Reference< css::beans::XPropertyChangeListener > &xListener) override
Definition: unofield.cxx:928
static const css::uno::Sequence< sal_Int8 > & getUnoTunnelId()
Definition: unofield.cxx:462
virtual void SAL_CALL addRefreshListener(const css::uno::Reference< css::util::XRefreshListener > &xListener) override
Definition: unofield.cxx:2919
css::uno::Type const & get()
SwNodes & GetNodes()
Node is in which nodes-array/doc?
Definition: node.hxx:694
virtual const SwFieldTypes * GetFieldTypes() const =0
virtual sal_Bool SAL_CALL hasElements() override
Definition: unofield.cxx:2895
virtual sal_Bool SAL_CALL hasByName(const OUString &rName) override
Definition: unofield.cxx:2807
SwTextField * GetFieldTextAttrAt(const sal_Int32 nIndex, const bool bIncludeInputFieldAtStart=false) const
Definition: ndtxt.cxx:1760
Text operation/manipulation interface.
bool StartListening(SvtBroadcaster &rBroadcaster)
SwXFieldMaster(SwFieldType &rType, SwDoc *pDoc)
Definition: unofield.cxx:528
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
Definition: unofield.cxx:2859
SAL_DLLPRIVATE css::uno::WeakReference< css::text::XTextField > const & GetXTextField() const
Definition: fmtfld.hxx:143
#define PROPERTY_MAP_FLDTYP_USER
Definition: unomap.hxx:67
const SvXMLTokenMapEntry aTypes[]
virtual ~SwXFieldMaster() override
Definition: unofield.cxx:533
#define DB_DELIM
Definition: swtypes.hxx:131
virtual sal_uInt16 GetSubType() const
Definition: fldbas.cxx:337
#define UNO_NAME_NUMBERING_SEPARATOR
Definition: unoprnms.hxx:465
IDocumentLayoutAccess const & getIDocumentLayoutAccess() const
Definition: doc.cxx:405
#define PROPERTY_MAP_FLDTYP_DATETIME
Definition: unomap.hxx:66
virtual void QueryValue(css::uno::Any &rVal, sal_uInt16 nWhich) const
Definition: fldbas.cxx:141
const SwPosition * Start() const
Definition: pam.hxx:212
#define FIELD_PROP_PAR3
Definition: unofldmid.h:25
const OUString & GetName() const
Definition: docufld.hxx:492
bool XTextRangeToSwPaM(SwUnoInternalPaM &rToFill, const uno::Reference< text::XTextRange > &xTextRange,::sw::TextRangeMode const eMode)
Definition: unoobj2.cxx:1107
#define PROPERTY_MAP_FLDTYP_JUMP_EDIT
Definition: unomap.hxx:87
virtual css::uno::Reference< css::text::XTextRange > SAL_CALL getAnchor() override
Definition: unofield.cxx:2068
#define PROPERTY_MAP_FLDTYP_DOC_INFO
Definition: unomap.hxx:82
Dropdown field.
Definition: flddropdown.hxx:58
SwFieldType * GetTyp() const
Definition: fldbas.hxx:392
#define PROPERTY_MAP_FLDTYP_DOCINFO_EDIT_TIME
Definition: unomap.hxx:99
void SetText(const OUString &rText, SwRootFrame const *pLayout)
Definition: docufld.cxx:2324
#define PROPERTY_MAP_FLDTYP_DOCSTAT
Definition: unomap.hxx:94
bool GetInputFlag() const
Definition: expfld.hxx:264
void SetName(const OUString &rName)
Sets the name of the field.
#define PROPERTY_MAP_FLDTYP_PAGE_NUM
Definition: unomap.hxx:71
void SetSeqNumber(sal_uInt16 n)
Logical number, sequence fields.
Definition: expfld.hxx:242
OUString getDataSource() const
const SwDocInfoSubType DI_SUB_AUTHOR
Definition: docufld.hxx:82
SwFieldType * GetFieldType(bool bDontCreate=false) const
Definition: unofield.cxx:778
SvtBroadcaster & GetNotifier()
Definition: calbck.hxx:99
#define FIELD_PROP_BOOL1
Definition: unofldmid.h:28
static const css::uno::Sequence< sal_Int8 > & getUnoTunnelId()
Definition: unoobj2.cxx:905
void SetFieldType(SwFieldType *pType)
Definition: unofield.cxx:452
#define INIT_FLDTYPES
Definition: swtypes.hxx:106
virtual void SAL_CALL removeRefreshListener(const css::uno::Reference< css::util::XRefreshListener > &xListener) override
Definition: unofield.cxx:2926
#define PROPERTY_MAP_FLDTYP_INPUT
Definition: unomap.hxx:78
virtual void PutValueToField(const SwPosition &rPos, const css::uno::Any &rVal, sal_uInt16 nWhich)=0
Puts a value into a field at a certain position.
SwTextNode is a paragraph in the document model.
Definition: ndtxt.hxx:79
virtual void SAL_CALL attach(const css::uno::Reference< css::text::XTextRange > &xTextRange) override
Definition: unofield.cxx:1352
OUString ExpandField(bool bCached, SwRootFrame const *pLayout) const
expand the field.
Definition: fldbas.cxx:465
#define PROPERTY_MAP_FLDTYP_HIDDEN_PARA
Definition: unomap.hxx:81
SwFormatField * GetFormatField()
Definition: expfld.hxx:219
static const std::vector< OUString > & GetExtraUINameArray()
SwFieldIds Which() const
ResId.
Definition: fldbas.cxx:245
#define PROPERTY_MAP_FLDTYP_MACRO
Definition: unomap.hxx:79
#define UNO_NAME_INSTANCE_NAME
Definition: unoprnms.hxx:473
#define PROPERTY_MAP_FLDTYP_TEMPLATE_NAME
Definition: unomap.hxx:83
#define FIELD_PROP_BOOL3
Definition: unofldmid.h:35
#define FIELD_PROP_PAR1
Definition: unofldmid.h:23
virtual OUString GetName() const
Only in derived classes.
Definition: fldbas.cxx:136
#define FIELD_PROP_PAR2
Definition: unofldmid.h:24
virtual void UpdateDocStat(bool bCompleteAsync, bool bFields)=0
Updates the internal document's statistics.
virtual const SwViewShell * GetCurrentViewShell() const =0
Returns the layout set at the document.
const SwDocInfoSubType DI_DOCNO
Definition: docufld.hxx:77
static OUString Expand(sal_uInt16 nSubType)
Definition: docufld.cxx:1960
virtual SwFieldType * InsertFieldType(const SwFieldType &)=0
::osl::Mutex m_Mutex
Definition: unofield.cxx:1087
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
Definition: unofield.cxx:518
SwXTextField(SwFormatField &rFormat, SwDoc &rDoc)
Definition: unofield.cxx:1209
#define FIELD_PROP_PROP_SEQ
Definition: unofldmid.h:39
#define PROPERTY_MAP_FLDMSTR_SET_EXP
Definition: unomap.hxx:107
css::uno::Sequence< DstElementType > containerToSequence(const SrcType &i_Container)
virtual void SAL_CALL removeEventListener(const css::uno::Reference< css::lang::XEventListener > &xListener) override
Definition: unofield.cxx:978
#define FN_UNO_ANCHOR_TYPE
Definition: cmdid.h:566
#define PROPERTY_MAP_FLDMSTR_DATABASE
Definition: unomap.hxx:108
OUString aName
static OUString Expand(sal_uLong)
Definition: docufld.cxx:311
sal_Int32 GetIndex() const
Definition: index.hxx:91
INetProtocol GetProtocol() const
#define PROPERTY_MAP_FLDTYP_DATABASE_NAME
Definition: unomap.hxx:93
if(aStr!=aBuf) UpdateName_Impl(m_xFollowLb.get()
static OUString OldNameToNewName_Impl(const OUString &rOld)
Definition: unofield.cxx:2575
static const css::uno::Sequence< sal_Int8 > & getUnoTunnelId()
virtual void Invalidate()
Definition: unocoll.cxx:1933
::comphelper::OInterfaceContainerHelper2 m_EventListeners
Definition: unofield.cxx:1093
void SetInputFlag(bool bInp)
Definition: expfld.hxx:261
const SwPosition * End() const
Definition: pam.hxx:217
::osl::Mutex m_Mutex
Definition: unofield.cxx:407
virtual sal_Bool SAL_CALL supportsService(const OUString &rServiceName) override
Definition: unofield.cxx:2961
virtual void SAL_CALL removePropertyChangeListener(const OUString &rPropertyName, const css::uno::Reference< css::beans::XPropertyChangeListener > &xListener) override
Definition: unofield.cxx:933
#define PROPERTY_MAP_FLDTYP_DATABASE_NUM_SET
Definition: unomap.hxx:90
virtual void PutValue(const css::uno::Any &rVal, sal_uInt16 nWhich)
Definition: fldbas.cxx:144
#define PROPERTY_MAP_FLDTYP_ANNOTATION
Definition: unomap.hxx:77
SwUnoPropertyMapProvider aSwMapProvider
Definition: unomap1.cxx:87
QPRO_FUNC_TYPE nType
Label illustration.
Definition: poolfmt.hxx:346
virtual OUString GetFieldName() const
get name or content
Definition: fldbas.cxx:300
#define PROPERTY_MAP_FLDTYP_BIBLIOGRAPHY
Definition: unomap.hxx:110
const SwField * GetField() const
Definition: unofield.cxx:2645
Sequence< sal_Int8 > aSeq
bool IsHidden() const
Definition: ndtxt.cxx:4544
const SwGetSetExpType GSE_FORMULA
Formula.
Definition: fldbas.hxx:205
static SwFieldIds lcl_ServiceIdToResId(SwServiceType nServiceId)
Definition: unofield.cxx:183
virtual void SAL_CALL addEventListener(const css::uno::Reference< css::lang::XEventListener > &xListener) override
Definition: unofield.cxx:971
#define UNO_NAME_DATA_BASE_URL
Definition: unoprnms.hxx:747
#define FN_UNO_ANCHOR_TYPES
Definition: cmdid.h:559
constexpr TypedWhichId< SwFormatField > RES_TXTATR_INPUTFIELD(55)
void SetExpansion(const OUString &rStr)
Definition: docufld.hxx:566
virtual sal_Bool SAL_CALL supportsService(const OUString &rServiceName) override
Definition: unofield.cxx:512
#define UNO_NAME_DATA_TABLE_NAME
Definition: unoprnms.hxx:244
virtual void CalcLayout() override
To enable set up of StartActions and EndActions.
Definition: edws.cxx:108
virtual OUString SAL_CALL getImplementationName() override
Definition: unofield.cxx:475
virtual void SAL_CALL addEventListener(const css::uno::Reference< css::lang::XEventListener > &xListener) override
Definition: unofield.cxx:2124
static bool GetBoundsOfHiddenRange(const SwTextNode &rNode, sal_Int32 nPos, sal_Int32 &rnStartPos, sal_Int32 &rnEndPos, std::vector< sal_Int32 > *pList=nullptr)
Hidden text range information - static and non-version.
Definition: porlay.cxx:1864
#define UNO_NAME_DATA_COLUMN_NAME
Definition: unoprnms.hxx:246
#define UNO_NAME_DATA_BASE_NAME
Definition: unoprnms.hxx:243
#define PROPERTY_MAP_FLDTYP_AUTHOR
Definition: unomap.hxx:72
virtual void SAL_CALL refresh() override
Definition: unofield.cxx:2903
#define PROPERTY_MAP_PARAGRAPH_EXTENSIONS
Definition: unomap.hxx:51
#define FIELD_PROP_IS_FIELD_DISPLAYED
Definition: unofldmid.h:46
#define PROPERTY_MAP_FLDTYP_USER_EXT
Definition: unomap.hxx:84
ResultType type
virtual ~SwXTextField() override
Definition: unofield.cxx:1214
void SetFieldType(SwFieldType &rType)
Definition: unofield.cxx:1160
::comphelper::OInterfaceContainerHelper2 m_RefreshListeners
Definition: unofield.cxx:2844
void SetHelp(const OUString &rHelp)
Sets the help text of the field.
bool SetURL(OUString const &rTheAbsURIRef, EncodeMechanism eMechanism=EncodeMechanism::WasEncoded, rtl_TextEncoding eCharset=RTL_TEXTENCODING_UTF8)
bool IsDocNodes() const
Is the NodesArray the regular one of Doc? (and not the UndoNds, ...) Implementation in doc...
Definition: nodes.cxx:2329
#define FIELD_PROP_DATE
Definition: unofldmid.h:30
#define FIELD_PROP_PAR4
Definition: unofldmid.h:36
const SwGetSetExpType GSE_STRING
String.
Definition: fldbas.hxx:202
virtual void SetValue(const double &rVal)
Definition: fldbas.cxx:731
SwDoc & GetDoc() const
Definition: pam.hxx:243
detail::Optional< bool >::type tryAccess< bool >(css::uno::Any const &any)
virtual SwFieldType * GetSysFieldType(const SwFieldIds eWhich) const =0
SwFieldType * m_pType
Definition: unofield.cxx:414
const SwDocInfoSubType DI_SUB_FIXED
Definition: docufld.hxx:85
const SwDocInfoSubType DI_CHANGE
Definition: docufld.hxx:75
virtual void SetMark()
Unless this is called, the getter method of Mark will return Point.
Definition: pam.cxx:478
#define PROPERTY_MAP_FLDTYP_DROPDOWN
Definition: unomap.hxx:115
virtual css::uno::Type SAL_CALL getElementType() override
Definition: unofield.cxx:2890
const char *const aFieldNames[]
Definition: authfld.cxx:649
virtual void SAL_CALL attachTextFieldMaster(const css::uno::Reference< css::beans::XPropertySet > &xFieldMaster) override
Definition: unofield.cxx:1306
static css::uno::Reference< css::text::XTextRange > CreateXTextRange(SwDoc &rDoc, const SwPosition &rPos, const SwPosition *const pMark)
Definition: unoobj2.cxx:1210
#define PROPERTY_MAP_FLDTYP_CONDITIONED_TEXT
Definition: unomap.hxx:75
virtual css::uno::Any SAL_CALL nextElement() override
Definition: unofield.cxx:3014
virtual void UpdateFields(bool bCloseDB)=0
::std::unique_ptr< XmlIdRegistry_Impl > m_pImpl
SwTextNode & GetTextNode() const
Definition: txtfld.hxx:53
#define UNO_NAME_IS_EXPRESSION
Definition: unoprnms.hxx:311
static OUString GetProgrammaticName(const SwFieldType &rType, SwDoc &rDoc)
Definition: unofield.cxx:1001
virtual ~SwXTextFieldMasters() override
Definition: unofield.cxx:2671
virtual css::uno::Type SAL_CALL getElementType() override
Definition: unofield.cxx:2824
OUString setToken(const OUString &rIn, sal_Int32 nToken, sal_Unicode cTok, const OUString &rNewToken)
const SwDocInfoSubType DI_TITLE
Definition: docufld.hxx:70
#define FIELD_PROP_IS_FIELD_USED
Definition: unofldmid.h:45
OUString SwResId(std::string_view aId)
Definition: swmodule.cxx:165
const css::uno::Sequence< sal_Int8 > & getSeq() const
virtual css::uno::Reference< css::beans::XPropertySet > SAL_CALL getTextFieldMaster() override
Definition: unofield.cxx:1330
#define PROPERTY_MAP_FLDMSTR_DDE
Definition: unomap.hxx:106
Standard page.
Definition: poolfmt.hxx:170
void SetHidden(bool bHidden)
Definition: docufld.hxx:372
SwFieldIds Which() const
Definition: fldbas.hxx:272
static void GetPamForTextField(const SwTextField &rTextField, std::shared_ptr< SwPaM > &rPamForTextField)
Definition: atrfld.cxx:592
#define PROPERTY_MAP_FLDTYP_FILE_NAME
Definition: unomap.hxx:70
OUString sCommand
Definition: swdbdata.hxx:31
virtual sal_Bool SAL_CALL supportsService(const OUString &rServiceName) override
Definition: unofield.cxx:2589
#define PROPERTY_MAP_FLDTYP_TABLE_FORMULA
Definition: unomap.hxx:104
sal_uInt16 Which() const
SwServiceType
entries in this enum are mapped in an array in unocoll.cxx
Definition: unocoll.hxx:63
sal_Int32 GetEnumAsInt32(const css::uno::Any &rVal)
Definition: swunohelper.cxx:50
constexpr TypedWhichId< SwPtrMsgPoolItem > RES_OBJECTDYING(RES_MSG_BEGIN)
const SfxItemPropertyMapEntry * GetPropertyMapEntries(sal_uInt16 PropertyId)
Definition: unomap.cxx:71
#define UNO_NAME_NAME
Definition: unoprnms.hxx:76
SwTextNode * GetTextNode()
Inline methods from Node.hxx.
Definition: ndtxt.hxx:850
#define PROPERTY_MAP_FLDTYP_SET_EXP
Definition: unomap.hxx:68
void SetItems(const std::vector< OUString > &rItems)
Sets the items of the dropdown box.
static void DeleteTextField(const SwTextField &rTextField)
Definition: atrfld.cxx:612
static const OUString & GetSpecialExtraUIName(const OUString &rExtraProgName)
virtual void SAL_CALL update() override
Definition: unofield.cxx:2515
void SetLateInitialization()
Definition: expfld.hxx:131
static css::uno::Reference< css::beans::XPropertySet > CreateXFieldMaster(SwDoc *pDoc, SwFieldType *pType, SwFieldIds nResId=SwFieldIds::Unknown)
Definition: unofield.cxx:538
void SetUserString(const OUString &rS)
Definition: docufld.hxx:175
virtual sal_uInt16 GetSubType() const override
Definition: dbfld.cxx:346
virtual void Notify(const SfxHint &rHint) override
Definition: unofield.cxx:985
#define FIELD_PROP_SHORT1
Definition: unofldmid.h:37
void SetOffset(tools::Long nMinutes)
Definition: flddat.hxx:65
static const OUString & GetProgName(const OUString &rName, SwGetPoolIdFromName)
typedef void(CALLTYPE *GetFuncDataPtr)(sal_uInt16 &nNo