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