LibreOffice Module sw (master)  1
unoidx.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 <memory>
21 #include <unoidx.hxx>
22 #include <unoidxcoll.hxx>
23 
24 #include <com/sun/star/beans/PropertyAttribute.hpp>
25 #include <com/sun/star/container/XIndexReplace.hpp>
26 #include <com/sun/star/frame/XModel.hpp>
27 #include <com/sun/star/lang/IndexOutOfBoundsException.hpp>
28 #include <com/sun/star/text/ChapterFormat.hpp>
29 #include <com/sun/star/text/ReferenceFieldPart.hpp>
30 #include <com/sun/star/text/BibliographyDataField.hpp>
31 #include <com/sun/star/text/XTextDocument.hpp>
32 
33 #include <osl/mutex.hxx>
37 #include <tools/UnitConversion.hxx>
38 #include <vcl/svapp.hxx>
40 #include <editeng/memberids.h>
41 #include <swtypes.hxx>
42 #include <shellres.hxx>
43 #include <viewsh.hxx>
44 #include <doc.hxx>
46 #include <docary.hxx>
47 #include <fmtcntnt.hxx>
48 #include <unomap.hxx>
49 #include <unotextrange.hxx>
50 #include <unotextcursor.hxx>
51 #include <unosection.hxx>
52 #include <doctxm.hxx>
53 #include <txttxmrk.hxx>
54 #include <ndtxt.hxx>
55 #include <docsh.hxx>
56 #include <chpfld.hxx>
57 #include <editsh.hxx>
58 #include <SwStyleNameMapper.hxx>
59 #include <strings.hrc>
61 #include <comphelper/string.hxx>
62 #include <cppuhelper/implbase.hxx>
63 #include <svl/itemprop.hxx>
64 #include <svl/listener.hxx>
65 #include <mutex>
66 
67 using namespace ::com::sun::star;
68 
70 template<typename T>
71 static T
72 lcl_AnyToType(uno::Any const& rVal)
73 {
74  T aRet{};
75  if(!(rVal >>= aRet))
76  {
77  throw lang::IllegalArgumentException();
78  }
79  return aRet;
80 }
81 
83 template<typename T>
84 static void lcl_AnyToBitMask(uno::Any const& rValue,
85  T & rBitMask, const T nBit)
86 {
87  rBitMask = lcl_AnyToType<bool>(rValue)
88  ? (rBitMask | nBit)
89  : (rBitMask & ~nBit);
90 }
91 
92 template<typename T>
93 static void lcl_BitMaskToAny(uno::Any & o_rValue,
94  const T nBitMask, const T nBit)
95 {
96  const bool bRet(nBitMask & nBit);
97  o_rValue <<= bRet;
98 }
99 
100 static void
101 lcl_ReAssignTOXType(SwDoc& rDoc, SwTOXBase& rTOXBase, const OUString& rNewName)
102 {
103  const sal_uInt16 nUserCount = rDoc.GetTOXTypeCount( TOX_USER );
104  const SwTOXType* pNewType = nullptr;
105  for(sal_uInt16 nUser = 0; nUser < nUserCount; nUser++)
106  {
107  const SwTOXType* pType = rDoc.GetTOXType( TOX_USER, nUser );
108  if (pType->GetTypeName()==rNewName)
109  {
110  pNewType = pType;
111  break;
112  }
113  }
114  if(!pNewType)
115  {
116  SwTOXType aNewType(rDoc, TOX_USER, rNewName);
117  pNewType = rDoc.InsertTOXType( aNewType );
118  }
119 
120  rTOXBase.RegisterToTOXType( *const_cast<SwTOXType*>(pNewType) );
121 }
122 
123 constexpr OUStringLiteral cUserDefined = u"User-Defined";
124 const char cUserSuffix[] = " (user)";
125 #define USER_LEN 12
126 #define USER_AND_SUFFIXLEN 19
127 
128 static void lcl_ConvertTOUNameToProgrammaticName(OUString& rTmp)
129 {
131 
132  if(rTmp==pShellRes->aTOXUserName)
133  {
134  rTmp = cUserDefined;
135  }
136  // if the version is not English but the alternative index's name is
137  // "User-Defined" a " (user)" is appended
138  else if(rTmp == cUserDefined)
139  {
140  rTmp += cUserSuffix;
141  }
142 }
143 
144 static void
146 {
148  if (rTmp == cUserDefined)
149  {
150  rTmp = pShellRes->aTOXUserName;
151  }
152  else if (pShellRes->aTOXUserName != cUserDefined &&
153  USER_AND_SUFFIXLEN == rTmp.getLength())
154  {
155  //make sure that in non-English versions the " (user)" suffix is removed
156  if (rTmp.startsWith(cUserDefined) &&
157  rTmp.match(cUserSuffix, USER_LEN))
158  {
159  rTmp = cUserDefined;
160  }
161  }
162 }
163 
164 typedef ::cppu::WeakImplHelper
165 < lang::XServiceInfo
166 , container::XIndexReplace
168 
171 {
172 
173 private:
176 
177  virtual ~StyleAccess_Impl() override;
178 
179 public:
180  explicit StyleAccess_Impl(SwXDocumentIndex& rParentIdx);
181 
182  // XServiceInfo
183  virtual OUString SAL_CALL getImplementationName() override;
184  virtual sal_Bool SAL_CALL
185  supportsService(const OUString& rServiceName) override;
186  virtual uno::Sequence< OUString > SAL_CALL
187  getSupportedServiceNames() override;
188 
189  // XElementAccess
190  virtual uno::Type SAL_CALL getElementType() override;
191  virtual sal_Bool SAL_CALL hasElements() override;
192 
193  // XIndexAccess
194  virtual sal_Int32 SAL_CALL getCount() override;
195  virtual uno::Any SAL_CALL getByIndex(sal_Int32 nIndex) override;
196 
197  // XIndexReplace
198  virtual void SAL_CALL
199  replaceByIndex(sal_Int32 Index, const uno::Any& rElement) override;
200 
201 };
202 
203 typedef ::cppu::WeakImplHelper
204 < lang::XServiceInfo
205 , container::XIndexReplace
207 
210 {
211 
212 private:
215 
216  virtual ~TokenAccess_Impl() override;
217 
218 public:
219 
220  explicit TokenAccess_Impl(SwXDocumentIndex& rParentIdx);
221 
222  // XServiceInfo
223  virtual OUString SAL_CALL getImplementationName() override;
224  virtual sal_Bool SAL_CALL
225  supportsService(const OUString& rServiceName) override;
226  virtual uno::Sequence< OUString > SAL_CALL
227  getSupportedServiceNames() override;
228 
229  // XElementAccess
230  virtual uno::Type SAL_CALL getElementType() override;
231  virtual sal_Bool SAL_CALL hasElements() override;
232 
233  // XIndexAccess
234  virtual sal_Int32 SAL_CALL getCount() override;
235  virtual uno::Any SAL_CALL getByIndex(sal_Int32 nIndex) override;
236 
237  // XIndexReplace
238  virtual void SAL_CALL
239  replaceByIndex(sal_Int32 Index, const uno::Any& rElement) override;
240 
241 };
242 
243 namespace {
244 
245 class SwDocIndexDescriptorProperties_Impl
246 {
247 private:
248  std::unique_ptr<SwTOXBase> m_pTOXBase;
249  OUString m_sUserTOXTypeName;
250 
251 public:
252  explicit SwDocIndexDescriptorProperties_Impl(SwTOXType const*const pType);
253 
254  SwTOXBase & GetTOXBase() { return *m_pTOXBase; }
255  const OUString& GetTypeName() const { return m_sUserTOXTypeName; }
256  void SetTypeName(const OUString& rSet) { m_sUserTOXTypeName = rSet; }
257 };
258 
259 }
260 
261 SwDocIndexDescriptorProperties_Impl::SwDocIndexDescriptorProperties_Impl(
262  SwTOXType const*const pType)
263 {
264  SwForm aForm(pType->GetType());
265  m_pTOXBase.reset(new SwTOXBase(pType, aForm,
266  SwTOXElement::Mark, pType->GetTypeName()));
267  if(pType->GetType() == TOX_CONTENT || pType->GetType() == TOX_USER)
268  {
269  m_pTOXBase->SetLevel(MAXLEVEL);
270  }
271  m_sUserTOXTypeName = pType->GetTypeName();
272 }
273 
274 static sal_uInt16
276 {
277  switch (eType)
278  {
279  case TOX_INDEX: return PROPERTY_MAP_INDEX_IDX;
285  //case TOX_USER:
286  default:
288  }
289 }
290 
292 {
293 private:
294  ::osl::Mutex m_Mutex; // just for OInterfaceContainerHelper2
296 
297 public:
298  uno::WeakReference<uno::XInterface> m_wThis;
304  std::unique_ptr<SwDocIndexDescriptorProperties_Impl> m_pProps;
305  uno::WeakReference<container::XIndexReplace> m_wStyleAccess;
306  uno::WeakReference<container::XIndexReplace> m_wTokenAccess;
307 
308  Impl(SwDoc& rDoc, const TOXTypes eType, SwTOXBaseSection *const pBaseSection)
309  : m_pFormat(pBaseSection ? pBaseSection->GetFormat() : nullptr)
310  , m_Listeners(m_Mutex)
311  , m_rPropSet(*aSwMapProvider.GetPropertySet(lcl_TypeToPropertyMap_Index(eType)))
312  , m_eTOXType(eType)
313  , m_bIsDescriptor(nullptr == pBaseSection)
314  , m_pDoc(&rDoc)
315  , m_pProps(m_bIsDescriptor
316  ? new SwDocIndexDescriptorProperties_Impl(rDoc.GetTOXType(eType, 0))
317  : nullptr)
318  {
319  if(m_pFormat)
320  StartListening(m_pFormat->GetNotifier());
321  }
322 
324  {
325  EndListeningAll();
326  m_pFormat = &rFormat;
327  StartListening(rFormat.GetNotifier());
328  }
329 
331  return m_pFormat;
332  }
333 
335  {
336  SwSectionFormat *const pSectionFormat(GetSectionFormat());
337  SwTOXBase *const pTOXSection( m_bIsDescriptor
338  ? &m_pProps->GetTOXBase()
339  : (pSectionFormat
340  ? static_cast<SwTOXBaseSection*>(pSectionFormat->GetSection())
341  : nullptr));
342  if (!pTOXSection)
343  {
344  throw uno::RuntimeException(
345  "SwXDocumentIndex: disposed or invalid", nullptr);
346  }
347  return *pTOXSection;
348  }
349 
350  sal_Int32 GetFormMax() const
351  {
352  SwTOXBase & rSection( GetTOXSectionOrThrow() );
353  return m_bIsDescriptor
354  ? SwForm::GetFormMaxLevel(m_eTOXType)
355  : rSection.GetTOXForm().GetFormMax();
356  }
357  virtual void Notify(const SfxHint&) override;
358 
359 };
360 
362 {
363  if (rHint.GetId() == SfxHintId::SwLegacyModify)
364  {
365  auto pLegacy = static_cast<const sw::LegacyModifyHint*>(&rHint);
366  if(pLegacy->m_pOld && pLegacy->m_pOld->Which() == RES_REMOVE_UNO_OBJECT)
367  m_pFormat = nullptr;
368  }
369  else if(rHint.GetId() == SfxHintId::Dying)
370  m_pFormat = nullptr;
371  if(!m_pFormat)
372  {
373  EndListeningAll();
374  uno::Reference<uno::XInterface> const xThis(m_wThis);
375  if (!xThis.is())
376  { // fdo#72695: if UNO object is already dead, don't revive it with event
377  return;
378  }
379  lang::EventObject const ev(xThis);
381  }
382 }
383 
385  SwTOXBaseSection & rBaseSection, SwDoc & rDoc)
386  : m_pImpl( new SwXDocumentIndex::Impl(
387  rDoc, rBaseSection.SwTOXBase::GetType(), & rBaseSection) )
388 {
389 }
390 
392  : m_pImpl( new SwXDocumentIndex::Impl(rDoc, eType, nullptr) )
393 {
394 }
395 
397 {
398 }
399 
400 uno::Reference<text::XDocumentIndex>
402  SwDoc & rDoc, SwTOXBaseSection * pSection, TOXTypes const eTypes)
403 {
404  // re-use existing SwXDocumentIndex
405  // #i105557#: do not iterate over the registered clients: race condition
406  uno::Reference<text::XDocumentIndex> xIndex;
407  if (pSection)
408  {
409  SwSectionFormat const *const pFormat = pSection->GetFormat();
410  xIndex.set(pFormat->GetXObject(), uno::UNO_QUERY);
411  }
412  if (!xIndex.is())
413  {
414  SwXDocumentIndex *const pIndex(pSection
415  ? new SwXDocumentIndex(*pSection, rDoc)
416  : new SwXDocumentIndex(eTypes, rDoc));
417  xIndex.set(pIndex);
418  if (pSection)
419  {
420  pSection->GetFormat()->SetXObject(xIndex);
421  }
422  // need a permanent Reference to initialize m_wThis
423  pIndex->m_pImpl->m_wThis = xIndex;
424  }
425  return xIndex;
426 }
427 
428 const uno::Sequence< sal_Int8 > & SwXDocumentIndex::getUnoTunnelId()
429 {
430  static const comphelper::UnoIdInit theSwXDocumentIndexUnoTunnelId;
431  return theSwXDocumentIndexUnoTunnelId.getSeq();
432 }
433 
434 sal_Int64 SAL_CALL
435 SwXDocumentIndex::getSomething(const uno::Sequence< sal_Int8 >& rId)
436 {
437  return comphelper::getSomethingImpl<SwXDocumentIndex>(rId, this);
438 }
439 
440 OUString SAL_CALL
442 {
443  return "SwXDocumentIndex";
444 }
445 
446 sal_Bool SAL_CALL
447 SwXDocumentIndex::supportsService(const OUString& rServiceName)
448 {
449  return cppu::supportsService(this, rServiceName);
450 }
451 
452 uno::Sequence< OUString > SAL_CALL
454 {
455  SolarMutexGuard g;
456 
457  uno::Sequence< OUString > aRet(2);
458  OUString* pArray = aRet.getArray();
459  pArray[0] = "com.sun.star.text.BaseIndex";
460  switch (m_pImpl->m_eTOXType)
461  {
462  case TOX_INDEX:
463  pArray[1] = "com.sun.star.text.DocumentIndex";
464  break;
465  case TOX_CONTENT:
466  pArray[1] = "com.sun.star.text.ContentIndex";
467  break;
468  case TOX_TABLES:
469  pArray[1] = "com.sun.star.text.TableIndex";
470  break;
471  case TOX_ILLUSTRATIONS:
472  pArray[1] = "com.sun.star.text.IllustrationsIndex";
473  break;
474  case TOX_OBJECTS:
475  pArray[1] = "com.sun.star.text.ObjectIndex";
476  break;
477  case TOX_AUTHORITIES:
478  pArray[1] = "com.sun.star.text.Bibliography";
479  break;
480  //case TOX_USER:
481  default:
482  pArray[1] = "com.sun.star.text.UserDefinedIndex";
483  }
484  return aRet;
485 }
486 
488 {
489  SolarMutexGuard g;
490 
492  switch (m_pImpl->m_eTOXType)
493  {
494  case TOX_USER: nObjectType = SwServiceType::UserIndex;
495  break;
496  case TOX_CONTENT: nObjectType = SwServiceType::ContentIndex;
497  break;
499  break;
500  case TOX_OBJECTS: nObjectType = SwServiceType::IndexObjects;
501  break;
502  case TOX_TABLES: nObjectType = SwServiceType::IndexTables;
503  break;
505  break;
506  default:
507  break;
508  }
509  return SwXServiceProvider::GetProviderName(nObjectType);
510 }
511 
513 {
514  return refresh(); // update is from deprecated XDocumentIndex
515 }
516 
517 uno::Reference< beans::XPropertySetInfo > SAL_CALL
519 {
520  SolarMutexGuard g;
521 
522  const uno::Reference< beans::XPropertySetInfo > xRef =
523  m_pImpl->m_rPropSet.getPropertySetInfo();
524  return xRef;
525 }
526 
527 void SAL_CALL
529  const OUString& rPropertyName, const uno::Any& rValue)
530 {
531  SolarMutexGuard aGuard;
532 
533  SfxItemPropertyMapEntry const*const pEntry =
534  m_pImpl->m_rPropSet.getPropertyMap().getByName(rPropertyName);
535  if (!pEntry)
536  {
537  throw beans::UnknownPropertyException(
538  "Unknown property: " + rPropertyName,
539  static_cast<cppu::OWeakObject *>(this));
540  }
541  if (pEntry->nFlags & beans::PropertyAttribute::READONLY)
542  {
543  throw beans::PropertyVetoException(
544  "Property is read-only: " + rPropertyName,
545  static_cast<cppu::OWeakObject *>(this));
546  }
547 
548  SwSectionFormat *const pSectionFormat(m_pImpl->GetSectionFormat());
549  SwTOXBase & rTOXBase( m_pImpl->GetTOXSectionOrThrow() );
550 
551  SwTOXElement nCreate = rTOXBase.GetCreateType();
552  SwTOOElements nOLEOptions = rTOXBase.GetOLEOptions();
553  const TOXTypes eTxBaseType = rTOXBase.GetTOXType()->GetType();
554  SwTOIOptions nTOIOptions = (eTxBaseType == TOX_INDEX)
555  ? rTOXBase.GetOptions() : SwTOIOptions::NONE;
556  SwForm aForm(rTOXBase.GetTOXForm());
557  bool bForm = false;
558  switch (pEntry->nWID)
559  {
560  case WID_IDX_TITLE:
561  {
562  OUString sNewName;
563  if (!(rValue >>= sNewName))
564  {
565  throw lang::IllegalArgumentException();
566  }
567  rTOXBase.SetTitle(sNewName);
568  }
569  break;
570  case WID_IDX_NAME:
571  {
572  OUString sNewName;
573  if (!(rValue >>= sNewName))
574  {
575  throw lang::IllegalArgumentException();
576  }
577  rTOXBase.SetTOXName(sNewName);
578  }
579  break;
580  case WID_USER_IDX_NAME:
581  {
582  OUString sNewName;
583  if (!(rValue >>= sNewName))
584  {
585  throw lang::IllegalArgumentException();
586  }
588  OSL_ENSURE(TOX_USER == eTxBaseType,
589  "tox type name can only be changed for user indexes");
590  if (pSectionFormat)
591  {
592  if (rTOXBase.GetTOXType()->GetTypeName() != sNewName)
593  {
594  lcl_ReAssignTOXType(*pSectionFormat->GetDoc(),
595  rTOXBase, sNewName);
596  }
597  }
598  else
599  {
600  m_pImpl->m_pProps->SetTypeName(sNewName);
601  }
602  }
603  break;
604  case WID_IDX_LOCALE:
605  {
606  lang::Locale aLocale;
607  if (!(rValue>>= aLocale))
608  {
609  throw lang::IllegalArgumentException();
610  }
611  rTOXBase.SetLanguage( LanguageTag::convertToLanguageType(aLocale));
612  }
613  break;
615  {
616  OUString sTmp;
617  if (!(rValue >>= sTmp))
618  {
619  throw lang::IllegalArgumentException();
620  }
621  rTOXBase.SetSortAlgorithm(sTmp);
622  }
623  break;
624  case WID_LEVEL:
625  {
626  rTOXBase.SetLevel(lcl_AnyToType<sal_Int16>(rValue));
627  }
628  break;
629  case WID_TOC_BOOKMARK:
630  {
631  rTOXBase.SetBookmarkName(lcl_AnyToType<OUString>(rValue));
632  nCreate = SwTOXElement::Bookmark;
633  rTOXBase.SetCreate(nCreate);
634  }
635  break;
637  lcl_AnyToBitMask(rValue, nCreate, SwTOXElement::Mark);
638  break;
641  break;
644  break;
645  case WID_TAB_IN_TOC:
646  lcl_AnyToBitMask(rValue, nCreate, SwTOXElement::TableInToc);
647  break;
648  case WID_TOC_NEWLINE:
649  lcl_AnyToBitMask(rValue, nCreate, SwTOXElement::Newline);
650  break;
651 // case WID_PARAGRAPH_STYLE_NAMES :OSL_FAIL("not implemented")
652 // break;
655  break ;
657  rTOXBase.SetFromChapter(lcl_AnyToType<bool>(rValue));
658  break;
660  rTOXBase.SetFromObjectNames(! lcl_AnyToType<bool>(rValue));
661  break;
662  case WID_PROTECTED:
663  {
664  bool bSet = lcl_AnyToType<bool>(rValue);
665  rTOXBase.SetProtected(bSet);
666  if (pSectionFormat)
667  {
668  static_cast<SwTOXBaseSection &>(rTOXBase).SetProtect(bSet);
669  }
670  }
671  break;
673  lcl_AnyToBitMask(rValue, nTOIOptions,
675  break;
677  lcl_AnyToBitMask(rValue, nTOIOptions,
679  break;
681  lcl_AnyToBitMask(rValue, nTOIOptions,
683  break;
685  lcl_AnyToBitMask(rValue, nTOIOptions,
687  break;
688  case WID_USE_P_P:
689  lcl_AnyToBitMask(rValue, nTOIOptions, SwTOIOptions::FF);
690  break;
691  case WID_USE_DASH:
692  lcl_AnyToBitMask(rValue, nTOIOptions, SwTOIOptions::Dash);
693  break;
694  case WID_USE_UPPER_CASE:
695  lcl_AnyToBitMask(rValue, nTOIOptions,
697  break;
699  bForm = true;
700  aForm.SetCommaSeparated(lcl_AnyToType<bool>(rValue));
701  break;
702  case WID_LABEL_CATEGORY:
703  {
704  // convert file-format/API/external programmatic english name
705  // to internal UI name before usage
706  rTOXBase.SetSequenceName( SwStyleNameMapper::GetSpecialExtraUIName(
707  lcl_AnyToType<OUString>(rValue) ) );
708  }
709  break;
711  {
712  const sal_Int16 nVal = lcl_AnyToType<sal_Int16>(rValue);
713  sal_uInt16 nSet = CAPTION_COMPLETE;
714  switch (nVal)
715  {
716  case text::ReferenceFieldPart::TEXT:
717  nSet = CAPTION_COMPLETE;
718  break;
719  case text::ReferenceFieldPart::CATEGORY_AND_NUMBER:
720  nSet = CAPTION_NUMBER;
721  break;
722  case text::ReferenceFieldPart::ONLY_CAPTION:
723  nSet = CAPTION_TEXT;
724  break;
725  default:
726  throw lang::IllegalArgumentException();
727  }
728  rTOXBase.SetCaptionDisplay(static_cast<SwCaptionDisplay>(nSet));
729  }
730  break;
732  rTOXBase.SetLevelFromChapter(lcl_AnyToType<bool>(rValue));
733  break;
735  {
736  OUString aString;
737  SwStyleNameMapper::FillUIName(lcl_AnyToType<OUString>(rValue),
738  aString, SwGetPoolIdFromName::ChrFmt);
739  rTOXBase.SetMainEntryCharStyle( aString );
740  }
741  break;
743  lcl_AnyToBitMask(rValue, nCreate, SwTOXElement::Table);
744  break;
746  lcl_AnyToBitMask(rValue, nCreate, SwTOXElement::Frame);
747  break;
749  lcl_AnyToBitMask(rValue, nCreate, SwTOXElement::Graphic);
750  break;
752  lcl_AnyToBitMask(rValue, nCreate, SwTOXElement::Ole);
753  break;
755  lcl_AnyToBitMask(rValue, nOLEOptions, SwTOOElements::Math);
756  break;
758  lcl_AnyToBitMask(rValue, nOLEOptions, SwTOOElements::Chart);
759  break;
761  lcl_AnyToBitMask(rValue, nOLEOptions, SwTOOElements::Calc);
762  break;
764  lcl_AnyToBitMask(rValue, nOLEOptions,
766  break;
768  lcl_AnyToBitMask(rValue, nOLEOptions, SwTOOElements::Other);
769  break;
770  case WID_PARA_HEAD:
771  {
772  OUString aString;
773  SwStyleNameMapper::FillUIName( lcl_AnyToType<OUString>(rValue),
775  bForm = true;
776  // Header is on Pos 0
777  aForm.SetTemplate( 0, aString );
778  }
779  break;
781  bForm = true;
782  aForm.SetRelTabPos(lcl_AnyToType<bool>(rValue));
783  break;
784  case WID_PARA_SEP:
785  {
786  OUString aString;
787  bForm = true;
788  SwStyleNameMapper::FillUIName( lcl_AnyToType<OUString>(rValue),
790  aForm.SetTemplate( 1, aString );
791  }
792  break;
794  lcl_AnyToBitMask(rValue, nCreate, SwTOXElement::Template);
795  break;
796 
797  case WID_PARA_LEV1:
798  case WID_PARA_LEV2:
799  case WID_PARA_LEV3:
800  case WID_PARA_LEV4:
801  case WID_PARA_LEV5:
802  case WID_PARA_LEV6:
803  case WID_PARA_LEV7:
804  case WID_PARA_LEV8:
805  case WID_PARA_LEV9:
806  case WID_PARA_LEV10:
807  {
808  bForm = true;
809  // in sdbcx::Index Label 1 begins at Pos 2 otherwise at Pos 1
810  const sal_uInt16 nLPos = rTOXBase.GetType() == TOX_INDEX ? 2 : 1;
811  OUString aString;
812  SwStyleNameMapper::FillUIName( lcl_AnyToType<OUString>(rValue),
814  aForm.SetTemplate(nLPos + pEntry->nWID - WID_PARA_LEV1, aString );
815  }
816  break;
817  default:
818  //this is for items only
819  if (WID_PRIMARY_KEY > pEntry->nWID)
820  {
821  const SwAttrSet& rSet =
822  SwDoc::GetTOXBaseAttrSet(rTOXBase);
823  SfxItemSet aAttrSet(rSet);
824  m_pImpl->m_rPropSet.setPropertyValue(
825  rPropertyName, rValue, aAttrSet);
826 
827  const SwSectionFormats& rSects = m_pImpl->m_pDoc->GetSections();
828  for (size_t i = 0; i < rSects.size(); ++i)
829  {
830  const SwSectionFormat* pTmpFormat = rSects[ i ];
831  if (pTmpFormat == pSectionFormat)
832  {
833  SwSectionData tmpData(
834  static_cast<SwTOXBaseSection&>(rTOXBase));
835  m_pImpl->m_pDoc->UpdateSection(i, tmpData, & aAttrSet);
836  break;
837  }
838  }
839  }
840  }
841  rTOXBase.SetCreate(nCreate);
842  rTOXBase.SetOLEOptions(nOLEOptions);
843  if (rTOXBase.GetTOXType()->GetType() == TOX_INDEX)
844  {
845  rTOXBase.SetOptions(nTOIOptions);
846  }
847  if (bForm)
848  {
849  rTOXBase.SetTOXForm(aForm);
850  }
851 }
852 
853 uno::Any SAL_CALL
854 SwXDocumentIndex::getPropertyValue(const OUString& rPropertyName)
855 {
856  SolarMutexGuard aGuard;
857 
858  uno::Any aRet;
859  SfxItemPropertyMapEntry const*const pEntry =
860  m_pImpl->m_rPropSet.getPropertyMap().getByName(rPropertyName);
861  if (!pEntry)
862  {
863  throw beans::UnknownPropertyException(
864  "Unknown property: " + rPropertyName,
865  static_cast< cppu::OWeakObject * >(this));
866  }
867  // TODO: is this the best approach to tell API clients about the change?
868  if (pEntry->nWID == RES_BACKGROUND && pEntry->nMemberId == MID_GRAPHIC_URL)
869  {
870  throw uno::RuntimeException("Getting GraphicURL property is not supported");
871  }
872 
873  SwSectionFormat *const pSectionFormat( m_pImpl->GetSectionFormat() );
874  SwTOXBase* pTOXBase = nullptr;
875  if (pSectionFormat)
876  {
877  pTOXBase = static_cast<SwTOXBaseSection*>(pSectionFormat->GetSection());
878  }
879  else if (m_pImpl->m_bIsDescriptor)
880  {
881  pTOXBase = &m_pImpl->m_pProps->GetTOXBase();
882  }
883  if(pTOXBase)
884  {
885  const SwTOXElement nCreate = pTOXBase->GetCreateType();
886  const SwTOOElements nOLEOptions = pTOXBase->GetOLEOptions();
887  const SwTOIOptions nTOIOptions =
888  (pTOXBase->GetTOXType()->GetType() == TOX_INDEX)
889  ? pTOXBase->GetOptions()
891  const SwForm& rForm = pTOXBase->GetTOXForm();
892  switch(pEntry->nWID)
893  {
896  if(WID_IDX_CONTENT_SECTION == pEntry->nWID)
897  {
898  const uno::Reference <text::XTextSection> xContentSect =
899  SwXTextSection::CreateXTextSection( pSectionFormat );
900  aRet <<= xContentSect;
901  }
902  else if (pSectionFormat)
903  {
904  SwSections aSectArr;
905  pSectionFormat->GetChildSections(aSectArr,
906  SectionSort::Not, false);
907  for(SwSection* pSect : aSectArr)
908  {
909  if(pSect->GetType() == SectionType::ToxHeader)
910  {
911  const uno::Reference <text::XTextSection> xHeader =
913  pSect->GetFormat() );
914  aRet <<= xHeader;
915  break;
916  }
917  }
918  }
919  break;
920  case WID_IDX_TITLE :
921  {
922  aRet <<= pTOXBase->GetTitle();
923  break;
924  }
925  case WID_IDX_NAME:
926  aRet <<= pTOXBase->GetTOXName();
927  break;
928  case WID_USER_IDX_NAME:
929  {
930  OUString sTmp((!m_pImpl->m_bIsDescriptor)
931  ? pTOXBase->GetTOXType()->GetTypeName()
932  : m_pImpl->m_pProps->GetTypeName());
933  //I18N
935  aRet <<= sTmp;
936  }
937  break;
938  case WID_IDX_LOCALE:
939  aRet <<= LanguageTag(pTOXBase->GetLanguage()).getLocale();
940  break;
942  aRet <<= pTOXBase->GetSortAlgorithm();
943  break;
944  case WID_LEVEL :
945  aRet <<= static_cast<sal_Int16>(pTOXBase->GetLevel());
946  break;
947  case WID_TOC_BOOKMARK :
948  aRet <<= pTOXBase->GetBookmarkName();
949  break;
951  lcl_BitMaskToAny(aRet, nCreate, SwTOXElement::Mark);
952  break;
954  lcl_BitMaskToAny(aRet, nCreate,
956  break;
958  {
959  const bool bRet = pTOXBase->IsFromChapter();
960  aRet <<= bRet;
961  }
962  break;
964  {
965  const bool bRet = ! pTOXBase->IsFromObjectNames();
966  aRet <<= bRet;
967  }
968  break;
969  case WID_PROTECTED:
970  {
971  const bool bRet = pTOXBase->IsProtected();
972  aRet <<= bRet;
973  }
974  break;
976  lcl_BitMaskToAny(aRet, nTOIOptions,
978  break;
980  lcl_BitMaskToAny(aRet, nTOIOptions,
982  break;
984  lcl_BitMaskToAny(aRet, nTOIOptions,
986  break;
988  lcl_BitMaskToAny(aRet, nTOIOptions,
990  break;
991  case WID_USE_P_P:
992  lcl_BitMaskToAny(aRet, nTOIOptions, SwTOIOptions::FF);
993  break;
994  case WID_USE_DASH:
995  lcl_BitMaskToAny(aRet, nTOIOptions, SwTOIOptions::Dash);
996  break;
997  case WID_USE_UPPER_CASE:
998  lcl_BitMaskToAny(aRet, nTOIOptions,
1000  break;
1002  {
1003  const bool bRet = rForm.IsCommaSeparated();
1004  aRet <<= bRet;
1005  }
1006  break;
1007  case WID_LABEL_CATEGORY:
1008  {
1009  // convert internal UI name to
1010  // file-format/API/external programmatic english name
1011  // before usage
1013  pTOXBase->GetSequenceName() );
1014  }
1015  break;
1017  {
1018  sal_Int16 nSet = text::ReferenceFieldPart::TEXT;
1019  switch (pTOXBase->GetCaptionDisplay())
1020  {
1021  case CAPTION_COMPLETE:
1022  nSet = text::ReferenceFieldPart::TEXT;
1023  break;
1024  case CAPTION_NUMBER:
1025  nSet = text::ReferenceFieldPart::CATEGORY_AND_NUMBER;
1026  break;
1027  case CAPTION_TEXT:
1028  nSet = text::ReferenceFieldPart::ONLY_CAPTION;
1029  break;
1030  }
1031  aRet <<= nSet;
1032  }
1033  break;
1035  {
1036  const bool bRet = pTOXBase->IsLevelFromChapter();
1037  aRet <<= bRet;
1038  }
1039  break;
1040  case WID_LEVEL_FORMAT:
1041  {
1042  uno::Reference< container::XIndexReplace > xTokenAccess(
1043  m_pImpl->m_wTokenAccess);
1044  if (!xTokenAccess.is())
1045  {
1046  xTokenAccess = new TokenAccess_Impl(*this);
1047  m_pImpl->m_wTokenAccess = xTokenAccess;
1048  }
1049  aRet <<= xTokenAccess;
1050  }
1051  break;
1053  {
1054  uno::Reference< container::XIndexReplace > xStyleAccess(
1055  m_pImpl->m_wStyleAccess);
1056  if (!xStyleAccess.is())
1057  {
1058  xStyleAccess = new StyleAccess_Impl(*this);
1059  m_pImpl->m_wStyleAccess = xStyleAccess;
1060  }
1061  aRet <<= xStyleAccess;
1062  }
1063  break;
1065  {
1066  OUString aString;
1068  pTOXBase->GetMainEntryCharStyle(),
1069  aString,
1071  aRet <<= aString;
1072  }
1073  break;
1075  lcl_BitMaskToAny(aRet, nCreate, SwTOXElement::Table);
1076  break;
1078  lcl_BitMaskToAny(aRet, nCreate, SwTOXElement::Frame);
1079  break;
1081  lcl_BitMaskToAny(aRet, nCreate, SwTOXElement::Graphic);
1082  break;
1084  lcl_BitMaskToAny(aRet, nCreate, SwTOXElement::Ole);
1085  break;
1087  lcl_BitMaskToAny(aRet, nOLEOptions, SwTOOElements::Math);
1088  break;
1090  lcl_BitMaskToAny(aRet, nOLEOptions, SwTOOElements::Chart);
1091  break;
1093  lcl_BitMaskToAny(aRet, nOLEOptions, SwTOOElements::Calc);
1094  break;
1096  lcl_BitMaskToAny(aRet, nOLEOptions,
1098  break;
1100  lcl_BitMaskToAny(aRet, nOLEOptions, SwTOOElements::Other);
1101  break;
1103  lcl_BitMaskToAny(aRet, nCreate, SwTOXElement::Template);
1104  break;
1105  case WID_PARA_HEAD:
1106  {
1107  //Header is at position 0
1108  OUString aString;
1109  SwStyleNameMapper::FillProgName(rForm.GetTemplate( 0 ), aString,
1111  aRet <<= aString;
1112  }
1113  break;
1114  case WID_PARA_SEP:
1115  {
1116  OUString aString;
1118  rForm.GetTemplate( 1 ),
1119  aString,
1121  aRet <<= aString;
1122  }
1123  break;
1124  case WID_PARA_LEV1:
1125  case WID_PARA_LEV2:
1126  case WID_PARA_LEV3:
1127  case WID_PARA_LEV4:
1128  case WID_PARA_LEV5:
1129  case WID_PARA_LEV6:
1130  case WID_PARA_LEV7:
1131  case WID_PARA_LEV8:
1132  case WID_PARA_LEV9:
1133  case WID_PARA_LEV10:
1134  {
1135  // in sdbcx::Index Label 1 begins at Pos 2 otherwise at Pos 1
1136  const sal_uInt16 nLPos = pTOXBase->GetType() == TOX_INDEX ? 2 : 1;
1137  OUString aString;
1139  rForm.GetTemplate(nLPos + pEntry->nWID - WID_PARA_LEV1),
1140  aString,
1142  aRet <<= aString;
1143  }
1144  break;
1146  {
1147  const bool bRet = rForm.IsRelTabPos();
1148  aRet <<= bRet;
1149  }
1150  break;
1151  case WID_INDEX_MARKS:
1152  {
1153  SwTOXMarks aMarks;
1154  const SwTOXType* pType = pTOXBase->GetTOXType();
1155  pType->CollectTextMarks(aMarks);
1156  uno::Sequence< uno::Reference<text::XDocumentIndexMark> > aXMarks(aMarks.size());
1157  uno::Reference<text::XDocumentIndexMark>* pxMarks = aXMarks.getArray();
1158  for(size_t i = 0; i < aMarks.size(); ++i)
1159  {
1160  SwTOXMark* pMark = aMarks[i];
1162  *m_pImpl->m_pDoc, pMark);
1163  }
1164  aRet <<= aXMarks;
1165  }
1166  break;
1167  default:
1168  //this is for items only
1169  if(WID_PRIMARY_KEY > pEntry->nWID)
1170  {
1171  const SwAttrSet& rSet =
1172  SwDoc::GetTOXBaseAttrSet(*pTOXBase);
1173  aRet = m_pImpl->m_rPropSet.getPropertyValue(
1174  rPropertyName, rSet);
1175  }
1176  }
1177  }
1178  return aRet;
1179 }
1180 
1181 void SAL_CALL
1183  const OUString& /*rPropertyName*/,
1184  const uno::Reference< beans::XPropertyChangeListener >& /*xListener*/)
1185 {
1186  OSL_FAIL("SwXDocumentIndex::addPropertyChangeListener(): not implemented");
1187 }
1188 
1189 void SAL_CALL
1191  const OUString& /*rPropertyName*/,
1192  const uno::Reference< beans::XPropertyChangeListener >& /*xListener*/)
1193 {
1194  OSL_FAIL("SwXDocumentIndex::removePropertyChangeListener(): not implemented");
1195 }
1196 
1197 void SAL_CALL
1199  const OUString& /*rPropertyName*/,
1200  const uno::Reference< beans::XVetoableChangeListener >& /*xListener*/)
1201 {
1202  OSL_FAIL("SwXDocumentIndex::addVetoableChangeListener(): not implemented");
1203 }
1204 
1205 void SAL_CALL
1207  const OUString& /*rPropertyName*/,
1208  const uno::Reference< beans::XVetoableChangeListener >& /*xListener*/)
1209 {
1210  OSL_FAIL("SwXDocumentIndex::removeVetoableChangeListener(): not implemented");
1211 }
1212 
1213 static void lcl_CalcLayout(SwDoc *pDoc)
1214 {
1215  SwViewShell *pViewShell = nullptr;
1216  SwEditShell* pEditShell = nullptr;
1217  if( pDoc )
1218  {
1219  pViewShell = pDoc->getIDocumentLayoutAccess().GetCurrentViewShell();
1220  pEditShell = pDoc->GetEditShell();
1221  }
1222 
1223  if (pEditShell)
1224  {
1225  pEditShell->CalcLayout();
1226  }
1227  else if (pViewShell)
1228  {
1229  pViewShell->CalcLayout();
1230  }
1231 }
1232 
1233 // XRefreshable
1235 {
1236  {
1237  SolarMutexGuard g;
1238 
1239  SwSectionFormat *const pFormat = m_pImpl->GetSectionFormat();
1240  SwTOXBaseSection *const pTOXBase = pFormat ?
1241  static_cast<SwTOXBaseSection*>(pFormat->GetSection()) : nullptr;
1242  if (!pTOXBase)
1243  {
1244  throw uno::RuntimeException(
1245  "SwXDocumentIndex::refresh: must be in attached state",
1246  static_cast< ::cppu::OWeakObject*>(this));
1247  }
1248  pTOXBase->Update(nullptr, m_pImpl->m_pDoc->getIDocumentLayoutAccess().GetCurrentLayout());
1249 
1250  // the insertion of TOC will affect the document layout
1251  lcl_CalcLayout(m_pImpl->m_pDoc);
1252 
1253  // page numbers
1254  pTOXBase->UpdatePageNum();
1255  }
1256 
1257  ::comphelper::OInterfaceContainerHelper2 *const pContainer(
1258  m_pImpl->m_Listeners.getContainer(
1260  if (pContainer)
1261  {
1262  lang::EventObject const event(static_cast< ::cppu::OWeakObject*>(this));
1263  pContainer->notifyEach(& util::XRefreshListener::refreshed, event);
1264  }
1265 }
1266 
1268  const uno::Reference<util::XRefreshListener>& xListener)
1269 {
1270  // no need to lock here as m_pImpl is const and container threadsafe
1271  m_pImpl->m_Listeners.addInterface(
1273 }
1274 
1276  const uno::Reference<util::XRefreshListener>& xListener)
1277 {
1278  // no need to lock here as m_pImpl is const and container threadsafe
1279  m_pImpl->m_Listeners.removeInterface(
1281 }
1282 
1283 void SAL_CALL
1284 SwXDocumentIndex::attach(const uno::Reference< text::XTextRange > & xTextRange)
1285 {
1286  SolarMutexGuard aGuard;
1287 
1288  if (!m_pImpl->m_bIsDescriptor)
1289  {
1290  throw uno::RuntimeException();
1291  }
1292  const uno::Reference<XUnoTunnel> xRangeTunnel( xTextRange, uno::UNO_QUERY);
1293  SwXTextRange *const pRange =
1294  comphelper::getFromUnoTunnel<SwXTextRange>(xRangeTunnel);
1295  OTextCursorHelper *const pCursor =
1296  comphelper::getFromUnoTunnel<OTextCursorHelper>(xRangeTunnel);
1297 
1298  SwDoc *const pDoc =
1299  pRange ? &pRange->GetDoc() : (pCursor ? pCursor->GetDoc() : nullptr);
1300  if (!pDoc)
1301  {
1302  throw lang::IllegalArgumentException();
1303  }
1304 
1305  SwUnoInternalPaM aPam(*pDoc);
1306  // this now needs to return TRUE
1307  ::sw::XTextRangeToSwPaM(aPam, xTextRange);
1308 
1309  const SwTOXBase* pOld = SwDoc::GetCurTOX( *aPam.Start() );
1310  if (pOld)
1311  {
1312  throw lang::IllegalArgumentException();
1313  }
1314 
1315  UnoActionContext aAction(pDoc);
1316 
1317  SwTOXBase & rTOXBase = m_pImpl->m_pProps->GetTOXBase();
1318  SwTOXType const*const pTOXType = rTOXBase.GetTOXType();
1319  if ((TOX_USER == pTOXType->GetType()) &&
1320  m_pImpl->m_pProps->GetTypeName() != pTOXType->GetTypeName())
1321  {
1322  lcl_ReAssignTOXType(*pDoc, rTOXBase, m_pImpl->m_pProps->GetTypeName());
1323  }
1324  //TODO: apply Section attributes (columns and background)
1325  SwTOXBaseSection *const pTOX =
1326  pDoc->InsertTableOf( aPam, rTOXBase, nullptr, false,
1327  m_pImpl->m_pDoc->getIDocumentLayoutAccess().GetCurrentLayout());
1328 
1329  pDoc->SetTOXBaseName(*pTOX, m_pImpl->m_pProps->GetTOXBase().GetTOXName());
1330 
1331  // update page numbers
1332  m_pImpl->SetSectionFormat(*pTOX->GetFormat());
1333  pTOX->GetFormat()->SetXObject(static_cast< ::cppu::OWeakObject*>(this));
1334  pTOX->UpdatePageNum();
1335 
1336  m_pImpl->m_pProps.reset();
1337  m_pImpl->m_pDoc = pDoc;
1338  m_pImpl->m_bIsDescriptor = false;
1339 }
1340 
1341 uno::Reference< text::XTextRange > SAL_CALL
1343 {
1344  SolarMutexGuard aGuard;
1345 
1346  SwSectionFormat *const pSectionFormat( m_pImpl->GetSectionFormat() );
1347  if (!pSectionFormat)
1348  {
1349  throw uno::RuntimeException();
1350  }
1351 
1352  uno::Reference< text::XTextRange > xRet;
1353  SwNodeIndex const*const pIdx( pSectionFormat->GetContent().GetContentIdx() );
1354  if (pIdx && pIdx->GetNode().GetNodes().IsDocNodes())
1355  {
1356  SwPaM aPaM(*pIdx);
1357  aPaM.Move( fnMoveForward, GoInContent );
1358  aPaM.SetMark();
1359  aPaM.GetPoint()->nNode = *pIdx->GetNode().EndOfSectionNode();
1360  aPaM.Move( fnMoveBackward, GoInContent );
1361  xRet = SwXTextRange::CreateXTextRange(*pSectionFormat->GetDoc(),
1362  *aPaM.GetMark(), aPaM.GetPoint());
1363  }
1364  return xRet;
1365 }
1366 
1368 {
1369  SolarMutexGuard aGuard;
1370 
1371  SwSectionFormat *const pSectionFormat( m_pImpl->GetSectionFormat() );
1372  if (pSectionFormat)
1373  {
1374  pSectionFormat->GetDoc()->DeleteTOX(
1375  *static_cast<SwTOXBaseSection*>(pSectionFormat->GetSection()),
1376  true);
1377  }
1378 }
1379 
1380 void SAL_CALL
1382  const uno::Reference< lang::XEventListener > & xListener)
1383 {
1384  // no need to lock here as m_pImpl is const and container threadsafe
1385  m_pImpl->m_Listeners.addInterface(
1387 }
1388 
1389 void SAL_CALL
1391  const uno::Reference< lang::XEventListener > & xListener)
1392 {
1393  // no need to lock here as m_pImpl is const and container threadsafe
1394  m_pImpl->m_Listeners.removeInterface(
1396 }
1397 
1398 OUString SAL_CALL SwXDocumentIndex::getName()
1399 {
1400  SolarMutexGuard g;
1401 
1402  SwSectionFormat *const pSectionFormat( m_pImpl->GetSectionFormat() );
1403  if (m_pImpl->m_bIsDescriptor)
1404  {
1405  return m_pImpl->m_pProps->GetTOXBase().GetTOXName();
1406  }
1407 
1408  if(!pSectionFormat)
1409  {
1410  throw uno::RuntimeException();
1411  }
1412 
1413  return pSectionFormat->GetSection()->GetSectionName();
1414 }
1415 
1416 void SAL_CALL
1417 SwXDocumentIndex::setName(const OUString& rName)
1418 {
1419  SolarMutexGuard g;
1420 
1421  if (rName.isEmpty())
1422  {
1423  throw uno::RuntimeException();
1424  }
1425 
1426  SwSectionFormat *const pSectionFormat( m_pImpl->GetSectionFormat() );
1427  if (m_pImpl->m_bIsDescriptor)
1428  {
1429  m_pImpl->m_pProps->GetTOXBase().SetTOXName(rName);
1430  }
1431  else if (pSectionFormat)
1432  {
1433  const bool bSuccess = pSectionFormat->GetDoc()->SetTOXBaseName(
1434  *static_cast<SwTOXBaseSection*>(pSectionFormat->GetSection()), rName);
1435  if (!bSuccess)
1436  {
1437  throw uno::RuntimeException();
1438  }
1439  }
1440  else
1441  {
1442  throw uno::RuntimeException();
1443  }
1444 }
1445 
1446 // MetadatableMixin
1448 {
1449  SwSectionFormat *const pSectionFormat( m_pImpl->GetSectionFormat() );
1450  return pSectionFormat;
1451 }
1452 
1453 uno::Reference<frame::XModel> SwXDocumentIndex::GetModel()
1454 {
1455  SwSectionFormat *const pSectionFormat( m_pImpl->GetSectionFormat() );
1456  if (pSectionFormat)
1457  {
1458  SwDocShell const*const pShell( pSectionFormat->GetDoc()->GetDocShell() );
1459  return pShell ? pShell->GetModel() : nullptr;
1460  }
1461  return nullptr;
1462 }
1463 
1464 static sal_uInt16
1466 {
1467  switch (eType)
1468  {
1469  case TOX_INDEX: return PROPERTY_MAP_INDEX_MARK;
1472  //case TOX_USER:
1473  default:
1474  return PROPERTY_MAP_USER_MARK;
1475  }
1476 }
1477 
1479 {
1480 private:
1483 
1484 public:
1485 
1486  uno::WeakReference<uno::XInterface> m_wThis;
1489  std::mutex m_Mutex; // just for OInterfaceContainerHelper4
1495 
1497  sal_uInt16 m_nLevel;
1499  OUString m_sAltText;
1500  OUString m_sPrimaryKey;
1502  OUString m_sTextReading;
1506 
1508  SwDoc* const pDoc,
1509  const enum TOXTypes eType,
1510  const SwTOXType* pType,
1511  SwTOXMark const* pMark)
1512  : m_rThis(rThis)
1513  , m_bInReplaceMark(false)
1514  , m_rPropSet(
1515  *aSwMapProvider.GetPropertySet(lcl_TypeToPropertyMap_Mark(eType)))
1516  , m_eTOXType(eType)
1517  , m_bIsDescriptor(nullptr == pMark)
1518  , m_pTOXType(pType)
1519  , m_pTOXMark(pMark)
1520  , m_pDoc(pDoc)
1521  , m_bMainEntry(false)
1522  , m_nLevel(0)
1523  {
1524  auto pMarkNonConst = const_cast<SwTOXMark*>(m_pTOXMark);
1525  auto pTypeNonConst = const_cast<SwTOXType*>(m_pTOXType);
1526 
1527  if(pMarkNonConst)
1528  StartListening(pMarkNonConst->GetNotifier());
1529  if(pTypeNonConst)
1530  StartListening(pTypeNonConst->GetNotifier());
1531  }
1532 
1534  return const_cast<SwTOXType*>(m_pTOXType);
1535  }
1536 
1538  {
1539  m_pDoc->DeleteTOXMark(m_pTOXMark);
1540  Invalidate();
1541  }
1542 
1543  void InsertTOXMark(const SwTOXType & rTOXType, SwTOXMark & rMark, SwPaM & rPam,
1544  SwXTextCursor const*const pTextCursor);
1545 
1546  void ReplaceTOXMark(const SwTOXType & rTOXType, SwTOXMark & rMark, SwPaM & rPam)
1547  {
1548  m_bInReplaceMark = true;
1549  DeleteTOXMark();
1550  m_bInReplaceMark = false;
1551  try {
1552  InsertTOXMark(rTOXType, rMark, rPam, nullptr);
1553  } catch (...) {
1554  OSL_FAIL("ReplaceTOXMark() failed!");
1555  lang::EventObject const ev(
1556  static_cast< ::cppu::OWeakObject&>(m_rThis));
1557  std::unique_lock aGuard(m_Mutex);
1558  m_EventListeners.disposeAndClear(aGuard, ev);
1559  throw;
1560  }
1561  }
1562 
1563  void Invalidate();
1564  virtual void Notify(const SfxHint&) override;
1565 };
1566 
1568 {
1569  if (!m_bInReplaceMark) // #i109983# only dispose on delete, not on replace!
1570  {
1571  uno::Reference<uno::XInterface> const xThis(m_wThis);
1572  // fdo#72695: if UNO object is already dead, don't revive it with event
1573  if (xThis.is())
1574  {
1575  lang::EventObject const ev(xThis);
1576  std::unique_lock aGuard(m_Mutex);
1577  m_EventListeners.disposeAndClear(aGuard, ev);
1578  }
1579  }
1580  EndListeningAll();
1581  m_pDoc = nullptr;
1582  m_pTOXMark = nullptr;
1583  m_pTOXType = nullptr;
1584 }
1585 
1587 {
1588  if(auto pModifyChangedHint = dynamic_cast<const sw::ModifyChangedHint*>(&rHint))
1589  {
1590  if(auto pNewType = dynamic_cast<const SwTOXType*>(pModifyChangedHint->m_pNew))
1591  m_pTOXType = pNewType;
1592 
1593  else
1594  Invalidate();
1595  }
1596 }
1597 
1599  : m_pImpl( new SwXDocumentIndexMark::Impl(*this, nullptr, eToxType, nullptr, nullptr) )
1600 {
1601 }
1602 
1604  const SwTOXType & rType, const SwTOXMark & rMark)
1605  : m_pImpl( new SwXDocumentIndexMark::Impl(*this, &rDoc, rType.GetType(),
1606  &rType, &rMark) )
1607 {
1608 }
1609 
1611 {
1612 }
1613 
1614 uno::Reference<text::XDocumentIndexMark>
1616  SwDoc & rDoc, SwTOXMark *const pMark, TOXTypes const eType)
1617 {
1618  // re-use existing SwXDocumentIndexMark
1619  // NB: xmloff depends on this caching to generate ID from the address!
1620  // #i105557#: do not iterate over the registered clients: race condition
1621  uno::Reference<text::XDocumentIndexMark> xTOXMark;
1622  if (pMark)
1623  {
1624  xTOXMark = pMark->GetXTOXMark();
1625  }
1626  if (!xTOXMark.is())
1627  {
1628  SwXDocumentIndexMark *const pNew(pMark
1629  ? new SwXDocumentIndexMark(rDoc,
1630  *const_cast<SwTOXType*>(pMark->GetTOXType()), *pMark)
1631  : new SwXDocumentIndexMark(eType));
1632  xTOXMark.set(pNew);
1633  if (pMark)
1634  {
1635  pMark->SetXTOXMark(xTOXMark);
1636  }
1637  // need a permanent Reference to initialize m_wThis
1638  pNew->m_pImpl->m_wThis = xTOXMark;
1639  }
1640  return xTOXMark;
1641 }
1642 
1643 namespace
1644 {
1645 }
1646 
1647 const uno::Sequence< sal_Int8 > & SwXDocumentIndexMark::getUnoTunnelId()
1648 {
1649  static const comphelper::UnoIdInit theSwXDocumentIndexMarkUnoTunnelId;
1650  return theSwXDocumentIndexMarkUnoTunnelId.getSeq();
1651 }
1652 
1653 sal_Int64 SAL_CALL
1654 SwXDocumentIndexMark::getSomething(const uno::Sequence< sal_Int8 >& rId)
1655 {
1656  return comphelper::getSomethingImpl<SwXDocumentIndexMark>(rId, this);
1657 }
1658 
1659 OUString SAL_CALL
1661 {
1662  return "SwXDocumentIndexMark";
1663 }
1664 
1665 sal_Bool SAL_CALL SwXDocumentIndexMark::supportsService(const OUString& rServiceName)
1666 {
1667  return cppu::supportsService(this, rServiceName);
1668 }
1669 
1670 uno::Sequence< OUString > SAL_CALL
1672 {
1673  SolarMutexGuard g;
1674 
1675  const sal_Int32 nCnt = (m_pImpl->m_eTOXType == TOX_INDEX) ? 4 : 3;
1676  uno::Sequence< OUString > aRet(nCnt);
1677  OUString* pArray = aRet.getArray();
1678  pArray[0] = "com.sun.star.text.BaseIndexMark";
1679  pArray[1] = "com.sun.star.text.TextContent";
1680  switch (m_pImpl->m_eTOXType)
1681  {
1682  case TOX_USER:
1683  pArray[2] = "com.sun.star.text.UserIndexMark";
1684  break;
1685  case TOX_CONTENT:
1686  pArray[2] = "com.sun.star.text.ContentIndexMark";
1687  break;
1688  case TOX_INDEX:
1689  pArray[2] = "com.sun.star.text.DocumentIndexMark";
1690  pArray[3] = "com.sun.star.text.DocumentIndexMarkAsian";
1691  break;
1692 
1693  default:
1694  ;
1695  }
1696  return aRet;
1697 }
1698 
1699 OUString SAL_CALL
1701 {
1702  SolarMutexGuard aGuard;
1703 
1704  SwTOXType *const pType = m_pImpl->GetTOXType();
1705  if (pType && m_pImpl->m_pTOXMark)
1706  {
1707  return m_pImpl->m_pTOXMark->GetAlternativeText();
1708  }
1709 
1710  if (!m_pImpl->m_bIsDescriptor)
1711  {
1712  throw uno::RuntimeException();
1713  }
1714 
1715  return m_pImpl->m_sAltText;
1716 }
1717 
1718 void SAL_CALL
1719 SwXDocumentIndexMark::setMarkEntry(const OUString& rIndexEntry)
1720 {
1721  SolarMutexGuard aGuard;
1722 
1723  SwTOXType *const pType = m_pImpl->GetTOXType();
1724  if (pType && m_pImpl->m_pTOXMark)
1725  {
1726  SwTOXMark aMark(*m_pImpl->m_pTOXMark);
1727  aMark.SetAlternativeText(rIndexEntry);
1728  SwTextTOXMark const*const pTextMark =
1729  m_pImpl->m_pTOXMark->GetTextTOXMark();
1730  SwPaM aPam(pTextMark->GetTextNode(), pTextMark->GetStart());
1731  aPam.SetMark();
1732  if(pTextMark->End())
1733  {
1734  aPam.GetPoint()->nContent = *pTextMark->End();
1735  }
1736  else
1737  ++aPam.GetPoint()->nContent;
1738 
1739  m_pImpl->ReplaceTOXMark(*pType, aMark, aPam);
1740  }
1741  else if (m_pImpl->m_bIsDescriptor)
1742  {
1743  m_pImpl->m_sAltText = rIndexEntry;
1744  }
1745  else
1746  {
1747  throw uno::RuntimeException();
1748  }
1749 }
1750 
1751 void SAL_CALL
1753  const uno::Reference< text::XTextRange > & xTextRange)
1754 {
1755  SolarMutexGuard aGuard;
1756 
1757  if (!m_pImpl->m_bIsDescriptor)
1758  {
1759  throw uno::RuntimeException();
1760  }
1761 
1762  const uno::Reference<XUnoTunnel> xRangeTunnel(xTextRange, uno::UNO_QUERY);
1763  SwXTextRange *const pRange =
1764  comphelper::getFromUnoTunnel<SwXTextRange>(xRangeTunnel);
1765  OTextCursorHelper *const pCursor =
1766  comphelper::getFromUnoTunnel<OTextCursorHelper>(xRangeTunnel);
1767  SwDoc *const pDoc =
1768  pRange ? &pRange->GetDoc() : (pCursor ? pCursor->GetDoc() : nullptr);
1769  if (!pDoc)
1770  {
1771  throw lang::IllegalArgumentException();
1772  }
1773 
1774  const SwTOXType* pTOXType = nullptr;
1775  switch (m_pImpl->m_eTOXType)
1776  {
1777  case TOX_INDEX:
1778  case TOX_CONTENT:
1779  case TOX_CITATION:
1780  pTOXType = pDoc->GetTOXType( m_pImpl->m_eTOXType, 0 );
1781  break;
1782  case TOX_USER:
1783  {
1784  if (m_pImpl->m_sUserIndexName.isEmpty())
1785  {
1786  pTOXType = pDoc->GetTOXType( m_pImpl->m_eTOXType, 0 );
1787  }
1788  else
1789  {
1790  const sal_uInt16 nCount =
1791  pDoc->GetTOXTypeCount(m_pImpl->m_eTOXType);
1792  for (sal_uInt16 i = 0; i < nCount; i++)
1793  {
1794  SwTOXType const*const pTemp =
1795  pDoc->GetTOXType( m_pImpl->m_eTOXType, i );
1796  if (m_pImpl->m_sUserIndexName == pTemp->GetTypeName())
1797  {
1798  pTOXType = pTemp;
1799  break;
1800  }
1801  }
1802  if (!pTOXType)
1803  {
1804  SwTOXType aUserType(*pDoc, TOX_USER, m_pImpl->m_sUserIndexName);
1805  pTOXType = pDoc->InsertTOXType(aUserType);
1806  }
1807  }
1808  }
1809  break;
1810 
1811  default:
1812  break;
1813  }
1814  if (!pTOXType)
1815  {
1816  throw lang::IllegalArgumentException();
1817  }
1818 
1819  SwUnoInternalPaM aPam(*pDoc);
1820  // this now needs to return TRUE
1821  ::sw::XTextRangeToSwPaM(aPam, xTextRange);
1822  SwTOXMark aMark (pTOXType);
1823  if (!m_pImpl->m_sAltText.isEmpty())
1824  {
1825  aMark.SetAlternativeText(m_pImpl->m_sAltText);
1826  }
1827  switch (m_pImpl->m_eTOXType)
1828  {
1829  case TOX_INDEX:
1830  if (!m_pImpl->m_sPrimaryKey.isEmpty())
1831  {
1832  aMark.SetPrimaryKey(m_pImpl->m_sPrimaryKey);
1833  }
1834  if (!m_pImpl->m_sSecondaryKey.isEmpty())
1835  {
1836  aMark.SetSecondaryKey(m_pImpl->m_sSecondaryKey);
1837  }
1838  if (!m_pImpl->m_sTextReading.isEmpty())
1839  {
1840  aMark.SetTextReading(m_pImpl->m_sTextReading);
1841  }
1842  if (!m_pImpl->m_sPrimaryKeyReading.isEmpty())
1843  {
1844  aMark.SetPrimaryKeyReading(m_pImpl->m_sPrimaryKeyReading);
1845  }
1846  if (!m_pImpl->m_sSecondaryKeyReading.isEmpty())
1847  {
1848  aMark.SetSecondaryKeyReading(m_pImpl->m_sSecondaryKeyReading);
1849  }
1850  aMark.SetMainEntry(m_pImpl->m_bMainEntry);
1851  break;
1852  case TOX_CITATION:
1853  aMark.SetMainEntry(m_pImpl->m_bMainEntry);
1854  break;
1855  case TOX_USER:
1856  case TOX_CONTENT:
1857  if (USHRT_MAX != m_pImpl->m_nLevel)
1858  {
1859  aMark.SetLevel(m_pImpl->m_nLevel+1);
1860  }
1861  break;
1862 
1863  default:
1864  break;
1865  }
1866 
1867  m_pImpl->InsertTOXMark(*const_cast<SwTOXType *>(pTOXType), aMark, aPam,
1868  dynamic_cast<SwXTextCursor const*>(pCursor));
1869 
1870  m_pImpl->m_bIsDescriptor = false;
1871 }
1872 
1873 namespace {
1874 
1875 template<typename T> struct NotContainedIn
1876 {
1877  std::vector<T> const& m_rVector;
1878  explicit NotContainedIn(std::vector<T> const& rVector)
1879  : m_rVector(rVector) { }
1880  bool operator() (T const& rT) {
1881  return std::find(m_rVector.begin(), m_rVector.end(), rT)
1882  == m_rVector.end();
1883  }
1884 };
1885 
1886 }
1887 
1889  const SwTOXType & rTOXType, SwTOXMark & rMark, SwPaM & rPam,
1890  SwXTextCursor const*const pTextCursor)
1891 {
1892  SwDoc& rDoc(rPam.GetDoc());
1893  UnoActionContext aAction(&rDoc);
1894  bool bMark = *rPam.GetPoint() != *rPam.GetMark();
1895  // n.b.: toxmarks must have either alternative text or an extent
1896  if (bMark && !rMark.GetAlternativeText().isEmpty())
1897  {
1898  rPam.Normalize();
1899  rPam.DeleteMark();
1900  bMark = false;
1901  }
1902  // Marks without alternative text and without selected text cannot be inserted,
1903  // thus use a space - is this really the ideal solution?
1904  if (!bMark && rMark.GetAlternativeText().isEmpty())
1905  {
1906  rMark.SetAlternativeText( " " );
1907  }
1908 
1909  const bool bForceExpandHints( !bMark && pTextCursor && pTextCursor->IsAtEndOfMeta() );
1910  const SetAttrMode nInsertFlags = bForceExpandHints
1914 
1915  // rMark gets copied into the document pool;
1916  // pNewTextAttr comes back with the real format
1917  SwTextAttr *pNewTextAttr = nullptr;
1918  rDoc.getIDocumentContentOperations().InsertPoolItem(rPam, rMark, nInsertFlags,
1919  /*pLayout*/nullptr, &pNewTextAttr);
1920  if (bMark && *rPam.GetPoint() > *rPam.GetMark())
1921  {
1922  rPam.Exchange();
1923  }
1924 
1925  if (!pNewTextAttr)
1926  {
1927  throw uno::RuntimeException(
1928  "SwXDocumentIndexMark::InsertTOXMark(): cannot insert attribute",
1929  nullptr);
1930  }
1931 
1932  m_pDoc = &rDoc;
1933  m_pTOXMark = &pNewTextAttr->GetTOXMark();
1934  m_pTOXType = &rTOXType;
1935  EndListeningAll();
1936  StartListening(const_cast<SwTOXMark*>(m_pTOXMark)->GetNotifier());
1937  StartListening(const_cast<SwTOXType*>(m_pTOXType)->GetNotifier());
1938 }
1939 
1940 uno::Reference< text::XTextRange > SAL_CALL
1942 {
1943  SolarMutexGuard aGuard;
1944 
1945  SwTOXType *const pType = m_pImpl->GetTOXType();
1946  if (!pType || !m_pImpl->m_pTOXMark)
1947  {
1948  throw uno::RuntimeException();
1949  }
1950  if (!m_pImpl->m_pTOXMark->GetTextTOXMark())
1951  {
1952  throw uno::RuntimeException();
1953  }
1954  const SwTextTOXMark* pTextMark = m_pImpl->m_pTOXMark->GetTextTOXMark();
1955  SwPaM aPam(pTextMark->GetTextNode(), pTextMark->GetStart());
1956  aPam.SetMark();
1957  if(pTextMark->End())
1958  {
1959  aPam.GetPoint()->nContent = *pTextMark->End();
1960  }
1961  else
1962  {
1963  ++aPam.GetPoint()->nContent;
1964  }
1965  const uno::Reference< frame::XModel > xModel =
1966  m_pImpl->m_pDoc->GetDocShell()->GetBaseModel();
1967  const uno::Reference< text::XTextDocument > xTDoc(xModel, uno::UNO_QUERY);
1968  const uno::Reference< text::XTextRange > xRet =
1969  new SwXTextRange(aPam, xTDoc->getText());
1970 
1971  return xRet;
1972 }
1973 
1974 void SAL_CALL
1976 {
1977  SolarMutexGuard aGuard;
1978 
1979  SwTOXType *const pType = m_pImpl->GetTOXType();
1980  if (pType && m_pImpl->m_pTOXMark)
1981  {
1982  m_pImpl->DeleteTOXMark(); // call Invalidate() via modify!
1983  }
1984 }
1985 
1986 void SAL_CALL
1988  const uno::Reference< lang::XEventListener > & xListener)
1989 {
1990  // no need to lock here as m_pImpl is const and container threadsafe
1991  std::unique_lock aGuard(m_pImpl->m_Mutex);
1992  m_pImpl->m_EventListeners.addInterface(aGuard, xListener);
1993 }
1994 
1995 void SAL_CALL
1997  const uno::Reference< lang::XEventListener > & xListener)
1998 {
1999  // no need to lock here as m_pImpl is const and container threadsafe
2000  std::unique_lock aGuard(m_pImpl->m_Mutex);
2001  m_pImpl->m_EventListeners.removeInterface(aGuard, xListener);
2002 }
2003 
2004 uno::Reference< beans::XPropertySetInfo > SAL_CALL
2006 {
2007  SolarMutexGuard g;
2008 
2009  static uno::Reference< beans::XPropertySetInfo > xInfos[3];
2010  int nPos = 0;
2011  switch (m_pImpl->m_eTOXType)
2012  {
2013  case TOX_INDEX: nPos = 0; break;
2014  case TOX_CONTENT: nPos = 1; break;
2015  case TOX_USER: nPos = 2; break;
2016  default:
2017  ;
2018  }
2019  if(!xInfos[nPos].is())
2020  {
2021  const uno::Reference< beans::XPropertySetInfo > xInfo =
2022  m_pImpl->m_rPropSet.getPropertySetInfo();
2023  // extend PropertySetInfo!
2024  const uno::Sequence<beans::Property> aPropSeq = xInfo->getProperties();
2025  xInfos[nPos] = new SfxExtItemPropertySetInfo(
2028  aPropSeq );
2029  }
2030  return xInfos[nPos];
2031 }
2032 
2033 void SAL_CALL
2035  const OUString& rPropertyName, const uno::Any& rValue)
2036 {
2037  SolarMutexGuard aGuard;
2038 
2039  SfxItemPropertyMapEntry const*const pEntry =
2040  m_pImpl->m_rPropSet.getPropertyMap().getByName(rPropertyName);
2041  if (!pEntry)
2042  {
2043  throw beans::UnknownPropertyException(
2044  "Unknown property: " + rPropertyName,
2045  static_cast<cppu::OWeakObject *>(this));
2046  }
2047  if (pEntry->nFlags & beans::PropertyAttribute::READONLY)
2048  {
2049  throw beans::PropertyVetoException(
2050  "Property is read-only: " + rPropertyName,
2051  static_cast<cppu::OWeakObject *>(this));
2052  }
2053 
2054  SwTOXType *const pType = m_pImpl->GetTOXType();
2055  if (pType && m_pImpl->m_pTOXMark)
2056  {
2057  SwTOXMark aMark(*m_pImpl->m_pTOXMark);
2058  switch(pEntry->nWID)
2059  {
2060  case WID_ALT_TEXT:
2061  aMark.SetAlternativeText(lcl_AnyToType<OUString>(rValue));
2062  break;
2063  case WID_LEVEL:
2064  aMark.SetLevel(std::min( static_cast<sal_Int8>( MAXLEVEL ),
2065  static_cast<sal_Int8>(lcl_AnyToType<sal_Int16>(rValue)+1)));
2066  break;
2067  case WID_TOC_BOOKMARK :
2068  aMark.SetBookmarkName(lcl_AnyToType<OUString>(rValue));
2069  break;
2070  case WID_PRIMARY_KEY :
2071  aMark.SetPrimaryKey(lcl_AnyToType<OUString>(rValue));
2072  break;
2073  case WID_SECONDARY_KEY:
2074  aMark.SetSecondaryKey(lcl_AnyToType<OUString>(rValue));
2075  break;
2076  case WID_MAIN_ENTRY:
2077  aMark.SetMainEntry(lcl_AnyToType<bool>(rValue));
2078  break;
2079  case WID_TEXT_READING:
2080  aMark.SetTextReading(lcl_AnyToType<OUString>(rValue));
2081  break;
2083  aMark.SetPrimaryKeyReading(lcl_AnyToType<OUString>(rValue));
2084  break;
2086  aMark.SetSecondaryKeyReading(lcl_AnyToType<OUString>(rValue));
2087  break;
2088  }
2089  SwTextTOXMark const*const pTextMark =
2090  m_pImpl->m_pTOXMark->GetTextTOXMark();
2091  SwPaM aPam(pTextMark->GetTextNode(), pTextMark->GetStart());
2092  aPam.SetMark();
2093  if(pTextMark->End())
2094  {
2095  aPam.GetPoint()->nContent = *pTextMark->End();
2096  }
2097  else
2098  {
2099  ++aPam.GetPoint()->nContent;
2100  }
2101 
2102  m_pImpl->ReplaceTOXMark(*pType, aMark, aPam);
2103  }
2104  else if (m_pImpl->m_bIsDescriptor)
2105  {
2106  switch(pEntry->nWID)
2107  {
2108  case WID_ALT_TEXT:
2109  m_pImpl->m_sAltText = lcl_AnyToType<OUString>(rValue);
2110  break;
2111  case WID_LEVEL:
2112  {
2113  const sal_Int16 nVal = lcl_AnyToType<sal_Int16>(rValue);
2114  if(nVal < 0 || nVal >= MAXLEVEL)
2115  {
2116  throw lang::IllegalArgumentException();
2117  }
2118  m_pImpl->m_nLevel = nVal;
2119  }
2120  break;
2121  case WID_TOC_BOOKMARK :
2122  {
2123  m_pImpl->m_aBookmarkName = lcl_AnyToType<OUString>(rValue);
2124  }
2125  break;
2126  case WID_PRIMARY_KEY:
2127  m_pImpl->m_sPrimaryKey = lcl_AnyToType<OUString>(rValue);
2128  break;
2129  case WID_SECONDARY_KEY:
2130  m_pImpl->m_sSecondaryKey = lcl_AnyToType<OUString>(rValue);
2131  break;
2132  case WID_TEXT_READING:
2133  m_pImpl->m_sTextReading = lcl_AnyToType<OUString>(rValue);
2134  break;
2136  m_pImpl->m_sPrimaryKeyReading = lcl_AnyToType<OUString>(rValue);
2137  break;
2139  m_pImpl->m_sSecondaryKeyReading = lcl_AnyToType<OUString>(rValue);
2140  break;
2141  case WID_USER_IDX_NAME:
2142  {
2143  OUString sTmp(lcl_AnyToType<OUString>(rValue));
2145  m_pImpl->m_sUserIndexName = sTmp;
2146  }
2147  break;
2148  case WID_MAIN_ENTRY:
2149  m_pImpl->m_bMainEntry = lcl_AnyToType<bool>(rValue);
2150  break;
2152  // unsupported
2153  break;
2154  }
2155  }
2156  else
2157  {
2158  throw uno::RuntimeException();
2159  }
2160 }
2161 
2162 uno::Any SAL_CALL
2163 SwXDocumentIndexMark::getPropertyValue(const OUString& rPropertyName)
2164 {
2165  SolarMutexGuard aGuard;
2166 
2167  uno::Any aRet;
2168  SfxItemPropertyMapEntry const*const pEntry =
2169  m_pImpl->m_rPropSet.getPropertyMap().getByName(rPropertyName);
2170  if (!pEntry)
2171  {
2172  throw beans::UnknownPropertyException(
2173  "Unknown property: " + rPropertyName,
2174  static_cast<cppu::OWeakObject *>(this));
2175  }
2176  if (::sw::GetDefaultTextContentValue(aRet, rPropertyName, pEntry->nWID))
2177  {
2178  return aRet;
2179  }
2180 
2181  SwTOXType *const pType = m_pImpl->GetTOXType();
2182  if (pType && m_pImpl->m_pTOXMark)
2183  {
2184  switch(pEntry->nWID)
2185  {
2186  case WID_ALT_TEXT:
2187  aRet <<= m_pImpl->m_pTOXMark->GetAlternativeText();
2188  break;
2189  case WID_LEVEL:
2190  aRet <<= static_cast<sal_Int16>(
2191  m_pImpl->m_pTOXMark->GetLevel() - 1);
2192  break;
2193  case WID_TOC_BOOKMARK :
2194  aRet <<= m_pImpl->m_pTOXMark->GetBookmarkName();
2195  break;
2196  case WID_PRIMARY_KEY :
2197  aRet <<= m_pImpl->m_pTOXMark->GetPrimaryKey();
2198  break;
2199  case WID_SECONDARY_KEY:
2200  aRet <<= m_pImpl->m_pTOXMark->GetSecondaryKey();
2201  break;
2202  case WID_TEXT_READING:
2203  aRet <<= m_pImpl->m_pTOXMark->GetTextReading();
2204  break;
2206  aRet <<= m_pImpl->m_pTOXMark->GetPrimaryKeyReading();
2207  break;
2209  aRet <<= m_pImpl->m_pTOXMark->GetSecondaryKeyReading();
2210  break;
2211  case WID_USER_IDX_NAME :
2212  {
2213  OUString sTmp(pType->GetTypeName());
2215  aRet <<= sTmp;
2216  }
2217  break;
2218  case WID_MAIN_ENTRY:
2219  {
2220  const bool bTemp = m_pImpl->m_pTOXMark->IsMainEntry();
2221  aRet <<= bTemp;
2222  }
2223  break;
2224  }
2225  }
2226  else if (m_pImpl->m_bIsDescriptor)
2227  {
2228  switch(pEntry->nWID)
2229  {
2230  case WID_ALT_TEXT:
2231  aRet <<= m_pImpl->m_sAltText;
2232  break;
2233  case WID_LEVEL:
2234  aRet <<= static_cast<sal_Int16>(m_pImpl->m_nLevel);
2235  break;
2236  case WID_TOC_BOOKMARK :
2237  aRet <<= m_pImpl->m_aBookmarkName;
2238  break;
2239  case WID_PRIMARY_KEY:
2240  aRet <<= m_pImpl->m_sPrimaryKey;
2241  break;
2242  case WID_SECONDARY_KEY:
2243  aRet <<= m_pImpl->m_sSecondaryKey;
2244  break;
2245  case WID_TEXT_READING:
2246  aRet <<= m_pImpl->m_sTextReading;
2247  break;
2249  aRet <<= m_pImpl->m_sPrimaryKeyReading;
2250  break;
2252  aRet <<= m_pImpl->m_sSecondaryKeyReading;
2253  break;
2254  case WID_USER_IDX_NAME :
2255  aRet <<= m_pImpl->m_sUserIndexName;
2256  break;
2257  case WID_MAIN_ENTRY:
2258  aRet <<= m_pImpl->m_bMainEntry;
2259  break;
2260  }
2261  }
2262  else
2263  {
2264  throw uno::RuntimeException();
2265  }
2266  return aRet;
2267 }
2268 
2269 void SAL_CALL
2271  const OUString& /*rPropertyName*/,
2272  const uno::Reference< beans::XPropertyChangeListener >& /*xListener*/)
2273 {
2274  OSL_FAIL("SwXDocumentIndexMark::addPropertyChangeListener(): not implemented");
2275 }
2276 
2277 void SAL_CALL
2279  const OUString& /*rPropertyName*/,
2280  const uno::Reference< beans::XPropertyChangeListener >& /*xListener*/)
2281 {
2282  OSL_FAIL("SwXDocumentIndexMark::removePropertyChangeListener(): not implemented");
2283 }
2284 
2285 void SAL_CALL
2287  const OUString& /*rPropertyName*/,
2288  const uno::Reference< beans::XVetoableChangeListener >& /*xListener*/)
2289 {
2290  OSL_FAIL("SwXDocumentIndexMark::addVetoableChangeListener(): not implemented");
2291 }
2292 
2293 void SAL_CALL
2295  const OUString& /*rPropertyName*/,
2296  const uno::Reference< beans::XVetoableChangeListener >& /*xListener*/)
2297 {
2298  OSL_FAIL("SwXDocumentIndexMark::removeVetoableChangeListener(): not implemented");
2299 }
2300 
2302  : SwUnoCollection(_pDoc)
2303 {
2304 }
2305 
2307 {
2308 }
2309 
2310 OUString SAL_CALL
2312 {
2313  return "SwXDocumentIndexes";
2314 }
2315 
2316 sal_Bool SAL_CALL SwXDocumentIndexes::supportsService(const OUString& rServiceName)
2317 {
2318  return cppu::supportsService(this, rServiceName);
2319 }
2320 
2321 uno::Sequence< OUString > SAL_CALL
2323 {
2324  return { "com.sun.star.text.DocumentIndexes" };
2325 }
2326 
2327 sal_Int32 SAL_CALL
2329 {
2330  SolarMutexGuard aGuard;
2331 
2332  if(!IsValid())
2333  throw uno::RuntimeException();
2334 
2335  sal_uInt32 nRet = 0;
2336  const SwSectionFormats& rFormats = GetDoc()->GetSections();
2337  for( size_t n = 0; n < rFormats.size(); ++n )
2338  {
2339  const SwSection* pSect = rFormats[ n ]->GetSection();
2340  if( SectionType::ToxContent == pSect->GetType() &&
2341  pSect->GetFormat()->GetSectionNode() )
2342  {
2343  ++nRet;
2344  }
2345  }
2346  return nRet;
2347 }
2348 
2349 uno::Any SAL_CALL
2351 {
2352  SolarMutexGuard aGuard;
2353 
2354  if(!IsValid())
2355  throw uno::RuntimeException();
2356 
2357  sal_Int32 nIdx = 0;
2358 
2359  const SwSectionFormats& rFormats = GetDoc()->GetSections();
2360  for( size_t n = 0; n < rFormats.size(); ++n )
2361  {
2362  SwSection* pSect = rFormats[ n ]->GetSection();
2363  if( SectionType::ToxContent == pSect->GetType() &&
2364  pSect->GetFormat()->GetSectionNode() &&
2365  nIdx++ == nIndex )
2366  {
2367  const uno::Reference< text::XDocumentIndex > xTmp =
2369  *GetDoc(), static_cast<SwTOXBaseSection *>(pSect));
2370  uno::Any aRet;
2371  aRet <<= xTmp;
2372  return aRet;
2373  }
2374  }
2375 
2376  throw lang::IndexOutOfBoundsException();
2377 }
2378 
2379 uno::Any SAL_CALL
2380 SwXDocumentIndexes::getByName(const OUString& rName)
2381 {
2382  SolarMutexGuard aGuard;
2383 
2384  if(!IsValid())
2385  throw uno::RuntimeException();
2386 
2387  const SwSectionFormats& rFormats = GetDoc()->GetSections();
2388  for( size_t n = 0; n < rFormats.size(); ++n )
2389  {
2390  SwSection* pSect = rFormats[ n ]->GetSection();
2391  if( SectionType::ToxContent == pSect->GetType() &&
2392  pSect->GetFormat()->GetSectionNode() &&
2393  (static_cast<SwTOXBaseSection const*>(pSect)->GetTOXName()
2394  == rName))
2395  {
2396  const uno::Reference< text::XDocumentIndex > xTmp =
2398  *GetDoc(), static_cast<SwTOXBaseSection *>(pSect));
2399  uno::Any aRet;
2400  aRet <<= xTmp;
2401  return aRet;
2402  }
2403  }
2404  throw container::NoSuchElementException();
2405 }
2406 
2407 uno::Sequence< OUString > SAL_CALL
2409 {
2410  SolarMutexGuard aGuard;
2411 
2412  if(!IsValid())
2413  throw uno::RuntimeException();
2414 
2415  const SwSectionFormats& rFormats = GetDoc()->GetSections();
2416  sal_Int32 nCount = 0;
2417  for( size_t n = 0; n < rFormats.size(); ++n )
2418  {
2419  SwSection const*const pSect = rFormats[ n ]->GetSection();
2420  if( SectionType::ToxContent == pSect->GetType() &&
2421  pSect->GetFormat()->GetSectionNode() )
2422  {
2423  ++nCount;
2424  }
2425  }
2426 
2427  uno::Sequence< OUString > aRet(nCount);
2428  OUString* pArray = aRet.getArray();
2429  sal_Int32 nCnt = 0;
2430  for( size_t n = 0; n < rFormats.size(); ++n )
2431  {
2432  SwSection const*const pSect = rFormats[ n ]->GetSection();
2433  if( SectionType::ToxContent == pSect->GetType() &&
2434  pSect->GetFormat()->GetSectionNode())
2435  {
2436  pArray[nCnt++] = static_cast<SwTOXBaseSection const*>(pSect)->GetTOXName();
2437  }
2438  }
2439  return aRet;
2440 }
2441 
2442 sal_Bool SAL_CALL
2443 SwXDocumentIndexes::hasByName(const OUString& rName)
2444 {
2445  SolarMutexGuard aGuard;
2446 
2447  if(!IsValid())
2448  throw uno::RuntimeException();
2449 
2450  const SwSectionFormats& rFormats = GetDoc()->GetSections();
2451  for( size_t n = 0; n < rFormats.size(); ++n )
2452  {
2453  SwSection const*const pSect = rFormats[ n ]->GetSection();
2454  if( SectionType::ToxContent == pSect->GetType() &&
2455  pSect->GetFormat()->GetSectionNode())
2456  {
2457  if (static_cast<SwTOXBaseSection const*>(pSect)->GetTOXName()
2458  == rName)
2459  {
2460  return true;
2461  }
2462  }
2463  }
2464  return false;
2465 }
2466 
2467 uno::Type SAL_CALL
2469 {
2471 }
2472 
2473 sal_Bool SAL_CALL
2475 {
2476  return 0 != getCount();
2477 }
2478 
2480  SwXDocumentIndex& rParentIdx)
2481  : m_xParent(&rParentIdx)
2482 {
2483 }
2484 
2486 {
2487 }
2488 
2489 OUString SAL_CALL
2491 {
2492  return "SwXDocumentIndex::StyleAccess_Impl";
2493 }
2494 
2495 sal_Bool SAL_CALL
2497 {
2498  return cppu::supportsService(this, rServiceName);
2499 }
2500 
2501 uno::Sequence< OUString > SAL_CALL
2503 {
2504  return { "com.sun.star.text.DocumentIndexParagraphStyles" };
2505 }
2506 
2507 void SAL_CALL
2509  sal_Int32 nIndex, const uno::Any& rElement)
2510 {
2511  SolarMutexGuard aGuard;
2512 
2513  if(nIndex < 0 || nIndex >= MAXLEVEL)
2514  {
2515  throw lang::IndexOutOfBoundsException();
2516  }
2517 
2518  SwTOXBase & rTOXBase( m_xParent->m_pImpl->GetTOXSectionOrThrow() );
2519 
2520  uno::Sequence<OUString> aSeq;
2521  if(!(rElement >>= aSeq))
2522  {
2523  throw lang::IllegalArgumentException();
2524  }
2525 
2526  const sal_Int32 nStyles = aSeq.getLength();
2527  const OUString* pStyles = aSeq.getConstArray();
2528  OUStringBuffer sSetStyles;
2529  OUString aString;
2530  for(sal_Int32 i = 0; i < nStyles; i++)
2531  {
2532  if(i)
2533  {
2534  sSetStyles.append(TOX_STYLE_DELIMITER);
2535  }
2536  SwStyleNameMapper::FillUIName(pStyles[i], aString,
2538  sSetStyles.append(aString);
2539  }
2540  rTOXBase.SetStyleNames(sSetStyles.makeStringAndClear(), o3tl::narrowing<sal_uInt16>(nIndex));
2541 }
2542 
2543 sal_Int32 SAL_CALL
2545 {
2546  return MAXLEVEL;
2547 }
2548 
2549 uno::Any SAL_CALL
2551 {
2552  SolarMutexGuard aGuard;
2553 
2554  if(nIndex < 0 || nIndex >= MAXLEVEL)
2555  {
2556  throw lang::IndexOutOfBoundsException();
2557  }
2558 
2559  SwTOXBase & rTOXBase( m_xParent->m_pImpl->GetTOXSectionOrThrow() );
2560 
2561  const OUString& rStyles =
2562  rTOXBase.GetStyleNames(o3tl::narrowing<sal_uInt16>(nIndex));
2563  const sal_Int32 nStyles = comphelper::string::getTokenCount(rStyles, TOX_STYLE_DELIMITER);
2564  uno::Sequence<OUString> aStyles(nStyles);
2565  OUString* pStyles = aStyles.getArray();
2566  OUString aString;
2567  sal_Int32 nPos = 0;
2568  for(sal_Int32 i = 0; i < nStyles; ++i)
2569  {
2571  rStyles.getToken(0, TOX_STYLE_DELIMITER, nPos),
2572  aString,
2574  pStyles[i] = aString;
2575  }
2576  uno::Any aRet(&aStyles, cppu::UnoType<uno::Sequence<OUString>>::get());
2577  return aRet;
2578 }
2579 
2580 uno::Type SAL_CALL
2582 {
2584 }
2585 
2586 sal_Bool SAL_CALL
2588 {
2589  return true;
2590 }
2591 
2593  SwXDocumentIndex& rParentIdx)
2594  : m_xParent(&rParentIdx)
2595 {
2596 }
2597 
2599 {
2600 }
2601 
2602 OUString SAL_CALL
2604 {
2605  return "SwXDocumentIndex::TokenAccess_Impl";
2606 }
2607 
2609  const OUString& rServiceName)
2610 {
2611  return cppu::supportsService(this, rServiceName);
2612 }
2613 
2614 uno::Sequence< OUString > SAL_CALL
2616 {
2617  return { "com.sun.star.text.DocumentIndexLevelFormat" };
2618 }
2619 
2620 namespace {
2621 
2622 struct TokenType_ {
2623  const char *pName;
2624  enum FormTokenType eTokenType;
2625 };
2626 
2627 }
2628 
2629 const struct TokenType_ g_TokenTypes[] =
2630 {
2631  { "TokenEntryNumber", TOKEN_ENTRY_NO },
2632  { "TokenEntryText", TOKEN_ENTRY_TEXT },
2633  { "TokenTabStop", TOKEN_TAB_STOP },
2634  { "TokenText", TOKEN_TEXT },
2635  { "TokenPageNumber", TOKEN_PAGE_NUMS },
2636  { "TokenChapterInfo", TOKEN_CHAPTER_INFO },
2637  { "TokenHyperlinkStart", TOKEN_LINK_START },
2638  { "TokenHyperlinkEnd", TOKEN_LINK_END },
2639  { "TokenBibliographyDataField", TOKEN_AUTHORITY },
2640  { nullptr, static_cast<enum FormTokenType>(0) }
2641 };
2642 
2643 void SAL_CALL
2645  sal_Int32 nIndex, const uno::Any& rElement)
2646 {
2647  SolarMutexGuard aGuard;
2648 
2649  SwTOXBase & rTOXBase( m_xParent->m_pImpl->GetTOXSectionOrThrow() );
2650 
2651  if ((nIndex < 0) || (nIndex > rTOXBase.GetTOXForm().GetFormMax()))
2652  {
2653  throw lang::IndexOutOfBoundsException();
2654  }
2655 
2656  uno::Sequence<beans::PropertyValues> aSeq;
2657  if(!(rElement >>= aSeq))
2658  {
2659  throw lang::IllegalArgumentException();
2660  }
2661 
2662  OUStringBuffer sPattern;
2663  for(const beans::PropertyValues& rToken : std::as_const(aSeq))
2664  {
2665  const beans::PropertyValue* pProperties = rToken.getConstArray();
2666  const sal_Int32 nProperties = rToken.getLength();
2667  //create an invalid token
2668  SwFormToken aToken(TOKEN_END);
2669  for(sal_Int32 j = 0; j < nProperties; j++)
2670  {
2671  if ( pProperties[j].Name == "TokenType" )
2672  {
2673  const OUString sTokenType =
2674  lcl_AnyToType<OUString>(pProperties[j].Value);
2675  for (TokenType_ const* pTokenType = g_TokenTypes;
2676  pTokenType->pName; ++pTokenType)
2677  {
2678  if (sTokenType.equalsAscii(pTokenType->pName))
2679  {
2680  aToken.eTokenType = pTokenType->eTokenType;
2681  break;
2682  }
2683  }
2684  }
2685  else if ( pProperties[j].Name == "CharacterStyleName" )
2686  {
2687  OUString sCharStyleName;
2689  lcl_AnyToType<OUString>(pProperties[j].Value),
2690  sCharStyleName,
2692  aToken.sCharStyleName = sCharStyleName;
2694  sCharStyleName, SwGetPoolIdFromName::ChrFmt );
2695  }
2696  else if ( pProperties[j].Name == "TabStopRightAligned" )
2697  {
2698  const bool bRight = lcl_AnyToType<bool>(pProperties[j].Value);
2699  aToken.eTabAlign = bRight ?
2700  SvxTabAdjust::End : SvxTabAdjust::Left;
2701  }
2702  else if ( pProperties[j].Name == "TabStopPosition" )
2703  {
2704  sal_Int32 nPosition = 0;
2705  if (!(pProperties[j].Value >>= nPosition))
2706  {
2707  throw lang::IllegalArgumentException();
2708  }
2709  nPosition = o3tl::toTwips(nPosition, o3tl::Length::mm100);
2710  if(nPosition < 0)
2711  {
2712  throw lang::IllegalArgumentException();
2713  }
2714  aToken.nTabStopPosition = nPosition;
2715  }
2716  else if ( pProperties[j].Name == "TabStopFillCharacter" )
2717  {
2718  const OUString sFillChar =
2719  lcl_AnyToType<OUString>(pProperties[j].Value);
2720  if (sFillChar.getLength() > 1)
2721  {
2722  throw lang::IllegalArgumentException();
2723  }
2724  aToken.cTabFillChar =
2725  sFillChar.isEmpty() ? ' ' : sFillChar[0];
2726  }
2727  else if ( pProperties[j].Name == "Text" )
2728  {
2729  aToken.sText = lcl_AnyToType<OUString>(pProperties[j].Value);
2730  }
2731  else if ( pProperties[j].Name == "ChapterFormat" )
2732  {
2733  sal_Int16 nFormat = lcl_AnyToType<sal_Int16>(pProperties[j].Value);
2734  switch(nFormat)
2735  {
2736  case text::ChapterFormat::NUMBER:
2737  nFormat = CF_NUMBER;
2738  break;
2740  nFormat = CF_TITLE;
2741  break;
2742  case text::ChapterFormat::NAME_NUMBER:
2743  nFormat = CF_NUM_TITLE;
2744  break;
2745  case text::ChapterFormat::NO_PREFIX_SUFFIX:
2746  nFormat = CF_NUMBER_NOPREPST;
2747  break;
2748  case text::ChapterFormat::DIGIT:
2749  nFormat = CF_NUM_NOPREPST_TITLE;
2750  break;
2751  default:
2752  throw lang::IllegalArgumentException();
2753  }
2754  aToken.nChapterFormat = nFormat;
2755  }
2756 // #i53420#
2757  else if ( pProperties[j].Name == "ChapterLevel" )
2758  {
2759  const sal_Int16 nLevel = lcl_AnyToType<sal_Int16>(pProperties[j].Value);
2760  if( nLevel < 1 || nLevel > MAXLEVEL )
2761  {
2762  throw lang::IllegalArgumentException();
2763  }
2764  aToken.nOutlineLevel = nLevel;
2765  }
2766  else if ( pProperties[j].Name == "BibliographyDataField" )
2767  {
2768  sal_Int16 nType = 0;
2769  pProperties[j].Value >>= nType;
2770  if(nType < 0 || nType > text::BibliographyDataField::LOCAL_URL)
2771  {
2772  lang::IllegalArgumentException aExcept;
2773  aExcept.Message = "BibliographyDataField - wrong value";
2774  aExcept.ArgumentPosition = static_cast< sal_Int16 >(j);
2775  throw aExcept;
2776  }
2777  aToken.nAuthorityField = nType;
2778  }
2779  // #i21237#
2780  else if ( pProperties[j].Name == "WithTab" )
2781  {
2782  aToken.bWithTab = lcl_AnyToType<bool>(pProperties[j].Value);
2783  }
2784 
2785  }
2786  //exception if wrong TokenType
2787  if(TOKEN_END <= aToken.eTokenType )
2788  {
2789  throw lang::IllegalArgumentException();
2790  }
2791  // set TokenType from TOKEN_ENTRY_TEXT to TOKEN_ENTRY if it is
2792  // not a content index
2793  if(TOKEN_ENTRY_TEXT == aToken.eTokenType &&
2794  (TOX_CONTENT != rTOXBase.GetType()))
2795  {
2796  aToken.eTokenType = TOKEN_ENTRY;
2797  }
2798 // #i53420#
2799 // check for chapter format allowed values if it was TOKEN_ENTRY_NO type
2800 // only allowed value are CF_NUMBER and CF_NUM_NOPREPST_TITLE
2801 // reading from file
2802  if( TOKEN_ENTRY_NO == aToken.eTokenType )
2803  {
2804  switch(aToken.nChapterFormat)
2805  {
2806  case CF_NUMBER:
2807  case CF_NUM_NOPREPST_TITLE:
2808  break;
2809  default:
2810  throw lang::IllegalArgumentException();
2811  }
2812  }
2813 
2814  if (rTOXBase.GetType() == TOX_CONTENT)
2815  {
2816  if (aToken.eTokenType == TOKEN_LINK_START && aToken.sCharStyleName.isEmpty())
2817  {
2818  aToken.sCharStyleName = SwResId(STR_POOLCHR_TOXJUMP);
2819  }
2820  }
2821 
2822  sPattern.append(aToken.GetString());
2823  }
2824  SwForm aForm(rTOXBase.GetTOXForm());
2825  aForm.SetPattern(o3tl::narrowing<sal_uInt16>(nIndex), sPattern.makeStringAndClear());
2826  rTOXBase.SetTOXForm(aForm);
2827 }
2828 
2829 sal_Int32 SAL_CALL
2831 {
2832  SolarMutexGuard aGuard;
2833 
2834  const sal_Int32 nRet = m_xParent->m_pImpl->GetFormMax();
2835  return nRet;
2836 }
2837 
2838 uno::Any SAL_CALL
2840 {
2841  SolarMutexGuard aGuard;
2842 
2843  SwTOXBase & rTOXBase( m_xParent->m_pImpl->GetTOXSectionOrThrow() );
2844 
2845  if ((nIndex < 0) || (nIndex > rTOXBase.GetTOXForm().GetFormMax()))
2846  {
2847  throw lang::IndexOutOfBoundsException();
2848  }
2849 
2850  // #i21237#
2851  SwFormTokens aPattern = rTOXBase.GetTOXForm().
2852  GetPattern(o3tl::narrowing<sal_uInt16>(nIndex));
2853 
2854  sal_Int32 nTokenCount = 0;
2855  uno::Sequence< beans::PropertyValues > aRetSeq;
2856  OUString aProgCharStyle;
2857  for(const SwFormToken& aToken : aPattern) // #i21237#
2858  {
2859  nTokenCount++;
2860  aRetSeq.realloc(nTokenCount);
2861  beans::PropertyValues* pTokenProps = aRetSeq.getArray();
2862 
2863  uno::Sequence< beans::PropertyValue >& rCurTokenSeq =
2864  pTokenProps[nTokenCount-1];
2866  aToken.sCharStyleName,
2867  aProgCharStyle,
2869  switch(aToken.eTokenType)
2870  {
2871  case TOKEN_ENTRY_NO:
2872  {
2873 // #i53420#
2874 // writing to file (from doc to properties)
2875  sal_Int32 nElements = 2;
2876  sal_Int32 nCurrentElement = 0;
2877 
2878  // check for default value
2879  if (aToken.nChapterFormat != CF_NUMBER)
2880  {
2881  nElements++;//we need the element
2882  }
2883  if( aToken.nOutlineLevel != MAXLEVEL )
2884  {
2885  nElements++;
2886  }
2887 
2888  rCurTokenSeq.realloc( nElements );
2889 
2890  beans::PropertyValue* pArr = rCurTokenSeq.getArray();
2891 
2892  pArr[nCurrentElement].Name = "TokenType";
2893  pArr[nCurrentElement++].Value <<=
2894  OUString("TokenEntryNumber");
2895 
2896  pArr[nCurrentElement].Name = "CharacterStyleName";
2897  pArr[nCurrentElement++].Value <<= aProgCharStyle;
2898  if( aToken.nChapterFormat != CF_NUMBER )
2899  {
2900  pArr[nCurrentElement].Name = "ChapterFormat";
2901  sal_Int16 nVal;
2902 // the allowed values for chapter format, when used as entry number,
2903 // are CF_NUMBER and CF_NUM_NOPREPST_TITLE only, all else forced to
2904 //CF_NUMBER
2905  switch(aToken.nChapterFormat)
2906  {
2907  default:
2908  case CF_NUMBER:
2909  nVal = text::ChapterFormat::NUMBER;
2910  break;
2911  case CF_NUM_NOPREPST_TITLE:
2912  nVal = text::ChapterFormat::DIGIT;
2913  break;
2914  }
2915  pArr[nCurrentElement++].Value <<= nVal;
2916  }
2917 
2918  // only a ChapterLevel != MAXLEVEL is registered
2919  if (aToken.nOutlineLevel != MAXLEVEL)
2920  {
2921  pArr[nCurrentElement].Name = "ChapterLevel";
2922  pArr[nCurrentElement].Value <<= aToken.nOutlineLevel;
2923  }
2924  }
2925  break;
2926  case TOKEN_ENTRY: // no difference between Entry and Entry Text
2927  case TOKEN_ENTRY_TEXT:
2928  {
2929  rCurTokenSeq.realloc( 2 );
2930  beans::PropertyValue* pArr = rCurTokenSeq.getArray();
2931 
2932  pArr[0].Name = "TokenType";
2933  pArr[0].Value <<= OUString("TokenEntryText");
2934 
2935  pArr[1].Name = "CharacterStyleName";
2936  pArr[1].Value <<= aProgCharStyle;
2937  }
2938  break;
2939  case TOKEN_TAB_STOP:
2940  {
2941  rCurTokenSeq.realloc(5); // #i21237#
2942  beans::PropertyValue* pArr = rCurTokenSeq.getArray();
2943 
2944  pArr[0].Name = "TokenType";
2945  pArr[0].Value <<= OUString("TokenTabStop");
2946 
2947  if(SvxTabAdjust::End == aToken.eTabAlign)
2948  {
2949  pArr[1].Name = "TabStopRightAligned";
2950  pArr[1].Value <<= true;
2951  }
2952  else
2953  {
2954  pArr[1].Name = "TabStopPosition";
2955  sal_Int32 nPos = convertTwipToMm100(aToken.nTabStopPosition);
2956  if(nPos < 0)
2957  nPos = 0;
2958  pArr[1].Value <<= nPos;
2959  }
2960  pArr[2].Name = "TabStopFillCharacter";
2961  pArr[2].Value <<= OUString(aToken.cTabFillChar);
2962  pArr[3].Name = "CharacterStyleName";
2963  pArr[3].Value <<= aProgCharStyle;
2964  // #i21237#
2965  pArr[4].Name = "WithTab";
2966  pArr[4].Value <<= aToken.bWithTab;
2967  }
2968  break;
2969  case TOKEN_TEXT:
2970  {
2971  rCurTokenSeq.realloc( 3 );
2972  beans::PropertyValue* pArr = rCurTokenSeq.getArray();
2973 
2974  pArr[0].Name = "TokenType";
2975  pArr[0].Value <<= OUString("TokenText");
2976 
2977  pArr[1].Name = "CharacterStyleName";
2978  pArr[1].Value <<= aProgCharStyle;
2979 
2980  pArr[2].Name = "Text";
2981  pArr[2].Value <<= aToken.sText;
2982  }
2983  break;
2984  case TOKEN_PAGE_NUMS:
2985  {
2986  rCurTokenSeq.realloc( 2 );
2987  beans::PropertyValue* pArr = rCurTokenSeq.getArray();
2988 
2989  pArr[0].Name = "TokenType";
2990  pArr[0].Value <<= OUString("TokenPageNumber");
2991 
2992  pArr[1].Name = "CharacterStyleName";
2993  pArr[1].Value <<= aProgCharStyle;
2994  }
2995  break;
2996  case TOKEN_CHAPTER_INFO:
2997  {
2998  rCurTokenSeq.realloc( 4 );
2999  beans::PropertyValue* pArr = rCurTokenSeq.getArray();
3000 
3001  pArr[0].Name = "TokenType";
3002  pArr[0].Value <<= OUString("TokenChapterInfo");
3003 
3004  pArr[1].Name = "CharacterStyleName";
3005  pArr[1].Value <<= aProgCharStyle;
3006 
3007  pArr[2].Name = "ChapterFormat";
3008  sal_Int16 nVal = text::ChapterFormat::NUMBER;
3009  switch(aToken.nChapterFormat)
3010  {
3011  case CF_NUMBER:
3012  nVal = text::ChapterFormat::NUMBER;
3013  break;
3014  case CF_TITLE:
3016  break;
3017  case CF_NUM_TITLE:
3018  nVal = text::ChapterFormat::NAME_NUMBER;
3019  break;
3020  case CF_NUMBER_NOPREPST:
3021  nVal = text::ChapterFormat::NO_PREFIX_SUFFIX;
3022  break;
3023  case CF_NUM_NOPREPST_TITLE:
3024  nVal = text::ChapterFormat::DIGIT;
3025  break;
3026  }
3027  pArr[2].Value <<= nVal;
3028 // #i53420#
3029  pArr[3].Name = "ChapterLevel";
3030  pArr[3].Value <<= aToken.nOutlineLevel;
3031  }
3032  break;
3033  case TOKEN_LINK_START:
3034  {
3035  rCurTokenSeq.realloc( 2 );
3036  beans::PropertyValue* pArr = rCurTokenSeq.getArray();
3037 
3038  pArr[0].Name = "TokenType";
3039  pArr[0].Value <<=
3040  OUString("TokenHyperlinkStart");
3041  pArr[1].Name = "CharacterStyleName";
3042  pArr[1].Value <<= aProgCharStyle;
3043  }
3044  break;
3045  case TOKEN_LINK_END:
3046  {
3047  rCurTokenSeq.realloc( 1 );
3048  beans::PropertyValue* pArr = rCurTokenSeq.getArray();
3049 
3050  pArr[0].Name = "TokenType";
3051  pArr[0].Value <<=
3052  OUString("TokenHyperlinkEnd");
3053  }
3054  break;
3055  case TOKEN_AUTHORITY:
3056  {
3057  rCurTokenSeq.realloc( 3 );
3058  beans::PropertyValue* pArr = rCurTokenSeq.getArray();
3059 
3060  pArr[0].Name = "TokenType";
3061  pArr[0].Value <<=
3062  OUString("TokenBibliographyDataField");
3063 
3064  pArr[1].Name = "CharacterStyleName";
3065  pArr[1].Value <<= aProgCharStyle;
3066 
3067  pArr[2].Name = "BibliographyDataField";
3068  pArr[2].Value <<= sal_Int16(aToken.nAuthorityField);
3069  }
3070  break;
3071 
3072  default:
3073  ;
3074  }
3075  }
3076 
3077  uno::Any aRet;
3078  aRet <<= aRetSeq;
3079  return aRet;
3080 }
3081 
3082 uno::Type SAL_CALL
3084 {
3086 }
3087 
3088 sal_Bool SAL_CALL
3090 {
3091  return true;
3092 }
3093 
3094 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
void disposeAndClear(::std::unique_lock<::std::mutex > &rGuard, const css::lang::EventObject &rEvt)
css::uno::Reference< css::linguistic2::XProofreadingIterator > get(css::uno::Reference< css::uno::XComponentContext > const &context)
SwDoc * GetDoc() const
Definition: unocoll.hxx:59
virtual void SAL_CALL attach(const css::uno::Reference< css::text::XTextRange > &xTextRange) override
Definition: unoidx.cxx:1284
virtual void SAL_CALL removePropertyChangeListener(const OUString &rPropertyName, const css::uno::Reference< css::beans::XPropertyChangeListener > &xListener) override
Definition: unoidx.cxx:2278
const SwEndNode * EndOfSectionNode() const
Definition: node.hxx:692
std::vector< SwFormToken > SwFormTokens
Vector of tokens.
Definition: tox.hxx:284
SwNodeOffset min(const SwNodeOffset &a, const SwNodeOffset &b)
Definition: nodeoffset.hxx:35
static void lcl_CalcLayout(SwDoc *pDoc)
Definition: unoidx.cxx:1213
virtual uno::Any SAL_CALL getByIndex(sal_Int32 nIndex) override
Definition: unoidx.cxx:2550
TOXTypes
Definition: toxe.hxx:39
void DeleteMark()
Definition: pam.hxx:178
static sal_uInt16 lcl_TypeToPropertyMap_Mark(const TOXTypes eType)
Definition: unoidx.cxx:1465
#define WID_USE_LEVEL_FROM_SOURCE
Definition: unomap.hxx:182
#define WID_TOC_PARAGRAPH_OUTLINE_LEVEL
Definition: unomap.hxx:227
std::vector< SwSection * > SwSections
Definition: section.hxx:40
SAL_DLLPRIVATE css::uno::WeakReference< css::text::XDocumentIndexMark > const & GetXTOXMark() const
Definition: tox.hxx:161
#define WID_IS_COMMA_SEPARATED
Definition: unomap.hxx:212
SwTOIOptions
Definition: tox.hxx:384
bool GoInContent(SwPaM &rPam, SwMoveFnCollection const &fnMove)
Definition: pam.cxx:968
::rtl::Reference< SwXDocumentIndex > m_xParent
can be destroyed threadsafely, so no UnoImplPtr here
Definition: unoidx.cxx:175
void SetSectionFormat(SwSectionFormat &rFormat)
Definition: unoidx.cxx:323
virtual uno::Type SAL_CALL getElementType() override
Definition: unoidx.cxx:3083
TokenAccess_Impl(SwXDocumentIndex &rParentIdx)
Definition: unoidx.cxx:2592
SwTOXElement GetCreateType() const
Definition: tox.hxx:699
virtual sal_Bool SAL_CALL hasElements() override
Definition: unoidx.cxx:3089
virtual void SAL_CALL setMarkEntry(const OUString &rIndexEntry) override
Definition: unoidx.cxx:1719
SwSectionFormat * m_pFormat
Definition: unoidx.cxx:295
#define WID_PARA_SEP
Definition: unomap.hxx:201
virtual css::uno::Any SAL_CALL getByName(const OUString &rName) override
Definition: unoidx.cxx:2380
constexpr auto toTwips(N number, Length from)
#define WID_CREATE_FROM_STAR_DRAW
Definition: unomap.hxx:197
virtual void SAL_CALL removeVetoableChangeListener(const OUString &rPropertyName, const css::uno::Reference< css::beans::XVetoableChangeListener > &xListener) override
Definition: unoidx.cxx:1206
static ShellResource * GetShellRes()
Definition: viewsh.cxx:2662
virtual void Notify(const SfxHint &) override
Definition: unoidx.cxx:361
::comphelper::OMultiTypeInterfaceContainerHelper2 m_Listeners
Definition: unoidx.cxx:299
sal_Int32 nProperties
virtual void CalcLayout()
Definition: viewsh.cxx:1082
#define WID_USE_COMBINED_ENTRIES
Definition: unomap.hxx:175
static void lcl_AnyToBitMask(uno::Any const &rValue, T &rBitMask, const T nBit)
Definition: unoidx.cxx:84
sal_uInt16 nOutlineLevel
Definition: tox.hxx:250
virtual sal_Int32 SAL_CALL getCount() override
Definition: unoidx.cxx:2328
constexpr TypedWhichId< SwPtrMsgPoolItem > RES_REMOVE_UNO_OBJECT(181)
static void FillUIName(const OUString &rName, OUString &rFillName, SwGetPoolIdFromName)
void SetLevel(sal_uInt16 nLevel)
Definition: tox.hxx:590
void InsertTOXMark(const SwTOXType &rTOXType, SwTOXMark &rMark, SwPaM &rPam, SwXTextCursor const *const pTextCursor)
Definition: unoidx.cxx:1888
virtual void SAL_CALL removeRefreshListener(const css::uno::Reference< css::util::XRefreshListener > &xListener) override
Definition: unoidx.cxx:1275
static SwTOXBase * GetCurTOX(const SwPosition &rPos)
Get current table of contents.
Definition: doctxm.cxx:448
SwTOOElements
Definition: tox.hxx:407
Definition: tox.hxx:311
SwNodeIndex nNode
Definition: pam.hxx:38
const SwTOXType * InsertTOXType(const SwTOXType &rTyp)
Definition: doctxm.cxx:629
OUString sCharStyleName
#define WID_CREATE_FROM_STAR_CALC
Definition: unomap.hxx:196
SAL_DLLPRIVATE css::uno::WeakReference< css::uno::XInterface > const & GetXObject() const
Definition: frmfmt.hxx:170
::rtl::Reference< SwXDocumentIndex > m_xParent
can be destroyed threadsafely, so no UnoImplPtr here
Definition: unoidx.cxx:214
uno::WeakReference< uno::XInterface > m_wThis
Definition: unoidx.cxx:298
void ReplaceTOXMark(const SwTOXType &rTOXType, SwTOXMark &rMark, SwPaM &rPam)
Definition: unoidx.cxx:1546
static LanguageType convertToLanguageType(const css::lang::Locale &rLocale, bool bResolveSystem=true)
virtual css::uno::Reference< css::frame::XModel > GetModel() override
Definition: unoidx.cxx:1453
#define WID_LEVEL_PARAGRAPH_STYLES
Definition: unomap.hxx:184
#define PROPERTY_MAP_INDEX_CNTNT
Definition: unomap.hxx:42
SAL_DLLPRIVATE void SetXTOXMark(css::uno::Reference< css::text::XDocumentIndexMark > const &xMark)
Definition: tox.hxx:163
std::vector< SwTOXMark * > SwTOXMarks
Definition: tox.hxx:44
#define WID_IS_RELATIVE_TABSTOPS
Definition: unomap.hxx:214
virtual void SAL_CALL addVetoableChangeListener(const OUString &rPropertyName, const css::uno::Reference< css::beans::XVetoableChangeListener > &xListener) override
Definition: unoidx.cxx:1198
OUString const & GetTemplate(sal_uInt16 nLevel) const
Definition: tox.hxx:670
const SwPosition * GetMark() const
Definition: pam.hxx:210
void CollectTextMarks(SwTOXMarks &rMarks) const
Definition: tox.hxx:182
#define PROPERTY_MAP_INDEX_IDX
Definition: unomap.hxx:43
#define TOX_STYLE_DELIMITER
Definition: tox.hxx:420
sal_Int64 n
css::uno::Reference< css::frame::XModel3 > GetModel() const
#define WID_PARA_LEV1
Definition: unomap.hxx:202
Definition: doc.hxx:187
only chapter number without post-/prefix
Definition: chpfld.hxx:35
#define WID_USER_IDX_NAME
Definition: unomap.hxx:199
virtual void SAL_CALL update() override
Definition: unoidx.cxx:512
constexpr sal_uInt8 MAXLEVEL
Definition: swtypes.hxx:92
#define WID_MAIN_ENTRY
Definition: unomap.hxx:170
SwSectionFormat * GetSectionFormat() const
Definition: unoidx.cxx:330
bool IsAtEndOfMeta() const
Definition: unoobj.cxx:791
#define WID_CREATE_FROM_TABLES
Definition: unomap.hxx:188
#define WID_USE_P_P
Definition: unomap.hxx:177
::osl::Mutex m_Mutex
Definition: unoidx.cxx:294
SwNode & GetNode() const
Definition: ndindex.hxx:119
#define WID_PARA_LEV5
Definition: unomap.hxx:206
virtual void SAL_CALL removeVetoableChangeListener(const OUString &rPropertyName, const css::uno::Reference< css::beans::XVetoableChangeListener > &xListener) override
Definition: unoidx.cxx:2294
#define WID_PRIMARY_KEY
Definition: unomap.hxx:163
SwSectionFormat * GetFormat()
Definition: section.hxx:336
sal_uInt16 GetFormMax() const
Definition: tox.hxx:681
const TOXTypes m_eTOXType
Definition: unoidx.cxx:301
OUString Name
const SwTOXType * GetTOXType() const
Definition: tox.hxx:574
virtual css::uno::Any SAL_CALL getByIndex(sal_Int32 nIndex) override
Definition: unoidx.cxx:2350
static const SwAttrSet & GetTOXBaseAttrSet(const SwTOXBase &rTOX)
Definition: doctxm.cxx:468
#define USER_AND_SUFFIXLEN
Definition: unoidx.cxx:126
virtual uno::Any SAL_CALL getByIndex(sal_Int32 nIndex) override
Definition: unoidx.cxx:2839
virtual uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
Definition: unoidx.cxx:2502
static void lcl_ConvertTOUNameToUserName(OUString &rTmp)
Definition: unoidx.cxx:145
sal_uInt16 nPoolId
Definition: tox.hxx:247
const SwTOXType * m_pTOXType
Definition: unoidx.cxx:1492
virtual void SAL_CALL refresh() override
Definition: unoidx.cxx:1234
SwXDocumentIndexes(SwDoc *const pDoc)
Definition: unoidx.cxx:2301
constexpr OUStringLiteral cUserDefined
Definition: unoidx.cxx:123
bool bWithTab
Definition: tox.hxx:253
virtual OUString SAL_CALL getImplementationName() override
Definition: unoidx.cxx:441
SfxHintId GetId() const
chapter number without post-/prefix and title
Definition: chpfld.hxx:36
sal_Unicode cTabFillChar
Definition: tox.hxx:252
virtual OUString SAL_CALL getMarkEntry() override
Definition: unoidx.cxx:1700
static css::uno::Reference< css::text::XTextSection > CreateXTextSection(SwSectionFormat *const pFormat, const bool bIndexHeader=false)
Definition: unosect.cxx:194
virtual css::uno::Reference< css::text::XTextRange > SAL_CALL getAnchor() override
Definition: unoidx.cxx:1342
Array of Undo-history.
Definition: docary.hxx:191
virtual css::uno::Sequence< OUString > SAL_CALL getElementNames() override
Definition: unoidx.cxx:2408
constexpr auto convertTwipToMm100(N n)
virtual sal_Bool SAL_CALL supportsService(const OUString &rServiceName) override
Definition: unoidx.cxx:1665
OUString SwResId(TranslateId aId)
Definition: swmodule.cxx:164
Value
SwXDocumentIndexMark & m_rThis
Definition: unoidx.cxx:1481
const SwDoc & GetDoc() const
Definition: unoobj2.cxx:767
const SwTOXType * GetTOXType() const
Definition: tox.hxx:696
virtual void SAL_CALL attach(const css::uno::Reference< css::text::XTextRange > &xTextRange) override
Definition: unoidx.cxx:1752
#define WID_LEVEL_FORMAT
Definition: unomap.hxx:183
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
Definition: unoidx.cxx:453
void RegisterToTOXType(SwTOXType &rMark)
Definition: tox.cxx:552
static void lcl_ReAssignTOXType(SwDoc &rDoc, SwTOXBase &rTOXBase, const OUString &rNewName)
Definition: unoidx.cxx:101
virtual void SAL_CALL setName(const OUString &rName) override
Definition: unoidx.cxx:1417
SwSectionNode * GetSectionNode()
Definition: section.cxx:922
A wrapper around SfxPoolItem to store the start position of (usually) a text portion, with an optional end.
Definition: txatbase.hxx:43
bool IsValid() const
Definition: unocoll.hxx:57
OUString sText
Definition: tox.hxx:243
int nCount
virtual ::sfx2::Metadatable * GetCoreObject() override
Definition: unoidx.cxx:1447
virtual sal_Int32 SAL_CALL getCount() override
Definition: unoidx.cxx:2830
bool CPPUHELPER_DLLPUBLIC supportsService(css::lang::XServiceInfo *implementation, rtl::OUString const &name)
sal_Int32 GetStart() const
Definition: txatbase.hxx:88
static SW_DLLPUBLIC sal_uInt16 GetPoolIdFromUIName(const OUString &rName, SwGetPoolIdFromName)
virtual void Notify(const SfxHint &) override
Definition: unoidx.cxx:1586
#define WID_USE_DASH
Definition: unomap.hxx:178
virtual OUString SAL_CALL getImplementationName() override
Definition: unoidx.cxx:2490
#define WID_IDX_SORT_ALGORITHM
Definition: unomap.hxx:219
bool DeleteTOX(const SwTOXBase &rTOXBase, bool bDelNodes)
Delete table of contents.
Definition: doctxm.cxx:524
sal_uInt16 GetTOXTypeCount(TOXTypes eTyp) const
Manage table of content types.
Definition: doctxm.cxx:611
#define WID_PARA_LEV7
Definition: unomap.hxx:208
virtual void SAL_CALL removeEventListener(const css::uno::Reference< css::lang::XEventListener > &xListener) override
Definition: unoidx.cxx:1390
SAL_DLLPRIVATE void SetXObject(css::uno::Reference< css::uno::XInterface > const &xObject)
Definition: frmfmt.hxx:172
sal_Int32 nElements
void SetAlternativeText(const OUString &rAlt)
Definition: tox.hxx:580
void Normalize(bool bPointFirst=true)
Normalizes PaM, i.e.
Definition: pam.cxx:539
sal_Int32 getTokenCount(std::string_view rIn, char cTok)
void SetPattern(sal_uInt16 nLevel, SwFormTokens &&rName)
Definition: tox.cxx:929
const css::uno::Sequence< sal_Int8 > & getSeq() const
static SW_DLLPUBLIC const OUString & GetSpecialExtraProgName(const OUString &rExtraUIName)
#define WID_IDX_LOCALE
Definition: unomap.hxx:218
#define WID_TAB_IN_TOC
Definition: unomap.hxx:186
void UpdatePageNum()
Calculate PageNumber and insert after formatting.
Definition: doctxm.cxx:1664
void EndListeningAll()
const OUString & GetAlternativeText() const
Definition: tox.hxx:568
#define WID_PARA_LEV6
Definition: unomap.hxx:207
PaM is Point and Mark: a selection of the document model.
Definition: pam.hxx:137
static OUString GetProviderName(SwServiceType nObjectType)
Definition: unocoll.cxx:476
OUString GetString() const
Definition: tox.cxx:655
bool Move(SwMoveFnCollection const &fnMove=fnMoveForward, SwGoInDoc fnGo=GoInContent)
Movement of cursor.
Definition: pam.cxx:502
virtual OUString SAL_CALL getImplementationName() override
Definition: unoidx.cxx:2603
#define WID_TOC_NEWLINE
Definition: unomap.hxx:226
#define WID_CREATE_FROM_STAR_MATH
Definition: unomap.hxx:192
bool GetDefaultTextContentValue(css::uno::Any &rAny, std::u16string_view rPropertyName, sal_uInt16 nWID=0)
sal_uInt16 char * pName
virtual void SAL_CALL dispose() override
Definition: unoidx.cxx:1975
virtual sal_Bool SAL_CALL supportsService(const OUString &rServiceName) override
Definition: unoidx.cxx:2496
virtual css::uno::Any SAL_CALL getPropertyValue(const OUString &rPropertyName) override
Definition: unoidx.cxx:854
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
Definition: unoidx.cxx:1671
#define WID_IDX_NAME
Definition: unomap.hxx:220
virtual sal_Int64 SAL_CALL getSomething(const css::uno::Sequence< sal_Int8 > &rIdentifier) override
Definition: unoidx.cxx:1654
number and title
Definition: chpfld.hxx:34
#define PROPERTY_MAP_INDEX_MARK
Definition: unomap.hxx:46
int i
void SetPrimaryKey(const OUString &rStr)
Definition: tox.hxx:596
virtual OUString SAL_CALL getServiceName() override
Definition: unoidx.cxx:487
SwTOXElement
Definition: tox.hxx:363
#define PROPERTY_MAP_INDEX_USER
Definition: unomap.hxx:41
const SwPosition * GetPoint() const
Definition: pam.hxx:208
void SetTextReading(const OUString &rStr)
Definition: tox.hxx:608
FormTokenType eTokenType
Definition: tox.hxx:246
virtual sal_Bool SAL_CALL supportsService(const OUString &rServiceName) override
Definition: unoidx.cxx:2316
SwEditShell const * GetEditShell() const
Definition: doccorr.cxx:328
OUString sCharStyleName
Definition: tox.hxx:244
#define WID_IDX_CONTENT_SECTION
Definition: unomap.hxx:216
virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo() override
Definition: unoidx.cxx:518
#define WID_CREATE_FROM_LABELS
Definition: unomap.hxx:172
#define WID_USE_UPPER_CASE
Definition: unomap.hxx:179
uno::WeakReference< container::XIndexReplace > m_wStyleAccess
Definition: unoidx.cxx:305
#define WID_CREATE_FROM_MARKS
Definition: unomap.hxx:168
::cppu::WeakImplHelper< lang::XServiceInfo, container::XIndexReplace > SwXDocumentIndexStyleAccess_Base
Definition: unoidx.cxx:167
virtual uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
Definition: unoidx.cxx:2615
SetAttrMode
Definition: swtypes.hxx:132
void Exchange()
Definition: pam.cxx:490
uno::WeakReference< container::XIndexReplace > m_wTokenAccess
Definition: unoidx.cxx:306
void disposeAndClear(const css::lang::EventObject &rEvt)
#define PROPERTY_MAP_INDEX_OBJECTS
Definition: unomap.hxx:53
void SetPrimaryKeyReading(const OUString &rStr)
Definition: tox.hxx:614
Force hint expand (only matters for hints with CH_TXTATR).
virtual void SAL_CALL addPropertyChangeListener(const OUString &rPropertyName, const css::uno::Reference< css::beans::XPropertyChangeListener > &xListener) override
Definition: unoidx.cxx:1182
float u
virtual uno::Type SAL_CALL getElementType() override
Definition: unoidx.cxx:2581
size_t size() const
Definition: docary.hxx:87
unsigned char sal_Bool
static css::uno::Reference< css::text::XDocumentIndexMark > CreateXDocumentIndexMark(SwDoc &rDoc, SwTOXMark *pMark, TOXTypes eType=TOX_INDEX)
Definition: unoidx.cxx:1615
virtual OUString SAL_CALL getImplementationName() override
Definition: unoidx.cxx:2311
virtual sal_Bool SAL_CALL supportsService(const OUString &rServiceName) override
Definition: unoidx.cxx:2608
virtual void SAL_CALL addRefreshListener(const css::uno::Reference< css::util::XRefreshListener > &xListener) override
Definition: unoidx.cxx:1267
const OUString & GetTypeName() const
Definition: tox.hxx:688
static const css::uno::Sequence< sal_Int8 > & getUnoTunnelId()
Definition: unoidx.cxx:1647
virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo() override
Definition: unoidx.cxx:2005
#define WID_USE_KEY_AS_ENTRY
Definition: unomap.hxx:174
static css::uno::Reference< css::text::XDocumentIndex > CreateXDocumentIndex(SwDoc &rDoc, SwTOXBaseSection *pSection, TOXTypes eTypes=TOX_INDEX)
Definition: unoidx.cxx:401
sal_Int32 GetFormMax() const
Definition: unoidx.cxx:350
sal_uInt16 nChapterFormat
Definition: tox.hxx:249
Marks a node in the document model.
Definition: ndindex.hxx:30
css::uno::Type const & get()
#define WID_INDEX_MARKS
Definition: unomap.hxx:213
sal_uInt16 nAuthorityField
Definition: tox.hxx:251
virtual void SAL_CALL setPropertyValue(const OUString &rPropertyName, const css::uno::Any &rValue) override
Definition: unoidx.cxx:2034
#define WID_SECONDARY_KEY
Definition: unomap.hxx:164
#define PROPERTY_MAP_USER_MARK
Definition: unomap.hxx:44
const SwDoc * GetDoc() const
The document is set in SwAttrPool now, therefore you always can access it.
Definition: format.hxx:139
bool StartListening(SvtBroadcaster &rBroadcaster)
#define WID_CREATE_FROM_STAR_CHART
Definition: unomap.hxx:195
static sal_uInt16 GetFormMaxLevel(TOXTypes eType)
Definition: tox.cxx:443
#define WID_PARA_LEV3
Definition: unomap.hxx:204
virtual void SAL_CALL setPropertyValue(const OUString &rPropertyName, const css::uno::Any &rValue) override
Definition: unoidx.cxx:528
#define WID_CREATE_FROM_CHAPTER
Definition: unomap.hxx:171
virtual sal_Int64 SAL_CALL getSomething(const css::uno::Sequence< sal_Int8 > &rIdentifier) override
Definition: unoidx.cxx:435
IDocumentLayoutAccess const & getIDocumentLayoutAccess() const
Definition: doc.cxx:405
virtual SotClipboardFormatId GetFormat(const TransferableDataHelper &aHelper) override
const SwPosition * Start() const
Definition: pam.hxx:213
#define WID_CREATE_FROM_OTHER_EMBEDDED_OBJECTS
Definition: unomap.hxx:198
bool XTextRangeToSwPaM(SwUnoInternalPaM &rToFill, const uno::Reference< text::XTextRange > &xTextRange,::sw::TextRangeMode const eMode)
Definition: unoobj2.cxx:1107
OUString aTOXUserName
Definition: shellres.hxx:54
#define WID_CREATE_FROM_OUTLINE
Definition: unomap.hxx:169
virtual void SAL_CALL removePropertyChangeListener(const OUString &rPropertyName, const css::uno::Reference< css::beans::XPropertyChangeListener > &xListener) override
Definition: unoidx.cxx:1190
#define WID_SECONDARY_KEY_READING
Definition: unomap.hxx:224
#define WID_PRIMARY_KEY_READING
Definition: unomap.hxx:223
::sw::UnoImplPtr< Impl > m_pImpl
Definition: unoidx.hxx:158
#define PROPERTY_MAP_CNTIDX_MARK
Definition: unomap.hxx:45
only the chapter number
Definition: chpfld.hxx:32
const LanguageTag & getLocale()
SvtBroadcaster & GetNotifier()
Definition: calbck.hxx:101
const char cUserSuffix[]
Definition: unoidx.cxx:124
uno::WeakReference< uno::XInterface > m_wThis
Definition: unoidx.cxx:1486
const SwTextNode & GetTextNode() const
Definition: txttxmrk.hxx:49
virtual css::uno::Reference< css::text::XTextRange > SAL_CALL getAnchor() override
Definition: unoidx.cxx:1941
#define WID_HIDE_TABLEADER_PAGENUMBERS
Definition: unomap.hxx:185
#define MID_GRAPHIC_URL
Impl(SwDoc &rDoc, const TOXTypes eType, SwTOXBaseSection *const pBaseSection)
Definition: unoidx.cxx:308
void DeleteTOXMark(const SwTOXMark *pTOXMark)
Delete table of contents Mark.
Definition: doctxm.cxx:155
std::unique_ptr< SwDocIndexDescriptorProperties_Impl > m_pProps
Definition: unoidx.cxx:304
bool IsRelTabPos() const
Definition: tox.hxx:342
virtual void SAL_CALL removeEventListener(const css::uno::Reference< css::lang::XEventListener > &xListener) override
Definition: unoidx.cxx:1996
const SwTOXMark * m_pTOXMark
Definition: unoidx.cxx:1493
virtual OUString SAL_CALL getName() override
Definition: unoidx.cxx:1398
#define PROPERTY_MAP_BIBLIOGRAPHY
Definition: unomap.hxx:55
constexpr TypedWhichId< SvxBrushItem > RES_BACKGROUND(105)
#define WID_CREATE_FROM_PARAGRAPH_STYLES
Definition: unomap.hxx:215
#define WID_TOC_BOOKMARK
Definition: unomap.hxx:225
SwTwips nTabStopPosition
Definition: tox.hxx:245
void Update(const SfxItemSet *pAttr=nullptr, SwRootFrame const *pLayout=nullptr, const bool _bNewTOX=false)
Collect table of contents content.
Definition: doctxm.cxx:850
#define WID_LEVEL
Definition: unomap.hxx:167
virtual css::uno::Type SAL_CALL getElementType() override
Definition: unoidx.cxx:2468
virtual void SAL_CALL replaceByIndex(sal_Int32 Index, const uno::Any &rElement) override
Definition: unoidx.cxx:2644
virtual const SwViewShell * GetCurrentViewShell() const =0
Returns the layout set at the document.
virtual sal_Bool SAL_CALL hasElements() override
Definition: unoidx.cxx:2587
SwMoveFnCollection const & fnMoveForward
SwPam::Move()/Find() default argument.
Definition: paminit.cxx:59
virtual void SAL_CALL addVetoableChangeListener(const OUString &rPropertyName, const css::uno::Reference< css::beans::XVetoableChangeListener > &xListener) override
Definition: unoidx.cxx:2286
static void lcl_ConvertTOUNameToProgrammaticName(OUString &rTmp)
Definition: unoidx.cxx:128
OUString const & GetStyleNames(sal_uInt16 nLevel) const
Definition: tox.hxx:517
#define WID_CREATE_FROM_TEXT_FRAMES
Definition: unomap.hxx:189
bool IsCommaSeparated() const
Definition: tox.hxx:345
static void FillProgName(const OUString &rName, OUString &rFillName, SwGetPoolIdFromName)
virtual ~TokenAccess_Impl() override
Definition: unoidx.cxx:2598
virtual css::uno::Any SAL_CALL getPropertyValue(const OUString &rPropertyName) override
Definition: unoidx.cxx:2163
static sal_uInt16 lcl_TypeToPropertyMap_Index(const TOXTypes eType)
Definition: unoidx.cxx:275
#define WID_TEXT_READING
Definition: unomap.hxx:222
#define WID_PARA_LEV9
Definition: unomap.hxx:210
void SetBookmarkName(const OUString &bName)
Definition: tox.hxx:585
const sal_Int32 * End() const
Definition: txatbase.hxx:156
Impl(SwXDocumentIndexMark &rThis, SwDoc *const pDoc, const enum TOXTypes eType, const SwTOXType *pType, SwTOXMark const *pMark)
Definition: unoidx.cxx:1507
#define WID_PARA_LEV10
Definition: unomap.hxx:211
SwUnoPropertyMapProvider aSwMapProvider
Definition: unomap1.cxx:87
QPRO_FUNC_TYPE nType
virtual void SAL_CALL dispose() override
Definition: unoidx.cxx:1367
#define PROPERTY_MAP_FLDTYP_BIBLIOGRAPHY
Definition: unomap.hxx:110
Sequence< sal_Int8 > aSeq
void SetSecondaryKey(const OUString &rStr)
Definition: tox.hxx:602
#define WID_PARA_HEAD
Definition: unomap.hxx:200
TOXTypes GetType() const
Definition: tox.hxx:691
virtual void CalcLayout() override
To enable set up of StartActions and EndActions.
Definition: edws.cxx:108
SwMoveFnCollection const & fnMoveBackward
Definition: paminit.cxx:58
const TOXTypes m_eTOXType
Definition: unoidx.cxx:1488
#define WID_PARA_LEV2
Definition: unomap.hxx:203
#define WID_CREATE_FROM_EMBEDDED_OBJECTS
Definition: unomap.hxx:191
#define WID_IDX_TITLE
Definition: unomap.hxx:166
#define PROPERTY_MAP_PARAGRAPH_EXTENSIONS
Definition: unomap.hxx:51
virtual ~StyleAccess_Impl() override
Definition: unoidx.cxx:2485
static const css::uno::Sequence< sal_Int8 > & getUnoTunnelId()
Definition: unoidx.cxx:428
SvxTabAdjust eTabAlign
Definition: tox.hxx:248
#define WID_PARA_LEV8
Definition: unomap.hxx:209
#define WID_PROTECTED
Definition: unomap.hxx:193
Reference< XModel > xModel
static void lcl_BitMaskToAny(uno::Any &o_rValue, const T nBitMask, const T nBit)
Definition: unoidx.cxx:93
#define WID_CREATE_FROM_GRAPHIC_OBJECTS
Definition: unomap.hxx:190
SwDoc & GetDoc() const
Definition: pam.hxx:244
SwXDocumentIndex(SwTOXBaseSection &, SwDoc &)
Definition: unoidx.cxx:384
virtual ~SwXDocumentIndexMark() override
Definition: unoidx.cxx:1610
#define USER_LEN
Definition: unoidx.cxx:125
virtual void SetMark()
Unless this is called, the getter method of Mark will return Point.
Definition: pam.cxx:476
SectionType GetType() const
Definition: section.hxx:169
const SwTOXType * GetTOXType(TOXTypes eTyp, sal_uInt16 nId) const
Definition: doctxm.cxx:620
#define WID_LABEL_DISPLAY_TYPE
Definition: unomap.hxx:181
#define WID_USE_ALPHABETICAL_SEPARATORS
Definition: unomap.hxx:173
static css::uno::Reference< css::text::XTextRange > CreateXTextRange(SwDoc &rDoc, const SwPosition &rPos, const SwPosition *const pMark)
Definition: unoobj2.cxx:1214
virtual void SAL_CALL replaceByIndex(sal_Int32 Index, const uno::Any &rElement) override
Definition: unoidx.cxx:2508
const SwForm & GetTOXForm() const
Definition: tox.hxx:711
::sw::UnoImplPtr< Impl > m_pImpl
Definition: unoidx.hxx:61
::std::unique_ptr< XmlIdRegistry_Impl > m_pImpl
SwSection * GetSection() const
Definition: section.cxx:640
#define WID_MAIN_ENTRY_CHARACTER_STYLE_NAME
Definition: unomap.hxx:187
SfxItemPropertySet const & m_rPropSet
Definition: unoidx.cxx:1487
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
Definition: unoidx.cxx:2322
static T lcl_AnyToType(uno::Any const &rVal)
Definition: unoidx.cxx:72
void SetSecondaryKeyReading(const OUString &rStr)
Definition: tox.hxx:620
#define WID_LABEL_CATEGORY
Definition: unomap.hxx:180
#define WID_PARA_LEV4
Definition: unomap.hxx:205
SwSectionFormats & GetSections()
Definition: doc.hxx:1337
virtual sal_Int32 SAL_CALL getCount() override
Definition: unoidx.cxx:2544
virtual sal_Bool SAL_CALL supportsService(const OUString &rServiceName) override
Definition: unoidx.cxx:447
#define WID_IDX_HEADER_SECTION
Definition: unomap.hxx:217
::comphelper::OInterfaceContainerHelper4< css::lang::XEventListener > m_EventListeners
Definition: unoidx.cxx:1490
SfxItemPropertySet const & m_rPropSet
Definition: unoidx.cxx:300
struct _ADOIndex Index
void SetMainEntry(bool bSet)
Definition: tox.hxx:154
SwXDocumentIndexMark(SwDoc &rDoc, const SwTOXType &rType, const SwTOXMark &rMark)
Definition: unoidx.cxx:1603
virtual ~SwXDocumentIndex() override
Definition: unoidx.cxx:396
FormTokenType
Definition: tox.hxx:226
virtual void SAL_CALL addEventListener(const css::uno::Reference< css::lang::XEventListener > &xListener) override
Definition: unoidx.cxx:1381
SwTOXBase & GetTOXSectionOrThrow() const
Definition: unoidx.cxx:334
SwServiceType
entries in this enum are mapped in an array in unocoll.cxx
Definition: unocoll.hxx:63
#define PROPERTY_MAP_INDEX_ILLUSTRATIONS
Definition: unomap.hxx:52
StyleAccess_Impl(SwXDocumentIndex &rParentIdx)
Definition: unoidx.cxx:2479
virtual OUString SAL_CALL getImplementationName() override
Definition: unoidx.cxx:1660
virtual void SAL_CALL addPropertyChangeListener(const OUString &rPropertyName, const css::uno::Reference< css::beans::XPropertyChangeListener > &xListener) override
Definition: unoidx.cxx:2270
const SfxItemPropertyMapEntry * GetPropertyMapEntries(sal_uInt16 PropertyId)
Definition: unomap.cxx:71
sal_uInt16 nPos
SwTOXType * GetTOXType() const
Definition: unoidx.cxx:1533
#define WID_ALT_TEXT
Definition: unomap.hxx:165
::cppu::WeakImplHelper< lang::XServiceInfo, container::XIndexReplace > SwXDocumentIndexTokenAccess_Base
Definition: unoidx.cxx:206
virtual sal_Bool SAL_CALL hasByName(const OUString &rName) override
Definition: unoidx.cxx:2443
const struct TokenType_ g_TokenTypes[]
Definition: unoidx.cxx:2629
virtual sal_Bool SAL_CALL hasElements() override
Definition: unoidx.cxx:2474
static const OUString & GetSpecialExtraUIName(const OUString &rExtraProgName)
only the title
Definition: chpfld.hxx:33
bool m_bDetectedRangeSegmentation false
virtual void SAL_CALL addEventListener(const css::uno::Reference< css::lang::XEventListener > &xListener) override
Definition: unoidx.cxx:1987
#define WID_IS_CASE_SENSITIVE
Definition: unomap.hxx:176
#define PROPERTY_MAP_INDEX_TABLES
Definition: unomap.hxx:54
virtual ~SwXDocumentIndexes() override
Definition: unoidx.cxx:2306