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