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