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