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