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 constexpr OUStringLiteral COM_TEXT_FLDMASTER_CC = u"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 comphelper::UnoIdInit theSwXFieldMasterUnoTunnelId;
465  return theSwXFieldMasterUnoTunnelId.getSeq();
466 }
467 
468 sal_Int64 SAL_CALL
469 SwXFieldMaster::getSomething(const uno::Sequence< sal_Int8 >& rId)
470 {
471  return comphelper::getSomethingImpl<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.getArray(),
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 comphelper::UnoIdInit theSwXTextFieldUnoTunnelId;
1177  return theSwXTextFieldUnoTunnelId.getSeq();
1178 }
1179 
1180 sal_Int64 SAL_CALL
1181 SwXTextField::getSomething(const uno::Sequence< sal_Int8 >& rId)
1182 {
1183  return comphelper::getSomethingImpl<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  ? comphelper::getFromUnoTunnel<SwXTextField>(uno::Reference<lang::XUnoTunnel>(xField, uno::UNO_QUERY_THROW))
1270  : nullptr;
1271  if (pXField)
1272  pXField->m_pImpl->SetFormatField(nullptr, nullptr);
1273  SwTextField *const pOldAttr(rField.GetFormatField()->GetTextField());
1274  SwSetExpField tempField(rField);
1275  tempField.SetInputFlag(!rField.GetInputFlag());
1276  SwFormatField tempFormat(tempField);
1277  assert(tempFormat.GetField() != &rField);
1278  assert(tempFormat.GetField() != &tempField); // this copies it again?
1279  assert(tempFormat.Which() == (static_cast<SwSetExpField const*>(tempFormat.GetField())->GetInputFlag() ? RES_TXTATR_INPUTFIELD : RES_TXTATR_FIELD));
1280  SwTextNode & rNode(pOldAttr->GetTextNode());
1281  std::shared_ptr<SwPaM> pPamForTextField;
1282  IDocumentContentOperations & rIDCO(rNode.GetDoc().getIDocumentContentOperations());
1283  SwTextField::GetPamForTextField(*pOldAttr, pPamForTextField);
1284  assert(pPamForTextField);
1285  sal_Int32 const nStart(pPamForTextField->Start()->nContent.GetIndex());
1286  rIDCO.DeleteAndJoin(*pPamForTextField);
1287  // ATTENTION: rField is dead now! hope nobody accesses it...
1288  bool bSuccess = rIDCO.InsertPoolItem(*pPamForTextField, tempFormat);
1289  assert(bSuccess);
1290  (void) bSuccess;
1291  SwTextField const* pNewAttr(rNode.GetFieldTextAttrAt(nStart, true));
1292  assert(pNewAttr);
1293  SwFormatField const& rNewFormat(pNewAttr->GetFormatField());
1294  assert(rNewFormat.Which() == (static_cast<SwSetExpField const*>(rNewFormat.GetField())->GetInputFlag() ? RES_TXTATR_INPUTFIELD : RES_TXTATR_FIELD));
1295  assert(static_cast<SwSetExpField const*>(rNewFormat.GetField())->GetInputFlag() == (dynamic_cast<SwTextInputField const*>(pNewAttr) != nullptr));
1296  if (pXField)
1297  {
1298  pXField->m_pImpl->SetFormatField(const_cast<SwFormatField*>(&rNewFormat), &rNode.GetDoc());
1299  const_cast<SwFormatField&>(rNewFormat).SetXTextField(xField);
1300  }
1301 }
1302 
1304  const uno::Reference< beans::XPropertySet > & xFieldMaster)
1305 {
1306  SolarMutexGuard aGuard;
1307 
1308  if (!m_pImpl->IsDescriptor())
1309  throw uno::RuntimeException();
1310  uno::Reference< lang::XUnoTunnel > xMasterTunnel(xFieldMaster, uno::UNO_QUERY);
1311  if (!xMasterTunnel.is())
1312  throw lang::IllegalArgumentException();
1313  SwXFieldMaster* pMaster = comphelper::getFromUnoTunnel<SwXFieldMaster>(xMasterTunnel);
1314 
1315  SwFieldType* pFieldType = pMaster ? pMaster->GetFieldType() : nullptr;
1316  if (!pFieldType ||
1317  pFieldType->Which() != lcl_ServiceIdToResId(m_pImpl->m_nServiceId))
1318  {
1319  throw lang::IllegalArgumentException();
1320  }
1321  m_pImpl->m_sTypeName = pFieldType->GetName();
1322  m_pImpl->SetFieldType(*pFieldType);
1323 }
1324 
1325 uno::Reference< beans::XPropertySet > SAL_CALL
1327 {
1328  SolarMutexGuard aGuard;
1329 
1330  SwFieldType* pType = m_pImpl->GetFieldType();
1331  uno::Reference<beans::XPropertySet> const xRet(
1333  return xRet;
1334 }
1335 
1336 OUString SAL_CALL SwXTextField::getPresentation(sal_Bool bShowCommand)
1337 {
1338  SolarMutexGuard aGuard;
1339 
1340  SwField const*const pField = m_pImpl->GetField();
1341  if (!pField)
1342  {
1343  throw uno::RuntimeException();
1344  }
1345  return bShowCommand ? pField->GetFieldName() : pField->ExpandField(true, nullptr);
1346 }
1347 
1348 void SAL_CALL SwXTextField::attach(
1349  const uno::Reference< text::XTextRange > & xTextRange)
1350 {
1351  SolarMutexGuard aGuard;
1352  if (m_pImpl->IsDescriptor())
1353  {
1354  uno::Reference<lang::XUnoTunnel> xRangeTunnel( xTextRange, uno::UNO_QUERY);
1355  SwXTextRange* pRange = comphelper::getFromUnoTunnel<SwXTextRange>(xRangeTunnel);
1356  OTextCursorHelper* pCursor = comphelper::getFromUnoTunnel<OTextCursorHelper>(xRangeTunnel);
1357 
1358  SwDoc* pDoc = pRange ? &pRange->GetDoc() : pCursor ? pCursor->GetDoc() : nullptr;
1359  // if a FieldMaster was attached, then the document is already fixed!
1360  // NOTE: sw.SwXAutoTextEntry unoapi test depends on m_pDoc = 0 being valid
1361  if (!pDoc || (m_pImpl->m_pDoc && m_pImpl->m_pDoc != pDoc))
1362  throw lang::IllegalArgumentException();
1363 
1364  SwUnoInternalPaM aPam(*pDoc);
1365  // this now needs to return TRUE
1366  ::sw::XTextRangeToSwPaM(aPam, xTextRange);
1367  std::unique_ptr<SwField> xField;
1368  switch (m_pImpl->m_nServiceId)
1369  {
1371  {
1372  SwFieldType* pFieldType = pDoc->getIDocumentFieldsAccess().GetSysFieldType(SwFieldIds::Postit);
1373 
1374  DateTime aDateTime( DateTime::EMPTY );
1375  if (m_pImpl->m_pProps->pDateTime)
1376  {
1377  aDateTime = *(m_pImpl->m_pProps->pDateTime);
1378  }
1379  SwPostItField* pPostItField = new SwPostItField(
1380  static_cast<SwPostItFieldType*>(pFieldType),
1381  m_pImpl->m_pProps->sPar1, // author
1382  m_pImpl->m_pProps->sPar2, // content
1383  m_pImpl->m_pProps->sPar3, // author's initials
1384  m_pImpl->m_pProps->sPar4, // name
1385  aDateTime,
1386  m_pImpl->m_pProps->bBool1 // resolvedflag
1387  );
1388  if ( m_pImpl->m_xTextObject.is() )
1389  {
1390  pPostItField->SetTextObject( m_pImpl->m_xTextObject->CreateText() );
1391  pPostItField->SetPar2(m_pImpl->m_xTextObject->GetText());
1392  }
1393  xField.reset(pPostItField);
1394  }
1395  break;
1397  {
1398  SwFieldType* pFieldType = pDoc->getIDocumentFieldsAccess().GetSysFieldType(SwFieldIds::Script);
1399  xField.reset(new SwScriptField(static_cast<SwScriptFieldType*>(pFieldType),
1400  m_pImpl->m_pProps->sPar1, m_pImpl->m_pProps->sPar2,
1401  m_pImpl->m_pProps->bBool1));
1402  }
1403  break;
1405  {
1406  sal_uInt16 nSub = 0;
1407  if (m_pImpl->m_pProps->bBool1)
1408  nSub |= FIXEDFLD;
1409  if (m_pImpl->m_pProps->bBool2)
1410  nSub |= DATEFLD;
1411  else
1412  nSub |= TIMEFLD;
1413  SwFieldType* pFieldType = pDoc->getIDocumentFieldsAccess().GetSysFieldType(SwFieldIds::DateTime);
1414  SwDateTimeField *const pDTField = new SwDateTimeField(
1415  static_cast<SwDateTimeFieldType*>(pFieldType),
1416  nSub, m_pImpl->m_pProps->nFormat);
1417  xField.reset(pDTField);
1418  if (m_pImpl->m_pProps->fDouble > 0.)
1419  {
1420  pDTField->SetValue(m_pImpl->m_pProps->fDouble);
1421  }
1422  if (m_pImpl->m_pProps->pDateTime)
1423  {
1424  uno::Any aVal; aVal <<= *m_pImpl->m_pProps->pDateTime;
1425  xField->PutValue( aVal, FIELD_PROP_DATE_TIME );
1426  }
1427  pDTField->SetOffset(m_pImpl->m_pProps->nSubType);
1428  }
1429  break;
1431  {
1432  SwFieldType* pFieldType = pDoc->getIDocumentFieldsAccess().GetSysFieldType(SwFieldIds::Filename);
1433  sal_Int32 nFormat = m_pImpl->m_pProps->nFormat;
1434  if (m_pImpl->m_pProps->bBool2)
1435  nFormat |= FF_FIXED;
1436  SwFileNameField *const pFNField = new SwFileNameField(
1437  static_cast<SwFileNameFieldType*>(pFieldType), nFormat);
1438  xField.reset(pFNField);
1439  if (!m_pImpl->m_pProps->sPar3.isEmpty())
1440  pFNField->SetExpansion(m_pImpl->m_pProps->sPar3);
1441  uno::Any aFormat;
1442  aFormat <<= m_pImpl->m_pProps->nFormat;
1443  xField->PutValue( aFormat, FIELD_PROP_FORMAT );
1444  }
1445  break;
1447  {
1448  SwFieldType* pFieldType = pDoc->getIDocumentFieldsAccess().GetSysFieldType(SwFieldIds::TemplateName);
1449  xField.reset(new SwTemplNameField(static_cast<SwTemplNameFieldType*>(pFieldType),
1450  m_pImpl->m_pProps->nFormat));
1451  uno::Any aFormat;
1452  aFormat <<= m_pImpl->m_pProps->nFormat;
1453  xField->PutValue(aFormat, FIELD_PROP_FORMAT);
1454  }
1455  break;
1457  {
1458  SwFieldType* pFieldType = pDoc->getIDocumentFieldsAccess().GetSysFieldType(SwFieldIds::Chapter);
1459  SwChapterField *const pChapterField = new SwChapterField(
1460  static_cast<SwChapterFieldType*>(pFieldType),
1461  m_pImpl->m_pProps->nUSHORT1);
1462  xField.reset(pChapterField);
1463  pChapterField->SetLevel(m_pImpl->m_pProps->nByte1);
1464  uno::Any aVal;
1465  aVal <<= static_cast<sal_Int16>(m_pImpl->m_pProps->nUSHORT1);
1466  xField->PutValue(aVal, FIELD_PROP_USHORT1 );
1467  }
1468  break;
1470  {
1471  tools::Long nFormat = m_pImpl->m_pProps->bBool1 ? AF_NAME : AF_SHORTCUT;
1472  if (m_pImpl->m_pProps->bBool2)
1473  nFormat |= AF_FIXED;
1474 
1475  SwFieldType* pFieldType = pDoc->getIDocumentFieldsAccess().GetSysFieldType(SwFieldIds::Author);
1476  SwAuthorField *const pAuthorField = new SwAuthorField(
1477  static_cast<SwAuthorFieldType*>(pFieldType), nFormat);
1478  xField.reset(pAuthorField);
1479  pAuthorField->SetExpansion(m_pImpl->m_pProps->sPar1);
1480  }
1481  break;
1484  {
1485  SwFieldType* pFieldType = pDoc->getIDocumentFieldsAccess().GetSysFieldType(SwFieldIds::HiddenText);
1486  SwHiddenTextField *const pHTField = new SwHiddenTextField(
1487  static_cast<SwHiddenTextFieldType*>(pFieldType),
1488  m_pImpl->m_pProps->sPar1,
1489  m_pImpl->m_pProps->sPar2, m_pImpl->m_pProps->sPar3,
1490  SwServiceType::FieldTypeHiddenText == m_pImpl->m_nServiceId ?
1492  xField.reset(pHTField);
1493  pHTField->SetValue(m_pImpl->m_pProps->bBool1);
1494  uno::Any aVal;
1495  aVal <<= m_pImpl->m_pProps->sPar4;
1496  xField->PutValue(aVal, FIELD_PROP_PAR4 );
1497  }
1498  break;
1500  {
1501  SwFieldType* pFieldType = pDoc->getIDocumentFieldsAccess().GetSysFieldType(SwFieldIds::HiddenPara);
1502  SwHiddenParaField *const pHPField = new SwHiddenParaField(
1503  static_cast<SwHiddenParaFieldType*>(pFieldType),
1504  m_pImpl->m_pProps->sPar1);
1505  xField.reset(pHPField);
1506  pHPField->SetHidden(m_pImpl->m_pProps->bBool1);
1507  }
1508  break;
1510  {
1511  SwFieldType* pFieldType = pDoc->getIDocumentFieldsAccess().GetSysFieldType(SwFieldIds::GetRef);
1512  xField.reset(new SwGetRefField(static_cast<SwGetRefFieldType*>(pFieldType),
1513  m_pImpl->m_pProps->sPar1,
1514  m_pImpl->m_pProps->sPar4,
1515  0,
1516  0,
1517  0));
1518  if (!m_pImpl->m_pProps->sPar3.isEmpty())
1519  static_cast<SwGetRefField*>(xField.get())->SetExpand(m_pImpl->m_pProps->sPar3);
1520  uno::Any aVal;
1521  aVal <<= static_cast<sal_Int16>(m_pImpl->m_pProps->nUSHORT1);
1522  xField->PutValue(aVal, FIELD_PROP_USHORT1 );
1523  aVal <<= static_cast<sal_Int16>(m_pImpl->m_pProps->nUSHORT2);
1524  xField->PutValue(aVal, FIELD_PROP_USHORT2 );
1525  aVal <<= m_pImpl->m_pProps->nSHORT1;
1526  xField->PutValue(aVal, FIELD_PROP_SHORT1 );
1527  }
1528  break;
1530  {
1531  SwFieldType* pFieldType = pDoc->getIDocumentFieldsAccess().GetSysFieldType(SwFieldIds::JumpEdit);
1532  xField.reset(new SwJumpEditField(static_cast<SwJumpEditFieldType*>(pFieldType),
1533  m_pImpl->m_pProps->nUSHORT1, m_pImpl->m_pProps->sPar2,
1534  m_pImpl->m_pProps->sPar1));
1535  }
1536  break;
1551  {
1552  SwFieldType* pFieldType = pDoc->getIDocumentFieldsAccess().GetSysFieldType(SwFieldIds::DocInfo);
1553  sal_uInt16 nSubType = aDocInfoSubTypeFromService[
1554  static_cast<sal_uInt16>(m_pImpl->m_nServiceId) - sal_uInt16(SwServiceType::FieldTypeDocInfoChangeAuthor)];
1559  {
1560  if (m_pImpl->m_pProps->bBool2) //IsDate
1561  {
1562  nSubType &= 0xf0ff;
1563  nSubType |= DI_SUB_DATE;
1564  }
1565  else
1566  {
1567  nSubType &= 0xf0ff;
1568  nSubType |= DI_SUB_TIME;
1569  }
1570  }
1571  if (m_pImpl->m_pProps->bBool1)
1572  nSubType |= DI_SUB_FIXED;
1573  xField.reset(new SwDocInfoField(
1574  static_cast<SwDocInfoFieldType*>(pFieldType), nSubType,
1575  m_pImpl->m_pProps->sPar4, m_pImpl->m_pProps->nFormat));
1576  if (!m_pImpl->m_pProps->sPar3.isEmpty())
1577  static_cast<SwDocInfoField*>(xField.get())->SetExpansion(m_pImpl->m_pProps->sPar3);
1578  }
1579  break;
1581  {
1582  sal_Int32 nFormat = 0;
1583  if (m_pImpl->m_pProps->bBool1)
1584  nFormat = AF_FIXED;
1585 
1586  SwFieldType* pFieldType = pDoc->getIDocumentFieldsAccess().GetSysFieldType(SwFieldIds::ExtUser);
1587  SwExtUserField *const pEUField = new SwExtUserField(
1588  static_cast<SwExtUserFieldType*>(pFieldType),
1589  m_pImpl->m_pProps->nUSHORT1, nFormat);
1590  xField.reset(pEUField);
1591  pEUField->SetExpansion(m_pImpl->m_pProps->sPar1);
1592  }
1593  break;
1595  {
1596  SwFieldType* pFieldType =
1597  pDoc->getIDocumentFieldsAccess().GetFieldType(SwFieldIds::User, m_pImpl->m_sTypeName, true);
1598  if (!pFieldType)
1599  throw uno::RuntimeException();
1600  sal_uInt16 nUserSubType = (m_pImpl->m_pProps->bBool1)
1602  if (m_pImpl->m_pProps->bBool2)
1603  nUserSubType |= nsSwExtendedSubType::SUB_CMD;
1604  if (m_pImpl->m_pProps->bFormatIsDefault &&
1605  nsSwGetSetExpType::GSE_STRING == static_cast<SwUserFieldType*>(pFieldType)->GetType())
1606  {
1607  m_pImpl->m_pProps->nFormat = -1;
1608  }
1609  xField.reset(new SwUserField(static_cast<SwUserFieldType*>(pFieldType),
1610  nUserSubType,
1611  m_pImpl->m_pProps->nFormat));
1612  }
1613  break;
1615  {
1616  SwFieldType* pFieldType = pDoc->getIDocumentFieldsAccess().GetSysFieldType(SwFieldIds::RefPageSet);
1617  xField.reset(new SwRefPageSetField( static_cast<SwRefPageSetFieldType*>(pFieldType),
1618  m_pImpl->m_pProps->nUSHORT1,
1619  m_pImpl->m_pProps->bBool1 ));
1620  }
1621  break;
1623  {
1624  SwFieldType* pFieldType = pDoc->getIDocumentFieldsAccess().GetSysFieldType(SwFieldIds::RefPageGet);
1625  SwRefPageGetField *const pRGField = new SwRefPageGetField(
1626  static_cast<SwRefPageGetFieldType*>(pFieldType),
1627  m_pImpl->m_pProps->nUSHORT1 );
1628  xField.reset(pRGField);
1629  pRGField->SetText(m_pImpl->m_pProps->sPar1, nullptr);
1630  }
1631  break;
1633  {
1634  SwFieldType* pFieldType = pDoc->getIDocumentFieldsAccess().GetSysFieldType(SwFieldIds::PageNumber);
1635  SwPageNumberField *const pPNField = new SwPageNumberField(
1636  static_cast<SwPageNumberFieldType*>(pFieldType), PG_RANDOM,
1637  m_pImpl->m_pProps->nFormat,
1638  m_pImpl->m_pProps->nUSHORT1);
1639  xField.reset(pPNField);
1640  pPNField->SetUserString(m_pImpl->m_pProps->sPar1);
1641  uno::Any aVal;
1642  aVal <<= m_pImpl->m_pProps->nSubType;
1643  xField->PutValue( aVal, FIELD_PROP_SUBTYPE );
1644  }
1645  break;
1647  {
1648  SwFieldType* pFieldType =
1649  pDoc->getIDocumentFieldsAccess().GetFieldType(SwFieldIds::Dde, m_pImpl->m_sTypeName, true);
1650  if (!pFieldType)
1651  throw uno::RuntimeException();
1652  xField.reset(new SwDDEField( static_cast<SwDDEFieldType*>(pFieldType) ));
1653  }
1654  break;
1656  {
1657  SwFieldType* pFieldType = pDoc->getIDocumentFieldsAccess().GetSysFieldType(SwFieldIds::DatabaseName);
1658  SwDBData aData;
1659  aData.sDataSource = m_pImpl->m_pProps->sPar1;
1660  aData.sCommand = m_pImpl->m_pProps->sPar2;
1661  aData.nCommandType = m_pImpl->m_pProps->nSHORT1;
1662  xField.reset(new SwDBNameField(static_cast<SwDBNameFieldType*>(pFieldType), aData));
1663  sal_uInt16 nSubType = xField->GetSubType();
1664  if (m_pImpl->m_pProps->bBool2)
1666  else
1668  xField->SetSubType(nSubType);
1669  }
1670  break;
1672  {
1673  SwDBData aData;
1674  aData.sDataSource = m_pImpl->m_pProps->sPar1;
1675  aData.sCommand = m_pImpl->m_pProps->sPar2;
1676  aData.nCommandType = m_pImpl->m_pProps->nSHORT1;
1677  SwFieldType* pFieldType = pDoc->getIDocumentFieldsAccess().GetSysFieldType(SwFieldIds::DbNextSet);
1678  xField.reset(new SwDBNextSetField(static_cast<SwDBNextSetFieldType*>(pFieldType),
1679  m_pImpl->m_pProps->sPar3, aData));
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;
1688  xField.reset(new SwDBNumSetField( static_cast<SwDBNumSetFieldType*>(
1689  pDoc->getIDocumentFieldsAccess().GetSysFieldType(SwFieldIds::DbNumSet)),
1690  m_pImpl->m_pProps->sPar3,
1691  OUString::number(m_pImpl->m_pProps->nFormat),
1692  aData ));
1693  }
1694  break;
1696  {
1697  SwDBData aData;
1698  aData.sDataSource = m_pImpl->m_pProps->sPar1;
1699  aData.sCommand = m_pImpl->m_pProps->sPar2;
1700  aData.nCommandType = m_pImpl->m_pProps->nSHORT1;
1701  SwDBSetNumberField *const pDBSNField =
1702  new SwDBSetNumberField(static_cast<SwDBSetNumberFieldType*>(
1703  pDoc->getIDocumentFieldsAccess().GetSysFieldType(SwFieldIds::DbSetNumber)), aData,
1704  m_pImpl->m_pProps->nUSHORT1);
1705  xField.reset(pDBSNField);
1706  pDBSNField->SetSetNumber(m_pImpl->m_pProps->nFormat);
1707  sal_uInt16 nSubType = xField->GetSubType();
1708  if (m_pImpl->m_pProps->bBool2)
1710  else
1712  xField->SetSubType(nSubType);
1713  }
1714  break;
1716  {
1717  SwFieldType* pFieldType =
1718  pDoc->getIDocumentFieldsAccess().GetFieldType(SwFieldIds::Database, m_pImpl->m_sTypeName, false);
1719  if (!pFieldType)
1720  throw uno::RuntimeException();
1721  xField.reset(new SwDBField(static_cast<SwDBFieldType*>(pFieldType),
1722  m_pImpl->m_pProps->nFormat));
1723  static_cast<SwDBField*>(xField.get())->InitContent(m_pImpl->m_pProps->sPar1);
1724  sal_uInt16 nSubType = xField->GetSubType();
1725  if (m_pImpl->m_pProps->bBool2)
1727  else
1729  xField->SetSubType(nSubType);
1730  }
1731  break;
1733  {
1734  SwFieldType* pFieldType =
1735  pDoc->getIDocumentFieldsAccess().GetFieldType(SwFieldIds::SetExp, m_pImpl->m_sTypeName, true);
1736  if (!pFieldType)
1737  throw uno::RuntimeException();
1738  // detect the field type's sub type and set an appropriate number format
1739  if (m_pImpl->m_pProps->bFormatIsDefault &&
1740  nsSwGetSetExpType::GSE_STRING == static_cast<SwSetExpFieldType*>(pFieldType)->GetType())
1741  {
1742  m_pImpl->m_pProps->nFormat = -1;
1743  }
1744  SwSetExpField *const pSEField = new SwSetExpField(
1745  static_cast<SwSetExpFieldType*>(pFieldType),
1746  m_pImpl->m_pProps->sPar2,
1747  m_pImpl->m_pProps->nUSHORT2 != USHRT_MAX ? //#i79471# the field can have a number format or a number_ing_ format
1748  m_pImpl->m_pProps->nUSHORT2 : m_pImpl->m_pProps->nFormat);
1749  xField.reset(pSEField);
1750 
1751  sal_uInt16 nSubType = xField->GetSubType();
1752  if (m_pImpl->m_pProps->bBool2)
1754  else
1756  if (m_pImpl->m_pProps->bBool3)
1757  nSubType |= nsSwExtendedSubType::SUB_CMD;
1758  else
1759  nSubType &= ~nsSwExtendedSubType::SUB_CMD;
1760  xField->SetSubType(nSubType);
1761  pSEField->SetSeqNumber(m_pImpl->m_pProps->nUSHORT1);
1762  pSEField->SetInputFlag(m_pImpl->m_pProps->bBool1);
1763  pSEField->SetPromptText(m_pImpl->m_pProps->sPar3);
1764  if (!m_pImpl->m_pProps->sPar4.isEmpty())
1765  pSEField->ChgExpStr(m_pImpl->m_pProps->sPar4, nullptr);
1766 
1767  }
1768  break;
1770  {
1771  sal_uInt16 nSubType;
1772  switch (m_pImpl->m_pProps->nSubType)
1773  {
1774  case text::SetVariableType::STRING: nSubType = nsSwGetSetExpType::GSE_STRING; break;
1775  case text::SetVariableType::VAR: nSubType = nsSwGetSetExpType::GSE_EXPR; break;
1776  //case text::SetVariableType::SEQUENCE: nSubType = nsSwGetSetExpType::GSE_SEQ; break;
1777  case text::SetVariableType::FORMULA: nSubType = nsSwGetSetExpType::GSE_FORMULA; break;
1778  default:
1779  OSL_FAIL("wrong value");
1780  nSubType = nsSwGetSetExpType::GSE_EXPR;
1781  }
1782  //make sure the SubType matches the field type
1783  SwFieldType* pSetExpField = pDoc->getIDocumentFieldsAccess().GetFieldType(
1784  SwFieldIds::SetExp, m_pImpl->m_pProps->sPar1, false);
1785  bool bSetGetExpFieldUninitialized = false;
1786  if (pSetExpField)
1787  {
1788  if (nSubType != nsSwGetSetExpType::GSE_STRING &&
1789  static_cast< SwSetExpFieldType* >(pSetExpField)->GetType() == nsSwGetSetExpType::GSE_STRING)
1790  nSubType = nsSwGetSetExpType::GSE_STRING;
1791  }
1792  else
1793  bSetGetExpFieldUninitialized = true; // #i82544#
1794 
1795  if (m_pImpl->m_pProps->bBool2)
1796  nSubType |= nsSwExtendedSubType::SUB_CMD;
1797  else
1798  nSubType &= ~nsSwExtendedSubType::SUB_CMD;
1799  SwGetExpField *const pGEField = new SwGetExpField(
1800  static_cast<SwGetExpFieldType*>(
1801  pDoc->getIDocumentFieldsAccess().GetSysFieldType(SwFieldIds::GetExp)),
1802  m_pImpl->m_pProps->sPar1, nSubType,
1803  m_pImpl->m_pProps->nFormat);
1804  xField.reset(pGEField);
1805  //TODO: evaluate SubType!
1806  if (!m_pImpl->m_pProps->sPar4.isEmpty())
1807  pGEField->ChgExpStr(m_pImpl->m_pProps->sPar4, nullptr);
1808  // #i82544#
1809  if (bSetGetExpFieldUninitialized)
1810  pGEField->SetLateInitialization();
1811  }
1812  break;
1815  {
1816  SwFieldType* pFieldType =
1817  pDoc->getIDocumentFieldsAccess().GetFieldType(SwFieldIds::Input, m_pImpl->m_sTypeName, true);
1818  if (!pFieldType)
1819  throw uno::RuntimeException();
1820  sal_uInt16 nInpSubType =
1821  sal::static_int_cast<sal_uInt16>(
1823  ? INP_USR : INP_TXT);
1824  SwInputField * pTextField =
1825  new SwInputField(static_cast<SwInputFieldType*>(pFieldType),
1826  m_pImpl->m_pProps->sPar1,
1827  m_pImpl->m_pProps->sPar2,
1828  nInpSubType);
1829  pTextField->SetHelp(m_pImpl->m_pProps->sPar3);
1830  pTextField->SetToolTip(m_pImpl->m_pProps->sPar4);
1831 
1832  xField.reset(pTextField);
1833  }
1834  break;
1836  {
1837  SwFieldType* pFieldType = pDoc->getIDocumentFieldsAccess().GetSysFieldType(SwFieldIds::Macro);
1838  OUString aName;
1839 
1840  // support for Scripting Framework macros
1841  if (!m_pImpl->m_pProps->sPar4.isEmpty())
1842  {
1843  aName = m_pImpl->m_pProps->sPar4;
1844  }
1845  else
1846  {
1848  m_pImpl->m_pProps->sPar1, m_pImpl->m_pProps->sPar3);
1849  }
1850  xField.reset(new SwMacroField(static_cast<SwMacroFieldType*>(pFieldType), aName,
1851  m_pImpl->m_pProps->sPar2));
1852  }
1853  break;
1861  {
1862  sal_uInt16 nSubType = DS_PAGE;
1863  switch (m_pImpl->m_nServiceId)
1864  {
1865  case SwServiceType::FieldTypeParagraphCount : nSubType = DS_PARA; break;
1866  case SwServiceType::FieldTypeWordCount : nSubType = DS_WORD; break;
1867  case SwServiceType::FieldTypeCharacterCount : nSubType = DS_CHAR; break;
1868  case SwServiceType::FieldTypeTableCount : nSubType = DS_TBL; break;
1869  case SwServiceType::FieldTypeGraphicObjectCount : nSubType = DS_GRF; break;
1870  case SwServiceType::FieldTypeEmbeddedObjectCount : nSubType = DS_OLE; break;
1871  default: break;
1872  }
1873  SwFieldType* pFieldType = pDoc->getIDocumentFieldsAccess().GetSysFieldType(SwFieldIds::DocStat);
1874  xField.reset(new SwDocStatField(
1875  static_cast<SwDocStatFieldType*>(pFieldType),
1876  nSubType, m_pImpl->m_pProps->nUSHORT2));
1877  }
1878  break;
1880  {
1881  SwAuthorityFieldType const type(pDoc);
1882  xField.reset(new SwAuthorityField(static_cast<SwAuthorityFieldType*>(
1883  pDoc->getIDocumentFieldsAccess().InsertFieldType(type)),
1884  OUString()));
1885  if (m_pImpl->m_pProps->aPropSeq.hasElements())
1886  {
1887  uno::Any aVal;
1888  aVal <<= m_pImpl->m_pProps->aPropSeq;
1889  xField->PutValue( aVal, FIELD_PROP_PROP_SEQ );
1890  }
1891  }
1892  break;
1894  // create field
1895  xField.reset(new SwCombinedCharField( static_cast<SwCombinedCharFieldType*>(
1896  pDoc->getIDocumentFieldsAccess().GetSysFieldType(SwFieldIds::CombinedChars)),
1897  m_pImpl->m_pProps->sPar1));
1898  break;
1900  {
1901  SwDropDownField *const pDDField = new SwDropDownField(
1902  static_cast<SwDropDownFieldType *>(
1903  pDoc->getIDocumentFieldsAccess().GetSysFieldType(SwFieldIds::Dropdown)));
1904  xField.reset(pDDField);
1905 
1906  pDDField->SetItems(m_pImpl->m_pProps->aStrings);
1907  pDDField->SetSelectedItem(m_pImpl->m_pProps->sPar1);
1908  pDDField->SetName(m_pImpl->m_pProps->sPar2);
1909  pDDField->SetHelp(m_pImpl->m_pProps->sPar3);
1910  pDDField->SetToolTip(m_pImpl->m_pProps->sPar4);
1911  }
1912  break;
1913 
1915  {
1916  // create field
1918  if (m_pImpl->m_pProps->bBool1)
1919  {
1921  if (m_pImpl->m_pProps->bFormatIsDefault)
1922  m_pImpl->m_pProps->nFormat = -1;
1923  }
1924  xField.reset(new SwTableField( static_cast<SwTableFieldType*>(
1925  pDoc->getIDocumentFieldsAccess().GetSysFieldType(SwFieldIds::Table)),
1926  m_pImpl->m_pProps->sPar2,
1927  nType,
1928  m_pImpl->m_pProps->nFormat));
1929  static_cast<SwTableField*>(xField.get())->ChgExpStr(m_pImpl->m_pProps->sPar1);
1930  }
1931  break;
1932  default: OSL_FAIL("What kind of type is that?");
1933  }
1934 
1935  if (!xField)
1936  throw uno::RuntimeException("no SwField created?");
1937 
1938  xField->SetAutomaticLanguage(!m_pImpl->m_pProps->bBool4);
1939  SwFormatField aFormat(*xField);
1940 
1941  UnoActionContext aCont(pDoc);
1942  if (aPam.HasMark() &&
1944  {
1945  pDoc->getIDocumentContentOperations().DeleteAndJoin(aPam);
1946  }
1947 
1948  SwXTextCursor const*const pTextCursor(dynamic_cast<SwXTextCursor*>(pCursor));
1949  const bool bForceExpandHints(
1950  pTextCursor
1951  && pTextCursor->IsAtEndOfMeta() );
1952  const SetAttrMode nInsertFlags =
1953  bForceExpandHints
1956 
1957  if (*aPam.GetPoint() != *aPam.GetMark() &&
1959  {
1960  // Make sure we always insert the field at the end
1961  SwPaM aEnd(*aPam.End(), *aPam.End());
1962  pDoc->getIDocumentContentOperations().InsertPoolItem(aEnd, aFormat, nInsertFlags);
1963  }
1964  else
1965  pDoc->getIDocumentContentOperations().InsertPoolItem(aPam, aFormat, nInsertFlags);
1966 
1967  SwTextAttr* pTextAttr = aPam.GetNode().GetTextNode()->GetFieldTextAttrAt( aPam.GetPoint()->nContent.GetIndex()-1, true );
1968 
1969  // What about updating the fields? (see fldmgr.cxx)
1970  if (!pTextAttr)
1971  throw uno::RuntimeException("no SwTextAttr inserted?"); // could theoretically happen, if paragraph is full
1972 
1973  const SwFormatField& rField = pTextAttr->GetFormatField();
1974  m_pImpl->SetFormatField(const_cast<SwFormatField*>(&rField), pDoc);
1975 
1976  if ( pTextAttr->Which() == RES_TXTATR_ANNOTATION
1977  && *aPam.GetPoint() != *aPam.GetMark() )
1978  {
1979  // create annotation mark
1980  const SwPostItField* pPostItField = dynamic_cast< const SwPostItField* >(pTextAttr->GetFormatField().GetField());
1981  OSL_ENSURE( pPostItField != nullptr, "<SwXTextField::attachToRange(..)> - annotation field missing!" );
1982  if ( pPostItField != nullptr )
1983  {
1984  IDocumentMarkAccess* pMarksAccess = pDoc->getIDocumentMarkAccess();
1985  pMarksAccess->makeAnnotationMark( aPam, pPostItField->GetName() );
1986  }
1987  }
1988 
1989  xField.reset();
1990 
1991  assert(m_pImpl->GetFormatField());
1992  m_pImpl->m_pDoc = pDoc;
1993  m_pImpl->GetFormatField()->SetXTextField(this);
1994  m_pImpl->m_wThis = *this;
1995  m_pImpl->m_bIsDescriptor = false;
1996  m_pImpl->ClearFieldType();
1997  m_pImpl->m_pProps.reset();
1998  if (m_pImpl->m_bCallUpdate)
1999  update();
2000  }
2001  else if ( !m_pImpl->IsDescriptor()
2002  && m_pImpl->m_pDoc != nullptr
2003  && m_pImpl->m_nServiceId == SwServiceType::FieldTypeAnnotation )
2004  {
2005  SwUnoInternalPaM aIntPam( *m_pImpl->m_pDoc );
2006  if ( !::sw::XTextRangeToSwPaM( aIntPam, xTextRange ) )
2007  throw lang::IllegalArgumentException();
2008 
2009  // Nothing to do, if the text range has a separate start and end, but they have the same
2010  // value.
2011  if (!aIntPam.HasMark() || *aIntPam.Start() != *aIntPam.End())
2012  {
2013  UnoActionContext aCont( m_pImpl->m_pDoc );
2014  // insert copy of annotation at new text range
2015  std::unique_ptr<SwPostItField> pPostItField(static_cast< SwPostItField* >(m_pImpl->GetFormatField()->GetField()->CopyField().release()));
2016  SwFormatField aFormatField( *pPostItField );
2017  pPostItField.reset();
2018  SwPaM aEnd( *aIntPam.End(), *aIntPam.End() );
2019  m_pImpl->m_pDoc->getIDocumentContentOperations().InsertPoolItem( aEnd, aFormatField );
2020  // delete former annotation
2021  {
2022  const SwTextField* pTextField = m_pImpl->GetFormatField()->GetTextField();
2023  SwTextNode& rTextNode = *pTextField->GetpTextNode();
2024  SwPaM aPam( rTextNode, pTextField->GetStart() );
2025  aPam.SetMark();
2026  aPam.Move();
2027  m_pImpl->m_pDoc->getIDocumentContentOperations().DeleteAndJoin(aPam);
2028  }
2029  // keep inserted annotation
2030  {
2031  SwTextField* pTextAttr = aEnd.GetNode().GetTextNode()->GetFieldTextAttrAt( aEnd.End()->nContent.GetIndex()-1, true );
2032  if ( pTextAttr != nullptr )
2033  {
2034  m_pImpl->SetFormatField(const_cast<SwFormatField*>(&pTextAttr->GetFormatField()), m_pImpl->m_pDoc);
2035 
2036  if ( *aIntPam.GetPoint() != *aIntPam.GetMark() )
2037  {
2038  // create annotation mark
2039  const SwPostItField* pField = dynamic_cast< const SwPostItField* >(pTextAttr->GetFormatField().GetField());
2040  OSL_ENSURE( pField != nullptr, "<SwXTextField::attach(..)> - annotation field missing!" );
2041  if ( pField != nullptr )
2042  {
2043  IDocumentMarkAccess* pMarksAccess = aIntPam.GetDoc().getIDocumentMarkAccess();
2044  pMarksAccess->makeAnnotationMark( aIntPam, pField->GetName() );
2045  }
2046  }
2047  }
2048  }
2049  }
2050 
2051  }
2052  else
2053  throw lang::IllegalArgumentException();
2054 }
2055 
2056 uno::Reference< text::XTextRange > SAL_CALL
2058 {
2059  SolarMutexGuard aGuard;
2060 
2061  SwField const*const pField = m_pImpl->GetField();
2062  if (!pField)
2063  return nullptr;
2064 
2065  const SwTextField* pTextField = m_pImpl->GetFormatField()->GetTextField();
2066  if (!pTextField)
2067  throw uno::RuntimeException();
2068 
2069  std::shared_ptr< SwPaM > pPamForTextField;
2070  SwTextField::GetPamForTextField(*pTextField, pPamForTextField);
2071  if (pPamForTextField == nullptr)
2072  return nullptr;
2073 
2074  // If this is a postit field, then return the range of its annotation mark if it has one.
2075  if (pField->Which() == SwFieldIds::Postit)
2076  {
2077  const SwPostItField* pPostItField = static_cast<const SwPostItField*>(pField);
2078  IDocumentMarkAccess* pMarkAccess = m_pImpl->m_pDoc->getIDocumentMarkAccess();
2079  for (IDocumentMarkAccess::const_iterator_t ppMark = pMarkAccess->getAnnotationMarksBegin(); ppMark != pMarkAccess->getAnnotationMarksEnd(); ++ppMark)
2080  {
2081  if ((*ppMark)->GetName() == pPostItField->GetName())
2082  {
2083  pPamForTextField = std::make_shared<SwPaM>((*ppMark)->GetMarkStart(), (*ppMark)->GetMarkEnd());
2084  break;
2085  }
2086  }
2087  }
2088 
2089  uno::Reference<text::XTextRange> xRange = SwXTextRange::CreateXTextRange(
2090  *m_pImpl->m_pDoc, *(pPamForTextField->GetPoint()), pPamForTextField->GetMark());
2091  return xRange;
2092 }
2093 
2094 void SAL_CALL SwXTextField::dispose()
2095 {
2096  SolarMutexGuard aGuard;
2097  SwField const*const pField = m_pImpl->GetField();
2098  if(pField && m_pImpl->m_pDoc)
2099  {
2100  UnoActionContext aContext(m_pImpl->m_pDoc);
2101  assert(m_pImpl->GetFormatField()->GetTextField() && "<SwXTextField::dispose()> - missing <SwTextField> --> crash");
2102  SwTextField::DeleteTextField(*(m_pImpl->GetFormatField()->GetTextField()));
2103  }
2104 
2105  if (m_pImpl->m_xTextObject.is())
2106  {
2107  m_pImpl->m_xTextObject->DisposeEditSource();
2108  m_pImpl->m_xTextObject.clear();
2109  }
2110  m_pImpl->Invalidate();
2111 }
2112 
2114  const uno::Reference<lang::XEventListener> & xListener)
2115 {
2116  // no need to lock here as m_pImpl is const and container threadsafe
2117  m_pImpl->m_EventListeners.addInterface(xListener);
2118 }
2119 
2121  const uno::Reference<lang::XEventListener> & xListener)
2122 {
2123  // no need to lock here as m_pImpl is const and container threadsafe
2124  m_pImpl->m_EventListeners.removeInterface(xListener);
2125 }
2126 
2127 uno::Reference< beans::XPropertySetInfo > SAL_CALL
2129 {
2130  SolarMutexGuard aGuard;
2131  // no static
2132  uno::Reference< beans::XPropertySetInfo > aRef;
2133  if (m_pImpl->m_nServiceId == SwServiceType::Invalid)
2134  {
2135  throw uno::RuntimeException();
2136  }
2138  lcl_GetPropertyMapOfService(m_pImpl->m_nServiceId));
2139  const uno::Reference<beans::XPropertySetInfo>& xInfo = pPropSet->getPropertySetInfo();
2140  // extend PropertySetInfo!
2141  const uno::Sequence<beans::Property> aPropSeq = xInfo->getProperties();
2142  aRef = new SfxExtItemPropertySetInfo(
2144  aPropSeq );
2145  return aRef;
2146 }
2147 
2148 void SAL_CALL
2150  const OUString& rPropertyName, const uno::Any& rValue)
2151 {
2152  SolarMutexGuard aGuard;
2153  SwField const*const pField = m_pImpl->GetField();
2155  lcl_GetPropertyMapOfService(m_pImpl->m_nServiceId));
2156  const SfxItemPropertyMapEntry* pEntry = _pPropSet->getPropertyMap().getByName(rPropertyName);
2157 
2158  if (!pEntry)
2159  throw beans::UnknownPropertyException( "Unknown property: " + rPropertyName, static_cast < cppu::OWeakObject * > ( this ) );
2160  if ( pEntry->nFlags & beans::PropertyAttribute::READONLY)
2161  throw beans::PropertyVetoException( "Property is read-only: " + rPropertyName, static_cast < cppu::OWeakObject * > ( this ) );
2162 
2163  if(pField)
2164  {
2165  // special treatment for mail merge fields
2166  const SwFieldIds nWhich = pField->Which();
2167  if( SwFieldIds::Database == nWhich &&
2168  (rPropertyName == UNO_NAME_DATA_BASE_NAME ||
2169  rPropertyName == UNO_NAME_DATA_BASE_URL||
2170  rPropertyName == UNO_NAME_DATA_TABLE_NAME||
2171  rPropertyName == UNO_NAME_DATA_COLUMN_NAME))
2172  {
2173  // here a new field type must be created and the field must
2174  // be registered at the new type
2175  OSL_FAIL("not implemented");
2176  }
2177  else
2178  {
2179  SwDoc * pDoc = m_pImpl->m_pDoc;
2180  assert(pDoc);
2181  const SwTextField* pTextField = m_pImpl->GetFormatField()->GetTextField();
2182  if(!pTextField)
2183  throw uno::RuntimeException();
2184  SwPosition aPosition( pTextField->GetTextNode() );
2185  aPosition.nContent = pTextField->GetStart();
2186  pDoc->getIDocumentFieldsAccess().PutValueToField( aPosition, rValue, pEntry->nWID);
2187  }
2188 
2189  //#i100374# notify SwPostIt about new field content
2190  assert(m_pImpl->GetFormatField());
2191  if (SwFieldIds::Postit == nWhich)
2192  {
2193  m_pImpl->GetFormatField()->Broadcast(
2195  }
2196 
2197  // fdo#42073 notify SwTextField about changes of the expanded string
2198  if (m_pImpl->GetFormatField()->GetTextField())
2199  {
2200  m_pImpl->GetFormatField()->GetTextField()->ExpandTextField();
2201  }
2202 
2203  //#i100374# changing a document field should set the modify flag
2204  SwDoc* pDoc = m_pImpl->m_pDoc;
2205  if (pDoc)
2206  pDoc->getIDocumentState().SetModified();
2207 
2208  }
2209  else if (m_pImpl->m_pProps)
2210  {
2211  bool* pBool = nullptr;
2212  switch(pEntry->nWID)
2213  {
2214  case FIELD_PROP_PAR1:
2215  rValue >>= m_pImpl->m_pProps->sPar1;
2216  break;
2217  case FIELD_PROP_PAR2:
2218  rValue >>= m_pImpl->m_pProps->sPar2;
2219  break;
2220  case FIELD_PROP_PAR3:
2221  rValue >>= m_pImpl->m_pProps->sPar3;
2222  break;
2223  case FIELD_PROP_PAR4:
2224  rValue >>= m_pImpl->m_pProps->sPar4;
2225  break;
2226  case FIELD_PROP_FORMAT:
2227  rValue >>= m_pImpl->m_pProps->nFormat;
2228  m_pImpl->m_pProps->bFormatIsDefault = false;
2229  break;
2230  case FIELD_PROP_SUBTYPE:
2231  m_pImpl->m_pProps->nSubType = SWUnoHelper::GetEnumAsInt32(rValue);
2232  break;
2233  case FIELD_PROP_BYTE1 :
2234  rValue >>= m_pImpl->m_pProps->nByte1;
2235  break;
2236  case FIELD_PROP_BOOL1 :
2237  pBool = &m_pImpl->m_pProps->bBool1;
2238  break;
2239  case FIELD_PROP_BOOL2 :
2240  pBool = &m_pImpl->m_pProps->bBool2;
2241  break;
2242  case FIELD_PROP_BOOL3 :
2243  pBool = &m_pImpl->m_pProps->bBool3;
2244  break;
2245  case FIELD_PROP_BOOL4:
2246  pBool = &m_pImpl->m_pProps->bBool4;
2247  break;
2248  case FIELD_PROP_DATE :
2249  {
2250  auto aTemp = o3tl::tryAccess<util::Date>(rValue);
2251  if(!aTemp)
2252  throw lang::IllegalArgumentException();
2253 
2254  m_pImpl->m_pProps->aDate = Date(aTemp->Day, aTemp->Month, aTemp->Year);
2255  }
2256  break;
2257  case FIELD_PROP_USHORT1:
2258  case FIELD_PROP_USHORT2:
2259  {
2260  sal_Int16 nVal = 0;
2261  rValue >>= nVal;
2262  if( FIELD_PROP_USHORT1 == pEntry->nWID)
2263  m_pImpl->m_pProps->nUSHORT1 = nVal;
2264  else
2265  m_pImpl->m_pProps->nUSHORT2 = nVal;
2266  }
2267  break;
2268  case FIELD_PROP_SHORT1:
2269  rValue >>= m_pImpl->m_pProps->nSHORT1;
2270  break;
2271  case FIELD_PROP_DOUBLE:
2272  if(rValue.getValueType() != ::cppu::UnoType<double>::get())
2273  throw lang::IllegalArgumentException();
2274  rValue >>= m_pImpl->m_pProps->fDouble;
2275  break;
2276 
2277  case FIELD_PROP_DATE_TIME :
2278  if (!m_pImpl->m_pProps->pDateTime)
2279  m_pImpl->m_pProps->pDateTime.reset( new util::DateTime );
2280  rValue >>= *m_pImpl->m_pProps->pDateTime;
2281  break;
2282  case FIELD_PROP_PROP_SEQ:
2283  rValue >>= m_pImpl->m_pProps->aPropSeq;
2284  break;
2285  case FIELD_PROP_STRINGS:
2286  rValue >>= m_pImpl->m_pProps->aStrings;
2287  break;
2288  }
2289  if (pBool)
2290  {
2291  auto b = o3tl::tryAccess<bool>(rValue);
2292  if( !b )
2293  throw lang::IllegalArgumentException();
2294  *pBool = *b;
2295 
2296  }
2297  }
2298  else
2299  throw uno::RuntimeException();
2300 }
2301 
2302 uno::Any SAL_CALL SwXTextField::getPropertyValue(const OUString& rPropertyName)
2303 {
2304  SolarMutexGuard aGuard;
2305  uno::Any aRet;
2306  SwField const*const pField = m_pImpl->GetField();
2308  lcl_GetPropertyMapOfService(m_pImpl->m_nServiceId));
2309  const SfxItemPropertyMapEntry* pEntry = _pPropSet->getPropertyMap().getByName(rPropertyName);
2310  if(!pEntry )
2311  {
2313  pEntry = _pParaPropSet->getPropertyMap().getByName(rPropertyName);
2314  }
2315  if (!pEntry)
2316  throw beans::UnknownPropertyException( "Unknown property: " + rPropertyName, static_cast < cppu::OWeakObject * > ( this ) );
2317 
2318  switch( pEntry->nWID )
2319  {
2320  case FN_UNO_TEXT_WRAP:
2321  aRet <<= text::WrapTextMode_NONE;
2322  break;
2323  case FN_UNO_ANCHOR_TYPE:
2324  aRet <<= text::TextContentAnchorType_AS_CHARACTER;
2325  break;
2326  case FN_UNO_ANCHOR_TYPES:
2327  {
2328  uno::Sequence<text::TextContentAnchorType> aTypes { text::TextContentAnchorType_AS_CHARACTER };
2329  aRet <<= aTypes;
2330  }
2331  break;
2332 
2333  default:
2334  if( pField )
2335  {
2336  if (FIELD_PROP_IS_FIELD_USED == pEntry->nWID ||
2338  {
2339  bool bIsFieldUsed = false;
2340  bool bIsFieldDisplayed = false;
2341 
2342  // in order to have the information about fields
2343  // correctly evaluated the document needs a layout
2344  // (has to be already formatted)
2345  SwDoc *pDoc = m_pImpl->m_pDoc;
2346  SwViewShell *pViewShell = nullptr;
2347  SwEditShell *pEditShell = nullptr;
2348  if( pDoc )
2349  {
2350  pViewShell = pDoc->getIDocumentLayoutAccess().GetCurrentViewShell();
2351  pEditShell = pDoc->GetEditShell();
2352  }
2353 
2354  if (pEditShell)
2355  pEditShell->CalcLayout();
2356  else if (pViewShell) // a page preview has no SwEditShell it should only have a view shell
2357  pViewShell->CalcLayout();
2358  else
2359  throw uno::RuntimeException();
2360 
2361  // get text node for the text field
2362  const SwFormatField *pFieldFormat =
2363  (m_pImpl->GetField()) ? m_pImpl->GetFormatField() : nullptr;
2364  const SwTextField* pTextField = pFieldFormat
2365  ? m_pImpl->GetFormatField()->GetTextField() : nullptr;
2366  if(!pTextField)
2367  throw uno::RuntimeException();
2368  const SwTextNode& rTextNode = pTextField->GetTextNode();
2369 
2370  // skip fields that are currently not in the document
2371  // e.g. fields in undo or redo array
2372  if (rTextNode.GetNodes().IsDocNodes())
2373  {
2374  bool bFrame = 0 != rTextNode.FindLayoutRect().Width(); // or so
2375  bool bHidden = rTextNode.IsHidden();
2376  if ( !bHidden )
2377  {
2378  sal_Int32 nHiddenStart;
2379  sal_Int32 nHiddenEnd;
2380  bHidden = SwScriptInfo::GetBoundsOfHiddenRange( pTextField->GetTextNode(),
2381  pTextField->GetStart(),
2382  nHiddenStart, nHiddenEnd );
2383  }
2384 
2385  // !bFrame && !bHidden: most probably a field in an unused page style
2386 
2387  // FME: Problem: hidden field in unused page template =>
2388  // bIsFieldUsed = true
2389  // bIsFieldDisplayed = false
2390  bIsFieldUsed = bFrame || bHidden;
2391  bIsFieldDisplayed = bIsFieldUsed && !bHidden;
2392  }
2393  aRet <<= (FIELD_PROP_IS_FIELD_USED == pEntry->nWID) ? bIsFieldUsed : bIsFieldDisplayed;
2394  }
2395  else
2396  pField->QueryValue( aRet, pEntry->nWID );
2397  }
2398  else if (m_pImpl->m_pProps) // currently just a descriptor...
2399  {
2400  switch(pEntry->nWID)
2401  {
2402  case FIELD_PROP_TEXT:
2403  {
2404  if (!m_pImpl->m_xTextObject.is())
2405  {
2406  m_pImpl->m_xTextObject
2407  = new SwTextAPIObject( std::make_unique<SwTextAPIEditSource>(m_pImpl->m_pDoc) );
2408  }
2409 
2410  uno::Reference<text::XText> xText(m_pImpl->m_xTextObject);
2411  aRet <<= xText;
2412  break;
2413  }
2414  case FIELD_PROP_PAR1:
2415  aRet <<= m_pImpl->m_pProps->sPar1;
2416  break;
2417  case FIELD_PROP_PAR2:
2418  aRet <<= m_pImpl->m_pProps->sPar2;
2419  break;
2420  case FIELD_PROP_PAR3:
2421  aRet <<= m_pImpl->m_pProps->sPar3;
2422  break;
2423  case FIELD_PROP_PAR4:
2424  aRet <<= m_pImpl->m_pProps->sPar4;
2425  break;
2426  case FIELD_PROP_FORMAT:
2427  aRet <<= m_pImpl->m_pProps->nFormat;
2428  break;
2429  case FIELD_PROP_SUBTYPE:
2430  aRet <<= m_pImpl->m_pProps->nSubType;
2431  break;
2432  case FIELD_PROP_BYTE1 :
2433  aRet <<= m_pImpl->m_pProps->nByte1;
2434  break;
2435  case FIELD_PROP_BOOL1 :
2436  aRet <<= m_pImpl->m_pProps->bBool1;
2437  break;
2438  case FIELD_PROP_BOOL2 :
2439  aRet <<= m_pImpl->m_pProps->bBool2;
2440  break;
2441  case FIELD_PROP_BOOL3 :
2442  aRet <<= m_pImpl->m_pProps->bBool3;
2443  break;
2444  case FIELD_PROP_BOOL4 :
2445  aRet <<= m_pImpl->m_pProps->bBool4;
2446  break;
2447  case FIELD_PROP_DATE :
2448  aRet <<= m_pImpl->m_pProps->aDate.GetUNODate();
2449  break;
2450  case FIELD_PROP_USHORT1:
2451  aRet <<= static_cast<sal_Int16>(m_pImpl->m_pProps->nUSHORT1);
2452  break;
2453  case FIELD_PROP_USHORT2:
2454  aRet <<= static_cast<sal_Int16>(m_pImpl->m_pProps->nUSHORT2);
2455  break;
2456  case FIELD_PROP_SHORT1:
2457  aRet <<= m_pImpl->m_pProps->nSHORT1;
2458  break;
2459  case FIELD_PROP_DOUBLE:
2460  aRet <<= m_pImpl->m_pProps->fDouble;
2461  break;
2462  case FIELD_PROP_DATE_TIME :
2463  if (m_pImpl->m_pProps->pDateTime)
2464  aRet <<= *m_pImpl->m_pProps->pDateTime;
2465  break;
2466  case FIELD_PROP_PROP_SEQ:
2467  aRet <<= m_pImpl->m_pProps->aPropSeq;
2468  break;
2469  case FIELD_PROP_STRINGS:
2470  aRet <<= m_pImpl->m_pProps->aStrings;
2471  break;
2474  aRet <<= false;
2475  break;
2476  }
2477  }
2478  else
2479  throw uno::RuntimeException();
2480  }
2481  return aRet;
2482 }
2483 
2484 void SwXTextField::addPropertyChangeListener(const OUString& /*PropertyName*/, const uno::Reference< beans::XPropertyChangeListener > & /*aListener*/)
2485 {
2486  OSL_FAIL("not implemented");
2487 }
2488 
2489 void SwXTextField::removePropertyChangeListener(const OUString& /*PropertyName*/, const uno::Reference< beans::XPropertyChangeListener > & /*aListener*/)
2490 {
2491  OSL_FAIL("not implemented");
2492 }
2493 
2494 void SwXTextField::addVetoableChangeListener(const OUString& /*PropertyName*/, const uno::Reference< beans::XVetoableChangeListener > & /*aListener*/)
2495 {
2496  OSL_FAIL("not implemented");
2497 }
2498 
2499 void SwXTextField::removeVetoableChangeListener(const OUString& /*PropertyName*/, const uno::Reference< beans::XVetoableChangeListener > & /*aListener*/)
2500 {
2501  OSL_FAIL("not implemented");
2502 }
2503 
2504 void SAL_CALL SwXTextField::update()
2505 {
2506  SolarMutexGuard aGuard;
2507  SwField * pField = const_cast<SwField*>(m_pImpl->GetField());
2508  if (pField)
2509  {
2510  switch(pField->Which())
2511  {
2512  case SwFieldIds::DateTime:
2513  static_cast<SwDateTimeField*>(pField)->SetDateTime( ::DateTime( ::DateTime::SYSTEM ) );
2514  break;
2515 
2516  case SwFieldIds::ExtUser:
2517  {
2518  SwExtUserField* pExtUserField = static_cast<SwExtUserField*>(pField);
2519  pExtUserField->SetExpansion( SwExtUserFieldType::Expand(
2520  pExtUserField->GetSubType() ) );
2521  }
2522  break;
2523 
2524  case SwFieldIds::Author:
2525  {
2526  SwAuthorField* pAuthorField = static_cast<SwAuthorField*>(pField);
2527  pAuthorField->SetExpansion( SwAuthorFieldType::Expand(
2528  pAuthorField->GetFormat() ) );
2529  }
2530  break;
2531 
2532  case SwFieldIds::Filename:
2533  {
2534  SwFileNameField* pFileNameField = static_cast<SwFileNameField*>(pField);
2535  pFileNameField->SetExpansion( static_cast<SwFileNameFieldType*>(pField->GetTyp())->Expand(
2536  pFileNameField->GetFormat() ) );
2537  }
2538  break;
2539 
2540  case SwFieldIds::DocInfo:
2541  {
2542  SwDocInfoField* pDocInfField = static_cast<SwDocInfoField*>(pField);
2543  pDocInfField->SetExpansion( static_cast<SwDocInfoFieldType*>(pField->GetTyp())->Expand(
2544  pDocInfField->GetSubType(),
2545  pDocInfField->GetFormat(),
2546  pDocInfField->GetLanguage(),
2547  pDocInfField->GetName() ) );
2548  }
2549  break;
2550  default: break;
2551  }
2552  // Text formatting has to be triggered.
2553  m_pImpl->GetFormatField()->UpdateTextNode(nullptr, nullptr);
2554  }
2555  else
2556  m_pImpl->m_bCallUpdate = true;
2557 }
2558 
2560 {
2561  return "SwXTextField";
2562 }
2563 
2564 static OUString OldNameToNewName_Impl( const OUString &rOld )
2565 {
2566  static const char aOldNamePart1[] = ".TextField.DocInfo.";
2567  static const char aOldNamePart2[] = ".TextField.";
2568  OUString sServiceNameCC( rOld );
2569  sal_Int32 nIdx = sServiceNameCC.indexOf( aOldNamePart1 );
2570  if (nIdx >= 0)
2571  sServiceNameCC = sServiceNameCC.replaceAt( nIdx, strlen(aOldNamePart1), ".textfield.docinfo." );
2572  nIdx = sServiceNameCC.indexOf( aOldNamePart2 );
2573  if (nIdx >= 0)
2574  sServiceNameCC = sServiceNameCC.replaceAt( nIdx, strlen(aOldNamePart2), ".textfield." );
2575  return sServiceNameCC;
2576 }
2577 
2578 sal_Bool SAL_CALL SwXTextField::supportsService(const OUString& rServiceName)
2579 {
2580  return cppu::supportsService(this, rServiceName);
2581 }
2582 
2583 uno::Sequence< OUString > SAL_CALL SwXTextField::getSupportedServiceNames()
2584 {
2585  const OUString sServiceName =
2587 
2588  // case-corrected version of service-name (see #i67811)
2589  // (need to supply both because of compatibility to older versions)
2590  const OUString sServiceNameCC( OldNameToNewName_Impl( sServiceName ) );
2591  sal_Int32 nLen = sServiceName == sServiceNameCC ? 2 : 3;
2592 
2593  uno::Sequence< OUString > aRet( nLen );
2594  OUString* pArray = aRet.getArray();
2595  *pArray++ = sServiceName;
2596  if (nLen == 3)
2597  *pArray++ = sServiceNameCC;
2598  *pArray++ = "com.sun.star.text.TextContent";
2599  return aRet;
2600 }
2601 
2603 {
2604  EndListeningAll();
2605  m_pFormatField = nullptr;
2606  m_pDoc = nullptr;
2607  uno::Reference<uno::XInterface> const xThis(m_wThis);
2608  if (!xThis.is())
2609  { // fdo#72695: if UNO object is already dead, don't revive it with event
2610  return;
2611  }
2612  lang::EventObject const ev(xThis);
2614 }
2615 
2617 {
2618 
2619  if(rHint.GetId() == SfxHintId::Dying)
2620  Invalidate();
2621  else if (rHint.GetId() == SfxHintId::SwLegacyModify)
2622  {
2623  auto pLegacyHint = static_cast<const sw::LegacyModifyHint*>(&rHint);
2624  switch(pLegacyHint->m_pOld ? pLegacyHint->m_pOld->Which() : 0)
2625  {
2626  case RES_REMOVE_UNO_OBJECT:
2627  case RES_OBJECTDYING:
2628  Invalidate();
2629  break;
2630  }
2631  }
2632 }
2633 
2635 {
2636  return m_pFormatField ? m_pFormatField->GetField() : nullptr;
2637 }
2638 
2640 {
2641  return "SwXTextFieldMasters";
2642 }
2643 
2644 sal_Bool SwXTextFieldMasters::supportsService(const OUString& rServiceName)
2645 {
2646  return cppu::supportsService(this, rServiceName);
2647 }
2648 
2650 {
2651  uno::Sequence<OUString> aRet { "com.sun.star.text.TextFieldMasters" };
2652  return aRet;
2653 }
2654 
2656  SwUnoCollection(_pDoc)
2657 {
2658 }
2659 
2661 {
2662 
2663 }
2664 
2665 /*
2666  Iteration over non-standard field types
2667  USER/SETEXP/DDE/DATABASE
2668  Thus the names are:
2669  "com.sun.star.text.fieldmaster.User" + <field type name>
2670  "com.sun.star.text.fieldmaster.DDE" + <field type name>
2671  "com.sun.star.text.fieldmaster.SetExpression" + <field type name>
2672  "com.sun.star.text.fieldmaster.DataBase" + <field type name>
2673 
2674  If too much, maybe one could leave out the "com.sun.star.text".
2675  */
2676 static SwFieldIds lcl_GetIdByName( OUString& rName, OUString& rTypeName )
2677 {
2678  if (rName.startsWithIgnoreAsciiCase(COM_TEXT_FLDMASTER_CC))
2679  rName = rName.copy(COM_TEXT_FLDMASTER_CC.getLength());
2680 
2682  sal_Int32 nIdx = 0;
2683  rTypeName = rName.getToken( 0, '.', nIdx );
2684  if (rTypeName == "User")
2685  nResId = SwFieldIds::User;
2686  else if (rTypeName == "DDE")
2687  nResId = SwFieldIds::Dde;
2688  else if (rTypeName == "SetExpression")
2689  {
2690  nResId = SwFieldIds::SetExp;
2691 
2692  const OUString sFieldTypName( rName.getToken( 0, '.', nIdx ));
2693  const OUString sUIName( SwStyleNameMapper::GetSpecialExtraUIName( sFieldTypName ) );
2694 
2695  if( sUIName != sFieldTypName )
2696  rName = comphelper::string::setToken(rName, 1, '.', sUIName);
2697  }
2698  else if (rTypeName.equalsIgnoreAsciiCase("DataBase"))
2699  {
2700  rName = rName.copy(RTL_CONSTASCII_LENGTH("DataBase."));
2701  if (!rName.isEmpty())
2702  {
2703  // #i51815#
2704  rName = "DataBase." + rName;
2705  nResId = SwFieldIds::Database;
2706  }
2707  }
2708  else if (rTypeName == "Bibliography")
2710  return nResId;
2711 }
2712 
2714 {
2715  SolarMutexGuard aGuard;
2716  if(!GetDoc())
2717  throw uno::RuntimeException();
2718 
2719  OUString sName(rName), sTypeName;
2720  const SwFieldIds nResId = lcl_GetIdByName( sName, sTypeName );
2721  if( SwFieldIds::Unknown == nResId )
2722  throw container::NoSuchElementException(
2723  "SwXTextFieldMasters::getByName(" + rName + ")",
2724  css::uno::Reference<css::uno::XInterface>());
2725 
2726  sName = sName.copy(std::min(sTypeName.getLength()+1, sName.getLength()));
2727  SwFieldType* pType = GetDoc()->getIDocumentFieldsAccess().GetFieldType(nResId, sName, true);
2728  if(!pType)
2729  throw container::NoSuchElementException(
2730  "SwXTextFieldMasters::getByName(" + rName + ")",
2731  css::uno::Reference<css::uno::XInterface>());
2732 
2733  uno::Reference<beans::XPropertySet> const xRet(
2735  return uno::makeAny(xRet);
2736 }
2737 
2739  const SwFieldType& rFieldType, OUString& rName)
2740 {
2741  OUString sField;
2742 
2743  switch( rFieldType.Which() )
2744  {
2745  case SwFieldIds::User:
2746  sField = "User." + rFieldType.GetName();
2747  break;
2748  case SwFieldIds::Dde:
2749  sField = "DDE." + rFieldType.GetName();
2750  break;
2751 
2752  case SwFieldIds::SetExp:
2753  sField = "SetExpression." + SwStyleNameMapper::GetSpecialExtraProgName( rFieldType.GetName() );
2754  break;
2755 
2756  case SwFieldIds::Database:
2757  sField = "DataBase." + rFieldType.GetName().replaceAll(OUStringChar(DB_DELIM), ".");
2758  break;
2759 
2761  sField = "Bibliography";
2762  break;
2763 
2764  default:
2765  return false;
2766  }
2767 
2768  rName += COM_TEXT_FLDMASTER_CC + sField;
2769  return true;
2770 }
2771 
2772 uno::Sequence< OUString > SwXTextFieldMasters::getElementNames()
2773 {
2774  SolarMutexGuard aGuard;
2775  if(!GetDoc())
2776  throw uno::RuntimeException();
2777 
2778  const SwFieldTypes* pFieldTypes = GetDoc()->getIDocumentFieldsAccess().GetFieldTypes();
2779  const size_t nCount = pFieldTypes->size();
2780 
2781  std::vector<OUString> aFieldNames;
2782  for( size_t i = 0; i < nCount; ++i )
2783  {
2784  SwFieldType& rFieldType = *((*pFieldTypes)[i]);
2785 
2786  OUString sFieldName;
2787  if (SwXTextFieldMasters::getInstanceName(rFieldType, sFieldName))
2788  {
2789  aFieldNames.push_back(sFieldName);
2790  }
2791  }
2792 
2793  return comphelper::containerToSequence(aFieldNames);
2794 }
2795 
2797 {
2798  SolarMutexGuard aGuard;
2799  if(!GetDoc())
2800  throw uno::RuntimeException();
2801 
2802  OUString sName(rName), sTypeName;
2803  const SwFieldIds nResId = lcl_GetIdByName( sName, sTypeName );
2804  bool bRet = false;
2805  if( SwFieldIds::Unknown != nResId )
2806  {
2807  sName = sName.copy(std::min(sTypeName.getLength()+1, sName.getLength()));
2808  bRet = nullptr != GetDoc()->getIDocumentFieldsAccess().GetFieldType(nResId, sName, true);
2809  }
2810  return bRet;
2811 }
2812 
2814 {
2816 
2817 }
2818 
2820 {
2821  SolarMutexGuard aGuard;
2822  if(!IsValid())
2823  throw uno::RuntimeException();
2824  return true;
2825 }
2826 
2828 {
2829 private:
2830  ::osl::Mutex m_Mutex; // just for OInterfaceContainerHelper2
2831 
2832 public:
2834 
2835  Impl() : m_RefreshListeners(m_Mutex) { }
2836 };
2837 
2839 {
2840  return "SwXTextFieldTypes";
2841 }
2842 
2843 sal_Bool SwXTextFieldTypes::supportsService(const OUString& rServiceName)
2844 {
2845  return cppu::supportsService(this, rServiceName);
2846 }
2847 
2849 {
2850  uno::Sequence<OUString> aRet { "com.sun.star.text.TextFields" };
2851  return aRet;
2852 }
2853 
2855  : SwUnoCollection (_pDoc)
2856  , m_pImpl(new Impl)
2857 {
2858 }
2859 
2861 {
2862 }
2863 
2865 {
2867  lang::EventObject const ev(static_cast< ::cppu::OWeakObject&>(*this));
2868  m_pImpl->m_RefreshListeners.disposeAndClear(ev);
2869 }
2870 
2871 uno::Reference< container::XEnumeration > SwXTextFieldTypes::createEnumeration()
2872 {
2873  SolarMutexGuard aGuard;
2874  if(!IsValid())
2875  throw uno::RuntimeException();
2876  return new SwXFieldEnumeration(*GetDoc());
2877 }
2878 
2880 {
2882 }
2883 
2885 {
2886  SolarMutexGuard aGuard;
2887  if(!IsValid())
2888  throw uno::RuntimeException();
2889  return true; // they always exist
2890 }
2891 
2893 {
2894  {
2895  SolarMutexGuard aGuard;
2896  if (!IsValid())
2897  throw uno::RuntimeException();
2898  UnoActionContext aContext(GetDoc());
2899  GetDoc()->getIDocumentStatistics().UpdateDocStat( false, true );
2901  }
2902  // call refresh listeners (without SolarMutex locked)
2903  lang::EventObject const event(static_cast< ::cppu::OWeakObject*>(this));
2904  m_pImpl->m_RefreshListeners.notifyEach(
2905  & util::XRefreshListener::refreshed, event);
2906 }
2907 
2909  const uno::Reference<util::XRefreshListener> & xListener)
2910 {
2911  // no need to lock here as m_pImpl is const and container threadsafe
2912  m_pImpl->m_RefreshListeners.addInterface(xListener);
2913 }
2914 
2916  const uno::Reference<util::XRefreshListener> & xListener)
2917 {
2918  // no need to lock here as m_pImpl is const and container threadsafe
2919  m_pImpl->m_RefreshListeners.removeInterface(xListener);
2920 }
2921 
2923  : public SvtListener
2924 {
2925 public:
2927  std::vector<uno::Reference<text::XTextField>> m_Items;
2928  sal_Int32 m_nNextIndex;
2929 
2930  explicit Impl(SwDoc& rDoc)
2931  : m_pDoc(&rDoc)
2932  , m_nNextIndex(0)
2933  {
2935  }
2936 
2937  virtual void Notify(const SfxHint& rHint) override
2938  {
2939  if(rHint.GetId() == SfxHintId::Dying)
2940  m_pDoc = nullptr;
2941  }
2942 };
2943 
2944 OUString SAL_CALL
2946 {
2947  return "SwXFieldEnumeration";
2948 }
2949 
2950 sal_Bool SAL_CALL SwXFieldEnumeration::supportsService(const OUString& rServiceName)
2951 {
2952  return cppu::supportsService(this, rServiceName);
2953 }
2954 
2955 uno::Sequence<OUString> SAL_CALL
2957 {
2958  return { "com.sun.star.text.FieldEnumeration" };
2959 }
2960 
2962  : m_pImpl(new Impl(rDoc))
2963 {
2964  // build sequence
2965  m_pImpl->m_Items.clear();
2966 
2967  const SwFieldTypes* pFieldTypes = m_pImpl->m_pDoc->getIDocumentFieldsAccess().GetFieldTypes();
2968  const size_t nCount = pFieldTypes->size();
2969  for(size_t nType = 0; nType < nCount; ++nType)
2970  {
2971  const SwFieldType* pCurType = (*pFieldTypes)[nType].get();
2972  std::vector<SwFormatField*> vFormatFields;
2973  pCurType->GatherFields(vFormatFields);
2974  std::for_each(vFormatFields.begin(), vFormatFields.end(),
2975  [this](SwFormatField* pF) { m_pImpl->m_Items.push_back(SwXTextField::CreateXTextField(m_pImpl->m_pDoc, pF)); });
2976  }
2977  // now handle meta-fields, which are not SwFields
2978  const std::vector< uno::Reference<text::XTextField> > MetaFields(
2979  m_pImpl->m_pDoc->GetMetaFieldManager().getMetaFields() );
2980  for (const auto & rMetaField : MetaFields)
2981  {
2982  m_pImpl->m_Items.push_back( rMetaField );
2983  }
2984  // also add fieldmarks
2985  IDocumentMarkAccess& rMarksAccess(*rDoc.getIDocumentMarkAccess());
2986  for (auto iter = rMarksAccess.getFieldmarksBegin(); iter != rMarksAccess.getFieldmarksEnd(); ++iter)
2987  {
2988  m_pImpl->m_Items.emplace_back(SwXFieldmark::CreateXFieldmark(rDoc, *iter), uno::UNO_QUERY);
2989  }
2990 }
2991 
2993 {
2994 }
2995 
2997 {
2998  SolarMutexGuard aGuard;
2999 
3000  return m_pImpl->m_nNextIndex < static_cast<sal_Int32>(m_pImpl->m_Items.size());
3001 }
3002 
3004 {
3005  SolarMutexGuard aGuard;
3006 
3007  if (m_pImpl->m_nNextIndex >= static_cast<sal_Int32>(m_pImpl->m_Items.size()))
3008  throw container::NoSuchElementException(
3009  "SwXFieldEnumeration::nextElement",
3010  css::uno::Reference<css::uno::XInterface>());
3011 
3012  uno::Reference< text::XTextField > &rxField =
3013  m_pImpl->m_Items[ m_pImpl->m_nNextIndex++ ];
3014  uno::Any aRet;
3015  aRet <<= rxField;
3016  rxField = nullptr; // free memory for item that is no longer used
3017  return aRet;
3018 }
3019 
3020 /* 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:84
void SetValue(bool bHidden)
Definition: docufld.hxx:330
virtual void SAL_CALL removeEventListener(const css::uno::Reference< css::lang::XEventListener > &xListener) override
Definition: unofield.cxx:2120
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:327
#define PROPERTY_MAP_FLDTYP_DATABASE_SET_NUM
Definition: unomap.hxx:91
sal_Int32 nCommandType
Definition: swdbdata.hxx:32
sal_Int32 nIndex
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:153
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:2655
virtual const_iterator_t getAnnotationMarksEnd() const =0
#define UNO_NAME_IS_AUTOMATIC_UPDATE
Definition: unoprnms.hxx:155
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:3210
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:2128
sal_uInt32 GetFormat() const
Query parameters for dialog and for BASIC.
Definition: fldbas.hxx:397
virtual void CalcLayout()
Definition: viewsh.cxx:1031
virtual sal_uInt16 GetSubType() const override
Definition: docufld.cxx:2019
#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:2860
#define FIELD_PROP_STRINGS
Definition: unofldmid.h:42
#define PROPERTY_MAP_FLDTYP_DATABASE_NEXT_SET
Definition: unomap.hxx:89
void SetItems(std::vector< OUString > &&rItems)
Sets the items of the dropdown box.
virtual css::uno::Any SAL_CALL getByName(const OUString &rName) override
Definition: unofield.cxx:2713
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:2956
::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:1806
#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:1062
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
constexpr sal_uInt8 MAXLEVEL
Definition: swtypes.hxx:93
virtual void Invalidate() override
Definition: unofield.cxx:2864
#define FIELD_PROP_BOOL4
Definition: unofldmid.h:41
virtual sal_Bool SAL_CALL supportsService(const OUString &rServiceName) override
Definition: unofield.cxx:2843
sal_Int16 nId
virtual void Notify(const SfxHint &rHint) override
Definition: unofield.cxx:2937
void disposeAndClear(const css::lang::EventObject &rEvt)
bool IsAtEndOfMeta() const
Definition: unoobj.cxx:795
const SwDocInfoSubType DI_COMMENT
Definition: docufld.hxx:74
virtual OUString SAL_CALL getPresentation(sal_Bool bShowCommand) override
Definition: unofield.cxx:1336
SwFieldType * GetFieldType() const
Definition: unofield.cxx:1151
SwTextNode * GetpTextNode() const
Definition: txtfld.hxx:49
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:1790
const OUString & GetName() const
Definition: docufld.hxx:536
#define PROPERTY_MAP_FLDTYP_DOCINFO_REVISION
Definition: unomap.hxx:101
void SetLevel(sal_uInt8)
Definition: chpfld.cxx:86
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 css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo() override
Definition: unofield.cxx:564
#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:154
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:79
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:310
#define PROPERTY_MAP_FLDTYP_DOCINFO_DATE_TIME
Definition: unomap.hxx:96
virtual sal_Bool SAL_CALL hasElements() override
Definition: unofield.cxx:2819
virtual void SAL_CALL removeVetoableChangeListener(const OUString &rPropertyName, const css::uno::Reference< css::beans::XVetoableChangeListener > &xListener) override
Definition: unofield.cxx:2499
const SfxItemPropertyMapEntry * getByName(std::u16string_view rName) const
void GatherFields(std::vector< SwFormatField * > &rvFormatFields, bool bCollectOnlyInDocNodes=true) const
Definition: fldbas.cxx:208
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:149
virtual ~SwXFieldEnumeration() override
Definition: unofield.cxx:2992
OUString SwResId(TranslateId aId)
Definition: swmodule.cxx:165
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:2484
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:2583
virtual css::uno::Any SAL_CALL getPropertyValue(const OUString &rPropertyName) override
Definition: unofield.cxx:2302
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:2871
invariant for SwAuthorityField is that it is always registered at its SwAuthorityFieldType via AddFie...
Definition: authfld.hxx:154
SwXFieldEnumeration(SwDoc &rDoc)
Definition: unofield.cxx:2961
SwIndex nContent
Definition: pam.hxx:38
SwXTextFieldTypes(SwDoc *pDoc)
Definition: unofield.cxx:2854
::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:1135
SwFieldType * m_pFieldType
Definition: unofield.cxx:1088
virtual void SAL_CALL dispose() override
Definition: unofield.cxx:2094
#define PROPERTY_MAP_FLDMSTR_BIBLIOGRAPHY
Definition: unomap.hxx:111
int nCount
static SwFieldIds lcl_GetIdByName(OUString &rName, OUString &rTypeName)
Definition: unofield.cxx:2676
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:2489
static bool getInstanceName(const SwFieldType &rFieldType, OUString &rName)
Definition: unofield.cxx:2738
const SwDocInfoSubType DI_SUBJECT
Definition: docufld.hxx:72
static const css::uno::Sequence< sal_Int8 > & getUnoTunnelId()
Definition: unofield.cxx:1174
sal_Int32 GetStart() const
Definition: txatbase.hxx:86
virtual OUString SAL_CALL getImplementationName() override
Definition: unofield.cxx:2559
#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:683
void Width(tools::Long nNew)
Definition: swrect.hxx:189
#define PROPERTY_MAP_FLDTYP_DOCINFO_CUSTOM
Definition: unomap.hxx:122
void SetExpansion(const OUString &rStr)
Definition: docufld.hxx:198
#define UNO_NAME_CHAPTER_NUMBERING_LEVEL
Definition: unoprnms.hxx:465
const SwFormatField & GetFormatField() const
Definition: txatbase.hxx:195
virtual void Notify(const SfxHint &) override
Definition: unofield.cxx:2616
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:238
void SetExpansion(const OUString &rStr)
Definition: docufld.hxx:538
#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:246
sal_Int32 m_nNextIndex
index of next element to be returned
Definition: unofield.cxx:2928
::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:2945
constexpr OUStringLiteral aData
Definition: ww8scan.hxx:48
#define SAL_N_ELEMENTS(arr)
const css::uno::Sequence< sal_Int8 > & getSeq() const
const SwDocInfoSubType DI_CUSTOM
Definition: docufld.hxx:80
Impl(SwPageDesc *const pPageDesc, SwDoc *pDoc, SwFieldIds nResId)
Definition: unofield.cxx:427
#define UNO_NAME_DDE_COMMAND_TYPE
Definition: unoprnms.hxx:152
static SW_DLLPUBLIC const OUString & GetSpecialExtraProgName(const OUString &rExtraUIName)
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
Definition: unofield.cxx:2649
virtual void SAL_CALL addVetoableChangeListener(const OUString &rPropertyName, const css::uno::Reference< css::beans::XVetoableChangeListener > &xListener) override
Definition: unofield.cxx:2494
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:2772
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:77
SwFormatField * GetFormatField()
Definition: unofield.cxx:1137
virtual void SAL_CALL setPropertyValue(const OUString &rPropertyName, const css::uno::Any &rValue) override
Definition: unofield.cxx:2149
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:224
#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:471
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:73
#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:2639
SetAttrMode
Definition: swtypes.hxx:133
SAL_DLLPRIVATE void SetXObject(css::uno::Reference< css::beans::XPropertySet > const &xFieldMaster)
Definition: fldbas.hxx:260
#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:75
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:2996
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:2644
const SfxItemPropertyMap & getPropertyMap() const
virtual OUString SAL_CALL getImplementationName() override
Definition: unofield.cxx:2838
std::vector< uno::Reference< text::XTextField > > m_Items
Definition: unofield.cxx:2927
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:85
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:2908
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:2884
virtual sal_Bool SAL_CALL hasByName(const OUString &rName) override
Definition: unofield.cxx:2796
SwTextField * GetFieldTextAttrAt(const sal_Int32 nIndex, const bool bIncludeInputFieldAtStart=false) const
Definition: ndtxt.cxx:1735
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:2848
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:466
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:142
const SwPosition * Start() const
Definition: pam.hxx:212
#define FIELD_PROP_PAR3
Definition: unofldmid.h:25
const OUString & GetName() const
Definition: docufld.hxx:493
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:2057
#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:2326
#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:83
SwFieldType * GetFieldType(bool bDontCreate=false) const
Definition: unofield.cxx:778
SvtBroadcaster & GetNotifier()
Definition: calbck.hxx:102
#define FIELD_PROP_BOOL1
Definition: unofldmid.h:28
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:2915
#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:1348
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:474
#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:137
#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:78
static OUString Expand(sal_uInt16 nSubType)
Definition: docufld.cxx:1962
::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:313
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:2564
virtual void Invalidate()
Definition: unocoll.cxx:1932
::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:2950
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:145
#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:2634
Sequence< sal_Int8 > aSeq
bool IsHidden() const
Definition: ndtxt.cxx:4494
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:567
virtual sal_Bool SAL_CALL supportsService(const OUString &rServiceName) override
Definition: unofield.cxx:512
#define UNO_NAME_DATA_TABLE_NAME
Definition: unoprnms.hxx:245
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:2113
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:1877
#define UNO_NAME_DATA_COLUMN_NAME
Definition: unoprnms.hxx:247
constexpr OUStringLiteral COM_TEXT_FLDMASTER_CC
Definition: unofield.cxx:93
#define UNO_NAME_DATA_BASE_NAME
Definition: unoprnms.hxx:244
#define PROPERTY_MAP_FLDTYP_AUTHOR
Definition: unomap.hxx:72
virtual void SAL_CALL refresh() override
Definition: unofield.cxx:2892
#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:2833
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:2327
#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)
SwFieldType * m_pType
Definition: unofield.cxx:414
const SwDocInfoSubType DI_SUB_FIXED
Definition: docufld.hxx:86
const SwDocInfoSubType DI_CHANGE
Definition: docufld.hxx:76
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:2879
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:1303
static css::uno::Reference< css::text::XTextRange > CreateXTextRange(SwDoc &rDoc, const SwPosition &rPos, const SwPosition *const pMark)
Definition: unoobj2.cxx:1214
#define PROPERTY_MAP_FLDTYP_CONDITIONED_TEXT
Definition: unomap.hxx:75
virtual css::uno::Any SAL_CALL nextElement() override
Definition: unofield.cxx:3003
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:312
static OUString GetProgrammaticName(const SwFieldType &rType, SwDoc &rDoc)
Definition: unofield.cxx:1001
virtual ~SwXTextFieldMasters() override
Definition: unofield.cxx:2660
virtual css::uno::Type SAL_CALL getElementType() override
Definition: unofield.cxx:2813
OUString setToken(const OUString &rIn, sal_Int32 nToken, sal_Unicode cTok, const OUString &rNewToken)
const SwDocInfoSubType DI_TITLE
Definition: docufld.hxx:71
#define FIELD_PROP_IS_FIELD_USED
Definition: unofldmid.h:45
virtual css::uno::Reference< css::beans::XPropertySet > SAL_CALL getTextFieldMaster() override
Definition: unofield.cxx:1326
#define PROPERTY_MAP_FLDMSTR_DDE
Definition: unomap.hxx:106
Standard page.
Definition: poolfmt.hxx:170
void SetHidden(bool bHidden)
Definition: docufld.hxx:373
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:2578
#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:77
SwTextNode * GetTextNode()
Inline methods from Node.hxx.
Definition: ndtxt.hxx:856
#define PROPERTY_MAP_FLDTYP_SET_EXP
Definition: unomap.hxx:68
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:2504
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:176
virtual sal_uInt16 GetSubType() const override
Definition: dbfld.cxx:347
virtual void Notify(const SfxHint &rHint) override
Definition: unofield.cxx:985
#define FIELD_PROP_SHORT1
Definition: unofldmid.h:37
void SetTextObject(std::optional< OutlinerParaObject > pText)
Definition: docufld.cxx:1824
void SetOffset(tools::Long nMinutes)
Definition: flddat.hxx:65
static const OUString & GetProgName(const OUString &rName, SwGetPoolIdFromName)
typedef void(CALLTYPE *GetFuncDataPtr)(sal_uInt16 &nNo