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>
38 #include <tools/UnitConversion.hxx>
39 #include <vcl/svapp.hxx>
41 #include <editeng/memberids.h>
42 #include <swtypes.hxx>
43 #include <shellres.hxx>
44 #include <viewsh.hxx>
45 #include <doc.hxx>
47 #include <docary.hxx>
48 #include <fmtcntnt.hxx>
49 #include <unomap.hxx>
50 #include <unotextrange.hxx>
51 #include <unotextcursor.hxx>
52 #include <unosection.hxx>
53 #include <doctxm.hxx>
54 #include <txttxmrk.hxx>
55 #include <ndtxt.hxx>
56 #include <docsh.hxx>
57 #include <chpfld.hxx>
58 #include <editsh.hxx>
59 #include <SwStyleNameMapper.hxx>
60 #include <strings.hrc>
62 #include <comphelper/string.hxx>
63 #include <cppuhelper/implbase.hxx>
64 #include <svl/itemprop.hxx>
65 #include <svl/listener.hxx>
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:
1481  ::osl::Mutex m_Mutex; // just for OInterfaceContainerHelper3
1484 
1485 public:
1486 
1487  uno::WeakReference<uno::XInterface> m_wThis;
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_EventListeners(m_Mutex)
1518  , m_bIsDescriptor(nullptr == pMark)
1519  , m_pTOXType(pType)
1520  , m_pTOXMark(pMark)
1521  , m_pDoc(pDoc)
1522  , m_bMainEntry(false)
1523  , m_nLevel(0)
1524  {
1525  auto pMarkNonConst = const_cast<SwTOXMark*>(m_pTOXMark);
1526  auto pTypeNonConst = const_cast<SwTOXType*>(m_pTOXType);
1527 
1528  if(pMarkNonConst)
1529  StartListening(pMarkNonConst->GetNotifier());
1530  if(pTypeNonConst)
1531  StartListening(pTypeNonConst->GetNotifier());
1532  }
1533 
1535  return const_cast<SwTOXType*>(m_pTOXType);
1536  }
1537 
1539  {
1540  m_pDoc->DeleteTOXMark(m_pTOXMark);
1541  Invalidate();
1542  }
1543 
1544  void InsertTOXMark(const SwTOXType & rTOXType, SwTOXMark & rMark, SwPaM & rPam,
1545  SwXTextCursor const*const pTextCursor);
1546 
1547  void ReplaceTOXMark(const SwTOXType & rTOXType, SwTOXMark & rMark, SwPaM & rPam)
1548  {
1549  m_bInReplaceMark = true;
1550  DeleteTOXMark();
1551  m_bInReplaceMark = false;
1552  try {
1553  InsertTOXMark(rTOXType, rMark, rPam, nullptr);
1554  } catch (...) {
1555  OSL_FAIL("ReplaceTOXMark() failed!");
1556  lang::EventObject const ev(
1557  static_cast< ::cppu::OWeakObject&>(m_rThis));
1558  m_EventListeners.disposeAndClear(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);
1577  }
1578  }
1579  EndListeningAll();
1580  m_pDoc = nullptr;
1581  m_pTOXMark = nullptr;
1582  m_pTOXType = nullptr;
1583 }
1584 
1586 {
1587  if(auto pModifyChangedHint = dynamic_cast<const sw::ModifyChangedHint*>(&rHint))
1588  {
1589  if(auto pNewType = dynamic_cast<const SwTOXType*>(pModifyChangedHint->m_pNew))
1590  m_pTOXType = pNewType;
1591 
1592  else
1593  Invalidate();
1594  }
1595 }
1596 
1598  : m_pImpl( new SwXDocumentIndexMark::Impl(*this, nullptr, eToxType, nullptr, nullptr) )
1599 {
1600 }
1601 
1603  const SwTOXType & rType, const SwTOXMark & rMark)
1604  : m_pImpl( new SwXDocumentIndexMark::Impl(*this, &rDoc, rType.GetType(),
1605  &rType, &rMark) )
1606 {
1607 }
1608 
1610 {
1611 }
1612 
1613 uno::Reference<text::XDocumentIndexMark>
1615  SwDoc & rDoc, SwTOXMark *const pMark, TOXTypes const eType)
1616 {
1617  // re-use existing SwXDocumentIndexMark
1618  // NB: xmloff depends on this caching to generate ID from the address!
1619  // #i105557#: do not iterate over the registered clients: race condition
1620  uno::Reference<text::XDocumentIndexMark> xTOXMark;
1621  if (pMark)
1622  {
1623  xTOXMark = pMark->GetXTOXMark();
1624  }
1625  if (!xTOXMark.is())
1626  {
1627  SwXDocumentIndexMark *const pNew(pMark
1628  ? new SwXDocumentIndexMark(rDoc,
1629  *const_cast<SwTOXType*>(pMark->GetTOXType()), *pMark)
1630  : new SwXDocumentIndexMark(eType));
1631  xTOXMark.set(pNew);
1632  if (pMark)
1633  {
1634  pMark->SetXTOXMark(xTOXMark);
1635  }
1636  // need a permanent Reference to initialize m_wThis
1637  pNew->m_pImpl->m_wThis = xTOXMark;
1638  }
1639  return xTOXMark;
1640 }
1641 
1642 namespace
1643 {
1644 }
1645 
1646 const uno::Sequence< sal_Int8 > & SwXDocumentIndexMark::getUnoTunnelId()
1647 {
1648  static const comphelper::UnoIdInit theSwXDocumentIndexMarkUnoTunnelId;
1649  return theSwXDocumentIndexMarkUnoTunnelId.getSeq();
1650 }
1651 
1652 sal_Int64 SAL_CALL
1653 SwXDocumentIndexMark::getSomething(const uno::Sequence< sal_Int8 >& rId)
1654 {
1655  return comphelper::getSomethingImpl<SwXDocumentIndexMark>(rId, this);
1656 }
1657 
1658 OUString SAL_CALL
1660 {
1661  return "SwXDocumentIndexMark";
1662 }
1663 
1664 sal_Bool SAL_CALL SwXDocumentIndexMark::supportsService(const OUString& rServiceName)
1665 {
1666  return cppu::supportsService(this, rServiceName);
1667 }
1668 
1669 uno::Sequence< OUString > SAL_CALL
1671 {
1672  SolarMutexGuard g;
1673 
1674  const sal_Int32 nCnt = (m_pImpl->m_eTOXType == TOX_INDEX) ? 4 : 3;
1675  uno::Sequence< OUString > aRet(nCnt);
1676  OUString* pArray = aRet.getArray();
1677  pArray[0] = "com.sun.star.text.BaseIndexMark";
1678  pArray[1] = "com.sun.star.text.TextContent";
1679  switch (m_pImpl->m_eTOXType)
1680  {
1681  case TOX_USER:
1682  pArray[2] = "com.sun.star.text.UserIndexMark";
1683  break;
1684  case TOX_CONTENT:
1685  pArray[2] = "com.sun.star.text.ContentIndexMark";
1686  break;
1687  case TOX_INDEX:
1688  pArray[2] = "com.sun.star.text.DocumentIndexMark";
1689  pArray[3] = "com.sun.star.text.DocumentIndexMarkAsian";
1690  break;
1691 
1692  default:
1693  ;
1694  }
1695  return aRet;
1696 }
1697 
1698 OUString SAL_CALL
1700 {
1701  SolarMutexGuard aGuard;
1702 
1703  SwTOXType *const pType = m_pImpl->GetTOXType();
1704  if (pType && m_pImpl->m_pTOXMark)
1705  {
1706  return m_pImpl->m_pTOXMark->GetAlternativeText();
1707  }
1708 
1709  if (!m_pImpl->m_bIsDescriptor)
1710  {
1711  throw uno::RuntimeException();
1712  }
1713 
1714  return m_pImpl->m_sAltText;
1715 }
1716 
1717 void SAL_CALL
1718 SwXDocumentIndexMark::setMarkEntry(const OUString& rIndexEntry)
1719 {
1720  SolarMutexGuard aGuard;
1721 
1722  SwTOXType *const pType = m_pImpl->GetTOXType();
1723  if (pType && m_pImpl->m_pTOXMark)
1724  {
1725  SwTOXMark aMark(*m_pImpl->m_pTOXMark);
1726  aMark.SetAlternativeText(rIndexEntry);
1727  SwTextTOXMark const*const pTextMark =
1728  m_pImpl->m_pTOXMark->GetTextTOXMark();
1729  SwPaM aPam(pTextMark->GetTextNode(), pTextMark->GetStart());
1730  aPam.SetMark();
1731  if(pTextMark->End())
1732  {
1733  aPam.GetPoint()->nContent = *pTextMark->End();
1734  }
1735  else
1736  ++aPam.GetPoint()->nContent;
1737 
1738  m_pImpl->ReplaceTOXMark(*pType, aMark, aPam);
1739  }
1740  else if (m_pImpl->m_bIsDescriptor)
1741  {
1742  m_pImpl->m_sAltText = rIndexEntry;
1743  }
1744  else
1745  {
1746  throw uno::RuntimeException();
1747  }
1748 }
1749 
1750 void SAL_CALL
1752  const uno::Reference< text::XTextRange > & xTextRange)
1753 {
1754  SolarMutexGuard aGuard;
1755 
1756  if (!m_pImpl->m_bIsDescriptor)
1757  {
1758  throw uno::RuntimeException();
1759  }
1760 
1761  const uno::Reference<XUnoTunnel> xRangeTunnel(xTextRange, uno::UNO_QUERY);
1762  SwXTextRange *const pRange =
1763  comphelper::getFromUnoTunnel<SwXTextRange>(xRangeTunnel);
1764  OTextCursorHelper *const pCursor =
1765  comphelper::getFromUnoTunnel<OTextCursorHelper>(xRangeTunnel);
1766  SwDoc *const pDoc =
1767  pRange ? &pRange->GetDoc() : (pCursor ? pCursor->GetDoc() : nullptr);
1768  if (!pDoc)
1769  {
1770  throw lang::IllegalArgumentException();
1771  }
1772 
1773  const SwTOXType* pTOXType = nullptr;
1774  switch (m_pImpl->m_eTOXType)
1775  {
1776  case TOX_INDEX:
1777  case TOX_CONTENT:
1778  case TOX_CITATION:
1779  pTOXType = pDoc->GetTOXType( m_pImpl->m_eTOXType, 0 );
1780  break;
1781  case TOX_USER:
1782  {
1783  if (m_pImpl->m_sUserIndexName.isEmpty())
1784  {
1785  pTOXType = pDoc->GetTOXType( m_pImpl->m_eTOXType, 0 );
1786  }
1787  else
1788  {
1789  const sal_uInt16 nCount =
1790  pDoc->GetTOXTypeCount(m_pImpl->m_eTOXType);
1791  for (sal_uInt16 i = 0; i < nCount; i++)
1792  {
1793  SwTOXType const*const pTemp =
1794  pDoc->GetTOXType( m_pImpl->m_eTOXType, i );
1795  if (m_pImpl->m_sUserIndexName == pTemp->GetTypeName())
1796  {
1797  pTOXType = pTemp;
1798  break;
1799  }
1800  }
1801  if (!pTOXType)
1802  {
1803  SwTOXType aUserType(*pDoc, TOX_USER, m_pImpl->m_sUserIndexName);
1804  pTOXType = pDoc->InsertTOXType(aUserType);
1805  }
1806  }
1807  }
1808  break;
1809 
1810  default:
1811  break;
1812  }
1813  if (!pTOXType)
1814  {
1815  throw lang::IllegalArgumentException();
1816  }
1817 
1818  SwUnoInternalPaM aPam(*pDoc);
1819  // this now needs to return TRUE
1820  ::sw::XTextRangeToSwPaM(aPam, xTextRange);
1821  SwTOXMark aMark (pTOXType);
1822  if (!m_pImpl->m_sAltText.isEmpty())
1823  {
1824  aMark.SetAlternativeText(m_pImpl->m_sAltText);
1825  }
1826  switch (m_pImpl->m_eTOXType)
1827  {
1828  case TOX_INDEX:
1829  if (!m_pImpl->m_sPrimaryKey.isEmpty())
1830  {
1831  aMark.SetPrimaryKey(m_pImpl->m_sPrimaryKey);
1832  }
1833  if (!m_pImpl->m_sSecondaryKey.isEmpty())
1834  {
1835  aMark.SetSecondaryKey(m_pImpl->m_sSecondaryKey);
1836  }
1837  if (!m_pImpl->m_sTextReading.isEmpty())
1838  {
1839  aMark.SetTextReading(m_pImpl->m_sTextReading);
1840  }
1841  if (!m_pImpl->m_sPrimaryKeyReading.isEmpty())
1842  {
1843  aMark.SetPrimaryKeyReading(m_pImpl->m_sPrimaryKeyReading);
1844  }
1845  if (!m_pImpl->m_sSecondaryKeyReading.isEmpty())
1846  {
1847  aMark.SetSecondaryKeyReading(m_pImpl->m_sSecondaryKeyReading);
1848  }
1849  aMark.SetMainEntry(m_pImpl->m_bMainEntry);
1850  break;
1851  case TOX_CITATION:
1852  aMark.SetMainEntry(m_pImpl->m_bMainEntry);
1853  break;
1854  case TOX_USER:
1855  case TOX_CONTENT:
1856  if (USHRT_MAX != m_pImpl->m_nLevel)
1857  {
1858  aMark.SetLevel(m_pImpl->m_nLevel+1);
1859  }
1860  break;
1861 
1862  default:
1863  break;
1864  }
1865 
1866  m_pImpl->InsertTOXMark(*const_cast<SwTOXType *>(pTOXType), aMark, aPam,
1867  dynamic_cast<SwXTextCursor const*>(pCursor));
1868 
1869  m_pImpl->m_bIsDescriptor = false;
1870 }
1871 
1872 namespace {
1873 
1874 template<typename T> struct NotContainedIn
1875 {
1876  std::vector<T> const& m_rVector;
1877  explicit NotContainedIn(std::vector<T> const& rVector)
1878  : m_rVector(rVector) { }
1879  bool operator() (T const& rT) {
1880  return std::find(m_rVector.begin(), m_rVector.end(), rT)
1881  == m_rVector.end();
1882  }
1883 };
1884 
1885 }
1886 
1888  const SwTOXType & rTOXType, SwTOXMark & rMark, SwPaM & rPam,
1889  SwXTextCursor const*const pTextCursor)
1890 {
1891  SwDoc& rDoc(rPam.GetDoc());
1892  UnoActionContext aAction(&rDoc);
1893  bool bMark = *rPam.GetPoint() != *rPam.GetMark();
1894  // n.b.: toxmarks must have either alternative text or an extent
1895  if (bMark && !rMark.GetAlternativeText().isEmpty())
1896  {
1897  rPam.Normalize();
1898  rPam.DeleteMark();
1899  bMark = false;
1900  }
1901  // Marks without alternative text and without selected text cannot be inserted,
1902  // thus use a space - is this really the ideal solution?
1903  if (!bMark && rMark.GetAlternativeText().isEmpty())
1904  {
1905  rMark.SetAlternativeText( " " );
1906  }
1907 
1908  const bool bForceExpandHints( !bMark && pTextCursor && pTextCursor->IsAtEndOfMeta() );
1909  const SetAttrMode nInsertFlags = bForceExpandHints
1913 
1914  // rMark gets copied into the document pool;
1915  // pNewTextAttr comes back with the real format
1916  SwTextAttr *pNewTextAttr = nullptr;
1917  rDoc.getIDocumentContentOperations().InsertPoolItem(rPam, rMark, nInsertFlags,
1918  /*pLayout*/nullptr, &pNewTextAttr);
1919  if (bMark && *rPam.GetPoint() > *rPam.GetMark())
1920  {
1921  rPam.Exchange();
1922  }
1923 
1924  if (!pNewTextAttr)
1925  {
1926  throw uno::RuntimeException(
1927  "SwXDocumentIndexMark::InsertTOXMark(): cannot insert attribute",
1928  nullptr);
1929  }
1930 
1931  m_pDoc = &rDoc;
1932  m_pTOXMark = &pNewTextAttr->GetTOXMark();
1933  m_pTOXType = &rTOXType;
1934  EndListeningAll();
1935  StartListening(const_cast<SwTOXMark*>(m_pTOXMark)->GetNotifier());
1936  StartListening(const_cast<SwTOXType*>(m_pTOXType)->GetNotifier());
1937 }
1938 
1939 uno::Reference< text::XTextRange > SAL_CALL
1941 {
1942  SolarMutexGuard aGuard;
1943 
1944  SwTOXType *const pType = m_pImpl->GetTOXType();
1945  if (!pType || !m_pImpl->m_pTOXMark)
1946  {
1947  throw uno::RuntimeException();
1948  }
1949  if (!m_pImpl->m_pTOXMark->GetTextTOXMark())
1950  {
1951  throw uno::RuntimeException();
1952  }
1953  const SwTextTOXMark* pTextMark = m_pImpl->m_pTOXMark->GetTextTOXMark();
1954  SwPaM aPam(pTextMark->GetTextNode(), pTextMark->GetStart());
1955  aPam.SetMark();
1956  if(pTextMark->End())
1957  {
1958  aPam.GetPoint()->nContent = *pTextMark->End();
1959  }
1960  else
1961  {
1962  ++aPam.GetPoint()->nContent;
1963  }
1964  const uno::Reference< frame::XModel > xModel =
1965  m_pImpl->m_pDoc->GetDocShell()->GetBaseModel();
1966  const uno::Reference< text::XTextDocument > xTDoc(xModel, uno::UNO_QUERY);
1967  const uno::Reference< text::XTextRange > xRet =
1968  new SwXTextRange(aPam, xTDoc->getText());
1969 
1970  return xRet;
1971 }
1972 
1973 void SAL_CALL
1975 {
1976  SolarMutexGuard aGuard;
1977 
1978  SwTOXType *const pType = m_pImpl->GetTOXType();
1979  if (pType && m_pImpl->m_pTOXMark)
1980  {
1981  m_pImpl->DeleteTOXMark(); // call Invalidate() via modify!
1982  }
1983 }
1984 
1985 void SAL_CALL
1987  const uno::Reference< lang::XEventListener > & xListener)
1988 {
1989  // no need to lock here as m_pImpl is const and container threadsafe
1990  m_pImpl->m_EventListeners.addInterface(xListener);
1991 }
1992 
1993 void SAL_CALL
1995  const uno::Reference< lang::XEventListener > & xListener)
1996 {
1997  // no need to lock here as m_pImpl is const and container threadsafe
1998  m_pImpl->m_EventListeners.removeInterface(xListener);
1999 }
2000 
2001 uno::Reference< beans::XPropertySetInfo > SAL_CALL
2003 {
2004  SolarMutexGuard g;
2005 
2006  static uno::Reference< beans::XPropertySetInfo > xInfos[3];
2007  int nPos = 0;
2008  switch (m_pImpl->m_eTOXType)
2009  {
2010  case TOX_INDEX: nPos = 0; break;
2011  case TOX_CONTENT: nPos = 1; break;
2012  case TOX_USER: nPos = 2; break;
2013  default:
2014  ;
2015  }
2016  if(!xInfos[nPos].is())
2017  {
2018  const uno::Reference< beans::XPropertySetInfo > xInfo =
2019  m_pImpl->m_rPropSet.getPropertySetInfo();
2020  // extend PropertySetInfo!
2021  const uno::Sequence<beans::Property> aPropSeq = xInfo->getProperties();
2022  xInfos[nPos] = new SfxExtItemPropertySetInfo(
2025  aPropSeq );
2026  }
2027  return xInfos[nPos];
2028 }
2029 
2030 void SAL_CALL
2032  const OUString& rPropertyName, const uno::Any& rValue)
2033 {
2034  SolarMutexGuard aGuard;
2035 
2036  SfxItemPropertyMapEntry const*const pEntry =
2037  m_pImpl->m_rPropSet.getPropertyMap().getByName(rPropertyName);
2038  if (!pEntry)
2039  {
2040  throw beans::UnknownPropertyException(
2041  "Unknown property: " + rPropertyName,
2042  static_cast<cppu::OWeakObject *>(this));
2043  }
2044  if (pEntry->nFlags & beans::PropertyAttribute::READONLY)
2045  {
2046  throw beans::PropertyVetoException(
2047  "Property is read-only: " + rPropertyName,
2048  static_cast<cppu::OWeakObject *>(this));
2049  }
2050 
2051  SwTOXType *const pType = m_pImpl->GetTOXType();
2052  if (pType && m_pImpl->m_pTOXMark)
2053  {
2054  SwTOXMark aMark(*m_pImpl->m_pTOXMark);
2055  switch(pEntry->nWID)
2056  {
2057  case WID_ALT_TEXT:
2058  aMark.SetAlternativeText(lcl_AnyToType<OUString>(rValue));
2059  break;
2060  case WID_LEVEL:
2061  aMark.SetLevel(std::min( static_cast<sal_Int8>( MAXLEVEL ),
2062  static_cast<sal_Int8>(lcl_AnyToType<sal_Int16>(rValue)+1)));
2063  break;
2064  case WID_TOC_BOOKMARK :
2065  aMark.SetBookmarkName(lcl_AnyToType<OUString>(rValue));
2066  break;
2067  case WID_PRIMARY_KEY :
2068  aMark.SetPrimaryKey(lcl_AnyToType<OUString>(rValue));
2069  break;
2070  case WID_SECONDARY_KEY:
2071  aMark.SetSecondaryKey(lcl_AnyToType<OUString>(rValue));
2072  break;
2073  case WID_MAIN_ENTRY:
2074  aMark.SetMainEntry(lcl_AnyToType<bool>(rValue));
2075  break;
2076  case WID_TEXT_READING:
2077  aMark.SetTextReading(lcl_AnyToType<OUString>(rValue));
2078  break;
2080  aMark.SetPrimaryKeyReading(lcl_AnyToType<OUString>(rValue));
2081  break;
2083  aMark.SetSecondaryKeyReading(lcl_AnyToType<OUString>(rValue));
2084  break;
2085  }
2086  SwTextTOXMark const*const pTextMark =
2087  m_pImpl->m_pTOXMark->GetTextTOXMark();
2088  SwPaM aPam(pTextMark->GetTextNode(), pTextMark->GetStart());
2089  aPam.SetMark();
2090  if(pTextMark->End())
2091  {
2092  aPam.GetPoint()->nContent = *pTextMark->End();
2093  }
2094  else
2095  {
2096  ++aPam.GetPoint()->nContent;
2097  }
2098 
2099  m_pImpl->ReplaceTOXMark(*pType, aMark, aPam);
2100  }
2101  else if (m_pImpl->m_bIsDescriptor)
2102  {
2103  switch(pEntry->nWID)
2104  {
2105  case WID_ALT_TEXT:
2106  m_pImpl->m_sAltText = lcl_AnyToType<OUString>(rValue);
2107  break;
2108  case WID_LEVEL:
2109  {
2110  const sal_Int16 nVal = lcl_AnyToType<sal_Int16>(rValue);
2111  if(nVal < 0 || nVal >= MAXLEVEL)
2112  {
2113  throw lang::IllegalArgumentException();
2114  }
2115  m_pImpl->m_nLevel = nVal;
2116  }
2117  break;
2118  case WID_TOC_BOOKMARK :
2119  {
2120  m_pImpl->m_aBookmarkName = lcl_AnyToType<OUString>(rValue);
2121  }
2122  break;
2123  case WID_PRIMARY_KEY:
2124  m_pImpl->m_sPrimaryKey = lcl_AnyToType<OUString>(rValue);
2125  break;
2126  case WID_SECONDARY_KEY:
2127  m_pImpl->m_sSecondaryKey = lcl_AnyToType<OUString>(rValue);
2128  break;
2129  case WID_TEXT_READING:
2130  m_pImpl->m_sTextReading = lcl_AnyToType<OUString>(rValue);
2131  break;
2133  m_pImpl->m_sPrimaryKeyReading = lcl_AnyToType<OUString>(rValue);
2134  break;
2136  m_pImpl->m_sSecondaryKeyReading = lcl_AnyToType<OUString>(rValue);
2137  break;
2138  case WID_USER_IDX_NAME:
2139  {
2140  OUString sTmp(lcl_AnyToType<OUString>(rValue));
2142  m_pImpl->m_sUserIndexName = sTmp;
2143  }
2144  break;
2145  case WID_MAIN_ENTRY:
2146  m_pImpl->m_bMainEntry = lcl_AnyToType<bool>(rValue);
2147  break;
2149  // unsupported
2150  break;
2151  }
2152  }
2153  else
2154  {
2155  throw uno::RuntimeException();
2156  }
2157 }
2158 
2159 uno::Any SAL_CALL
2160 SwXDocumentIndexMark::getPropertyValue(const OUString& rPropertyName)
2161 {
2162  SolarMutexGuard aGuard;
2163 
2164  uno::Any aRet;
2165  SfxItemPropertyMapEntry const*const pEntry =
2166  m_pImpl->m_rPropSet.getPropertyMap().getByName(rPropertyName);
2167  if (!pEntry)
2168  {
2169  throw beans::UnknownPropertyException(
2170  "Unknown property: " + rPropertyName,
2171  static_cast<cppu::OWeakObject *>(this));
2172  }
2173  if (::sw::GetDefaultTextContentValue(aRet, rPropertyName, pEntry->nWID))
2174  {
2175  return aRet;
2176  }
2177 
2178  SwTOXType *const pType = m_pImpl->GetTOXType();
2179  if (pType && m_pImpl->m_pTOXMark)
2180  {
2181  switch(pEntry->nWID)
2182  {
2183  case WID_ALT_TEXT:
2184  aRet <<= m_pImpl->m_pTOXMark->GetAlternativeText();
2185  break;
2186  case WID_LEVEL:
2187  aRet <<= static_cast<sal_Int16>(
2188  m_pImpl->m_pTOXMark->GetLevel() - 1);
2189  break;
2190  case WID_TOC_BOOKMARK :
2191  aRet <<= m_pImpl->m_pTOXMark->GetBookmarkName();
2192  break;
2193  case WID_PRIMARY_KEY :
2194  aRet <<= m_pImpl->m_pTOXMark->GetPrimaryKey();
2195  break;
2196  case WID_SECONDARY_KEY:
2197  aRet <<= m_pImpl->m_pTOXMark->GetSecondaryKey();
2198  break;
2199  case WID_TEXT_READING:
2200  aRet <<= m_pImpl->m_pTOXMark->GetTextReading();
2201  break;
2203  aRet <<= m_pImpl->m_pTOXMark->GetPrimaryKeyReading();
2204  break;
2206  aRet <<= m_pImpl->m_pTOXMark->GetSecondaryKeyReading();
2207  break;
2208  case WID_USER_IDX_NAME :
2209  {
2210  OUString sTmp(pType->GetTypeName());
2212  aRet <<= sTmp;
2213  }
2214  break;
2215  case WID_MAIN_ENTRY:
2216  {
2217  const bool bTemp = m_pImpl->m_pTOXMark->IsMainEntry();
2218  aRet <<= bTemp;
2219  }
2220  break;
2221  }
2222  }
2223  else if (m_pImpl->m_bIsDescriptor)
2224  {
2225  switch(pEntry->nWID)
2226  {
2227  case WID_ALT_TEXT:
2228  aRet <<= m_pImpl->m_sAltText;
2229  break;
2230  case WID_LEVEL:
2231  aRet <<= static_cast<sal_Int16>(m_pImpl->m_nLevel);
2232  break;
2233  case WID_TOC_BOOKMARK :
2234  aRet <<= m_pImpl->m_aBookmarkName;
2235  break;
2236  case WID_PRIMARY_KEY:
2237  aRet <<= m_pImpl->m_sPrimaryKey;
2238  break;
2239  case WID_SECONDARY_KEY:
2240  aRet <<= m_pImpl->m_sSecondaryKey;
2241  break;
2242  case WID_TEXT_READING:
2243  aRet <<= m_pImpl->m_sTextReading;
2244  break;
2246  aRet <<= m_pImpl->m_sPrimaryKeyReading;
2247  break;
2249  aRet <<= m_pImpl->m_sSecondaryKeyReading;
2250  break;
2251  case WID_USER_IDX_NAME :
2252  aRet <<= m_pImpl->m_sUserIndexName;
2253  break;
2254  case WID_MAIN_ENTRY:
2255  aRet <<= m_pImpl->m_bMainEntry;
2256  break;
2257  }
2258  }
2259  else
2260  {
2261  throw uno::RuntimeException();
2262  }
2263  return aRet;
2264 }
2265 
2266 void SAL_CALL
2268  const OUString& /*rPropertyName*/,
2269  const uno::Reference< beans::XPropertyChangeListener >& /*xListener*/)
2270 {
2271  OSL_FAIL("SwXDocumentIndexMark::addPropertyChangeListener(): not implemented");
2272 }
2273 
2274 void SAL_CALL
2276  const OUString& /*rPropertyName*/,
2277  const uno::Reference< beans::XPropertyChangeListener >& /*xListener*/)
2278 {
2279  OSL_FAIL("SwXDocumentIndexMark::removePropertyChangeListener(): not implemented");
2280 }
2281 
2282 void SAL_CALL
2284  const OUString& /*rPropertyName*/,
2285  const uno::Reference< beans::XVetoableChangeListener >& /*xListener*/)
2286 {
2287  OSL_FAIL("SwXDocumentIndexMark::addVetoableChangeListener(): not implemented");
2288 }
2289 
2290 void SAL_CALL
2292  const OUString& /*rPropertyName*/,
2293  const uno::Reference< beans::XVetoableChangeListener >& /*xListener*/)
2294 {
2295  OSL_FAIL("SwXDocumentIndexMark::removeVetoableChangeListener(): not implemented");
2296 }
2297 
2299  : SwUnoCollection(_pDoc)
2300 {
2301 }
2302 
2304 {
2305 }
2306 
2307 OUString SAL_CALL
2309 {
2310  return "SwXDocumentIndexes";
2311 }
2312 
2313 sal_Bool SAL_CALL SwXDocumentIndexes::supportsService(const OUString& rServiceName)
2314 {
2315  return cppu::supportsService(this, rServiceName);
2316 }
2317 
2318 uno::Sequence< OUString > SAL_CALL
2320 {
2321  return { "com.sun.star.text.DocumentIndexes" };
2322 }
2323 
2324 sal_Int32 SAL_CALL
2326 {
2327  SolarMutexGuard aGuard;
2328 
2329  if(!IsValid())
2330  throw uno::RuntimeException();
2331 
2332  sal_uInt32 nRet = 0;
2333  const SwSectionFormats& rFormats = GetDoc()->GetSections();
2334  for( size_t n = 0; n < rFormats.size(); ++n )
2335  {
2336  const SwSection* pSect = rFormats[ n ]->GetSection();
2337  if( SectionType::ToxContent == pSect->GetType() &&
2338  pSect->GetFormat()->GetSectionNode() )
2339  {
2340  ++nRet;
2341  }
2342  }
2343  return nRet;
2344 }
2345 
2346 uno::Any SAL_CALL
2348 {
2349  SolarMutexGuard aGuard;
2350 
2351  if(!IsValid())
2352  throw uno::RuntimeException();
2353 
2354  sal_Int32 nIdx = 0;
2355 
2356  const SwSectionFormats& rFormats = GetDoc()->GetSections();
2357  for( size_t n = 0; n < rFormats.size(); ++n )
2358  {
2359  SwSection* pSect = rFormats[ n ]->GetSection();
2360  if( SectionType::ToxContent == pSect->GetType() &&
2361  pSect->GetFormat()->GetSectionNode() &&
2362  nIdx++ == nIndex )
2363  {
2364  const uno::Reference< text::XDocumentIndex > xTmp =
2366  *GetDoc(), static_cast<SwTOXBaseSection *>(pSect));
2367  uno::Any aRet;
2368  aRet <<= xTmp;
2369  return aRet;
2370  }
2371  }
2372 
2373  throw lang::IndexOutOfBoundsException();
2374 }
2375 
2376 uno::Any SAL_CALL
2377 SwXDocumentIndexes::getByName(const OUString& rName)
2378 {
2379  SolarMutexGuard aGuard;
2380 
2381  if(!IsValid())
2382  throw uno::RuntimeException();
2383 
2384  const SwSectionFormats& rFormats = GetDoc()->GetSections();
2385  for( size_t n = 0; n < rFormats.size(); ++n )
2386  {
2387  SwSection* pSect = rFormats[ n ]->GetSection();
2388  if( SectionType::ToxContent == pSect->GetType() &&
2389  pSect->GetFormat()->GetSectionNode() &&
2390  (static_cast<SwTOXBaseSection const*>(pSect)->GetTOXName()
2391  == rName))
2392  {
2393  const uno::Reference< text::XDocumentIndex > xTmp =
2395  *GetDoc(), static_cast<SwTOXBaseSection *>(pSect));
2396  uno::Any aRet;
2397  aRet <<= xTmp;
2398  return aRet;
2399  }
2400  }
2401  throw container::NoSuchElementException();
2402 }
2403 
2404 uno::Sequence< OUString > SAL_CALL
2406 {
2407  SolarMutexGuard aGuard;
2408 
2409  if(!IsValid())
2410  throw uno::RuntimeException();
2411 
2412  const SwSectionFormats& rFormats = GetDoc()->GetSections();
2413  sal_Int32 nCount = 0;
2414  for( size_t n = 0; n < rFormats.size(); ++n )
2415  {
2416  SwSection const*const pSect = rFormats[ n ]->GetSection();
2417  if( SectionType::ToxContent == pSect->GetType() &&
2418  pSect->GetFormat()->GetSectionNode() )
2419  {
2420  ++nCount;
2421  }
2422  }
2423 
2424  uno::Sequence< OUString > aRet(nCount);
2425  OUString* pArray = aRet.getArray();
2426  sal_Int32 nCnt = 0;
2427  for( size_t n = 0; n < rFormats.size(); ++n )
2428  {
2429  SwSection const*const pSect = rFormats[ n ]->GetSection();
2430  if( SectionType::ToxContent == pSect->GetType() &&
2431  pSect->GetFormat()->GetSectionNode())
2432  {
2433  pArray[nCnt++] = static_cast<SwTOXBaseSection const*>(pSect)->GetTOXName();
2434  }
2435  }
2436  return aRet;
2437 }
2438 
2439 sal_Bool SAL_CALL
2440 SwXDocumentIndexes::hasByName(const OUString& rName)
2441 {
2442  SolarMutexGuard aGuard;
2443 
2444  if(!IsValid())
2445  throw uno::RuntimeException();
2446 
2447  const SwSectionFormats& rFormats = GetDoc()->GetSections();
2448  for( size_t n = 0; n < rFormats.size(); ++n )
2449  {
2450  SwSection const*const pSect = rFormats[ n ]->GetSection();
2451  if( SectionType::ToxContent == pSect->GetType() &&
2452  pSect->GetFormat()->GetSectionNode())
2453  {
2454  if (static_cast<SwTOXBaseSection const*>(pSect)->GetTOXName()
2455  == rName)
2456  {
2457  return true;
2458  }
2459  }
2460  }
2461  return false;
2462 }
2463 
2464 uno::Type SAL_CALL
2466 {
2468 }
2469 
2470 sal_Bool SAL_CALL
2472 {
2473  return 0 != getCount();
2474 }
2475 
2477  SwXDocumentIndex& rParentIdx)
2478  : m_xParent(&rParentIdx)
2479 {
2480 }
2481 
2483 {
2484 }
2485 
2486 OUString SAL_CALL
2488 {
2489  return "SwXDocumentIndex::StyleAccess_Impl";
2490 }
2491 
2492 sal_Bool SAL_CALL
2494 {
2495  return cppu::supportsService(this, rServiceName);
2496 }
2497 
2498 uno::Sequence< OUString > SAL_CALL
2500 {
2501  return { "com.sun.star.text.DocumentIndexParagraphStyles" };
2502 }
2503 
2504 void SAL_CALL
2506  sal_Int32 nIndex, const uno::Any& rElement)
2507 {
2508  SolarMutexGuard aGuard;
2509 
2510  if(nIndex < 0 || nIndex >= MAXLEVEL)
2511  {
2512  throw lang::IndexOutOfBoundsException();
2513  }
2514 
2515  SwTOXBase & rTOXBase( m_xParent->m_pImpl->GetTOXSectionOrThrow() );
2516 
2517  uno::Sequence<OUString> aSeq;
2518  if(!(rElement >>= aSeq))
2519  {
2520  throw lang::IllegalArgumentException();
2521  }
2522 
2523  const sal_Int32 nStyles = aSeq.getLength();
2524  const OUString* pStyles = aSeq.getConstArray();
2525  OUStringBuffer sSetStyles;
2526  OUString aString;
2527  for(sal_Int32 i = 0; i < nStyles; i++)
2528  {
2529  if(i)
2530  {
2531  sSetStyles.append(TOX_STYLE_DELIMITER);
2532  }
2533  SwStyleNameMapper::FillUIName(pStyles[i], aString,
2535  sSetStyles.append(aString);
2536  }
2537  rTOXBase.SetStyleNames(sSetStyles.makeStringAndClear(), o3tl::narrowing<sal_uInt16>(nIndex));
2538 }
2539 
2540 sal_Int32 SAL_CALL
2542 {
2543  return MAXLEVEL;
2544 }
2545 
2546 uno::Any SAL_CALL
2548 {
2549  SolarMutexGuard aGuard;
2550 
2551  if(nIndex < 0 || nIndex >= MAXLEVEL)
2552  {
2553  throw lang::IndexOutOfBoundsException();
2554  }
2555 
2556  SwTOXBase & rTOXBase( m_xParent->m_pImpl->GetTOXSectionOrThrow() );
2557 
2558  const OUString& rStyles =
2559  rTOXBase.GetStyleNames(o3tl::narrowing<sal_uInt16>(nIndex));
2560  const sal_Int32 nStyles = comphelper::string::getTokenCount(rStyles, TOX_STYLE_DELIMITER);
2561  uno::Sequence<OUString> aStyles(nStyles);
2562  OUString* pStyles = aStyles.getArray();
2563  OUString aString;
2564  sal_Int32 nPos = 0;
2565  for(sal_Int32 i = 0; i < nStyles; ++i)
2566  {
2568  rStyles.getToken(0, TOX_STYLE_DELIMITER, nPos),
2569  aString,
2571  pStyles[i] = aString;
2572  }
2573  uno::Any aRet(&aStyles, cppu::UnoType<uno::Sequence<OUString>>::get());
2574  return aRet;
2575 }
2576 
2577 uno::Type SAL_CALL
2579 {
2581 }
2582 
2583 sal_Bool SAL_CALL
2585 {
2586  return true;
2587 }
2588 
2590  SwXDocumentIndex& rParentIdx)
2591  : m_xParent(&rParentIdx)
2592 {
2593 }
2594 
2596 {
2597 }
2598 
2599 OUString SAL_CALL
2601 {
2602  return "SwXDocumentIndex::TokenAccess_Impl";
2603 }
2604 
2606  const OUString& rServiceName)
2607 {
2608  return cppu::supportsService(this, rServiceName);
2609 }
2610 
2611 uno::Sequence< OUString > SAL_CALL
2613 {
2614  return { "com.sun.star.text.DocumentIndexLevelFormat" };
2615 }
2616 
2617 namespace {
2618 
2619 struct TokenType_ {
2620  const char *pName;
2621  enum FormTokenType eTokenType;
2622 };
2623 
2624 }
2625 
2626 const struct TokenType_ g_TokenTypes[] =
2627 {
2628  { "TokenEntryNumber", TOKEN_ENTRY_NO },
2629  { "TokenEntryText", TOKEN_ENTRY_TEXT },
2630  { "TokenTabStop", TOKEN_TAB_STOP },
2631  { "TokenText", TOKEN_TEXT },
2632  { "TokenPageNumber", TOKEN_PAGE_NUMS },
2633  { "TokenChapterInfo", TOKEN_CHAPTER_INFO },
2634  { "TokenHyperlinkStart", TOKEN_LINK_START },
2635  { "TokenHyperlinkEnd", TOKEN_LINK_END },
2636  { "TokenBibliographyDataField", TOKEN_AUTHORITY },
2637  { nullptr, static_cast<enum FormTokenType>(0) }
2638 };
2639 
2640 void SAL_CALL
2642  sal_Int32 nIndex, const uno::Any& rElement)
2643 {
2644  SolarMutexGuard aGuard;
2645 
2646  SwTOXBase & rTOXBase( m_xParent->m_pImpl->GetTOXSectionOrThrow() );
2647 
2648  if ((nIndex < 0) || (nIndex > rTOXBase.GetTOXForm().GetFormMax()))
2649  {
2650  throw lang::IndexOutOfBoundsException();
2651  }
2652 
2653  uno::Sequence<beans::PropertyValues> aSeq;
2654  if(!(rElement >>= aSeq))
2655  {
2656  throw lang::IllegalArgumentException();
2657  }
2658 
2659  OUStringBuffer sPattern;
2660  for(const beans::PropertyValues& rToken : std::as_const(aSeq))
2661  {
2662  const beans::PropertyValue* pProperties = rToken.getConstArray();
2663  const sal_Int32 nProperties = rToken.getLength();
2664  //create an invalid token
2665  SwFormToken aToken(TOKEN_END);
2666  for(sal_Int32 j = 0; j < nProperties; j++)
2667  {
2668  if ( pProperties[j].Name == "TokenType" )
2669  {
2670  const OUString sTokenType =
2671  lcl_AnyToType<OUString>(pProperties[j].Value);
2672  for (TokenType_ const* pTokenType = g_TokenTypes;
2673  pTokenType->pName; ++pTokenType)
2674  {
2675  if (sTokenType.equalsAscii(pTokenType->pName))
2676  {
2677  aToken.eTokenType = pTokenType->eTokenType;
2678  break;
2679  }
2680  }
2681  }
2682  else if ( pProperties[j].Name == "CharacterStyleName" )
2683  {
2684  OUString sCharStyleName;
2686  lcl_AnyToType<OUString>(pProperties[j].Value),
2687  sCharStyleName,
2689  aToken.sCharStyleName = sCharStyleName;
2691  sCharStyleName, SwGetPoolIdFromName::ChrFmt );
2692  }
2693  else if ( pProperties[j].Name == "TabStopRightAligned" )
2694  {
2695  const bool bRight = lcl_AnyToType<bool>(pProperties[j].Value);
2696  aToken.eTabAlign = bRight ?
2697  SvxTabAdjust::End : SvxTabAdjust::Left;
2698  }
2699  else if ( pProperties[j].Name == "TabStopPosition" )
2700  {
2701  sal_Int32 nPosition = 0;
2702  if (!(pProperties[j].Value >>= nPosition))
2703  {
2704  throw lang::IllegalArgumentException();
2705  }
2706  nPosition = o3tl::toTwips(nPosition, o3tl::Length::mm100);
2707  if(nPosition < 0)
2708  {
2709  throw lang::IllegalArgumentException();
2710  }
2711  aToken.nTabStopPosition = nPosition;
2712  }
2713  else if ( pProperties[j].Name == "TabStopFillCharacter" )
2714  {
2715  const OUString sFillChar =
2716  lcl_AnyToType<OUString>(pProperties[j].Value);
2717  if (sFillChar.getLength() > 1)
2718  {
2719  throw lang::IllegalArgumentException();
2720  }
2721  aToken.cTabFillChar =
2722  sFillChar.isEmpty() ? ' ' : sFillChar[0];
2723  }
2724  else if ( pProperties[j].Name == "Text" )
2725  {
2726  aToken.sText = lcl_AnyToType<OUString>(pProperties[j].Value);
2727  }
2728  else if ( pProperties[j].Name == "ChapterFormat" )
2729  {
2730  sal_Int16 nFormat = lcl_AnyToType<sal_Int16>(pProperties[j].Value);
2731  switch(nFormat)
2732  {
2733  case text::ChapterFormat::NUMBER:
2734  nFormat = CF_NUMBER;
2735  break;
2737  nFormat = CF_TITLE;
2738  break;
2739  case text::ChapterFormat::NAME_NUMBER:
2740  nFormat = CF_NUM_TITLE;
2741  break;
2742  case text::ChapterFormat::NO_PREFIX_SUFFIX:
2743  nFormat = CF_NUMBER_NOPREPST;
2744  break;
2745  case text::ChapterFormat::DIGIT:
2746  nFormat = CF_NUM_NOPREPST_TITLE;
2747  break;
2748  default:
2749  throw lang::IllegalArgumentException();
2750  }
2751  aToken.nChapterFormat = nFormat;
2752  }
2753 // #i53420#
2754  else if ( pProperties[j].Name == "ChapterLevel" )
2755  {
2756  const sal_Int16 nLevel = lcl_AnyToType<sal_Int16>(pProperties[j].Value);
2757  if( nLevel < 1 || nLevel > MAXLEVEL )
2758  {
2759  throw lang::IllegalArgumentException();
2760  }
2761  aToken.nOutlineLevel = nLevel;
2762  }
2763  else if ( pProperties[j].Name == "BibliographyDataField" )
2764  {
2765  sal_Int16 nType = 0;
2766  pProperties[j].Value >>= nType;
2767  if(nType < 0 || nType > text::BibliographyDataField::LOCAL_URL)
2768  {
2769  lang::IllegalArgumentException aExcept;
2770  aExcept.Message = "BibliographyDataField - wrong value";
2771  aExcept.ArgumentPosition = static_cast< sal_Int16 >(j);
2772  throw aExcept;
2773  }
2774  aToken.nAuthorityField = nType;
2775  }
2776  // #i21237#
2777  else if ( pProperties[j].Name == "WithTab" )
2778  {
2779  aToken.bWithTab = lcl_AnyToType<bool>(pProperties[j].Value);
2780  }
2781 
2782  }
2783  //exception if wrong TokenType
2784  if(TOKEN_END <= aToken.eTokenType )
2785  {
2786  throw lang::IllegalArgumentException();
2787  }
2788  // set TokenType from TOKEN_ENTRY_TEXT to TOKEN_ENTRY if it is
2789  // not a content index
2790  if(TOKEN_ENTRY_TEXT == aToken.eTokenType &&
2791  (TOX_CONTENT != rTOXBase.GetType()))
2792  {
2793  aToken.eTokenType = TOKEN_ENTRY;
2794  }
2795 // #i53420#
2796 // check for chapter format allowed values if it was TOKEN_ENTRY_NO type
2797 // only allowed value are CF_NUMBER and CF_NUM_NOPREPST_TITLE
2798 // reading from file
2799  if( TOKEN_ENTRY_NO == aToken.eTokenType )
2800  {
2801  switch(aToken.nChapterFormat)
2802  {
2803  case CF_NUMBER:
2804  case CF_NUM_NOPREPST_TITLE:
2805  break;
2806  default:
2807  throw lang::IllegalArgumentException();
2808  }
2809  }
2810 
2811  if (rTOXBase.GetType() == TOX_CONTENT)
2812  {
2813  if (aToken.eTokenType == TOKEN_LINK_START && aToken.sCharStyleName.isEmpty())
2814  {
2815  aToken.sCharStyleName = SwResId(STR_POOLCHR_TOXJUMP);
2816  }
2817  }
2818 
2819  sPattern.append(aToken.GetString());
2820  }
2821  SwForm aForm(rTOXBase.GetTOXForm());
2822  aForm.SetPattern(o3tl::narrowing<sal_uInt16>(nIndex), sPattern.makeStringAndClear());
2823  rTOXBase.SetTOXForm(aForm);
2824 }
2825 
2826 sal_Int32 SAL_CALL
2828 {
2829  SolarMutexGuard aGuard;
2830 
2831  const sal_Int32 nRet = m_xParent->m_pImpl->GetFormMax();
2832  return nRet;
2833 }
2834 
2835 uno::Any SAL_CALL
2837 {
2838  SolarMutexGuard aGuard;
2839 
2840  SwTOXBase & rTOXBase( m_xParent->m_pImpl->GetTOXSectionOrThrow() );
2841 
2842  if ((nIndex < 0) || (nIndex > rTOXBase.GetTOXForm().GetFormMax()))
2843  {
2844  throw lang::IndexOutOfBoundsException();
2845  }
2846 
2847  // #i21237#
2848  SwFormTokens aPattern = rTOXBase.GetTOXForm().
2849  GetPattern(o3tl::narrowing<sal_uInt16>(nIndex));
2850 
2851  sal_Int32 nTokenCount = 0;
2852  uno::Sequence< beans::PropertyValues > aRetSeq;
2853  OUString aProgCharStyle;
2854  for(const SwFormToken& aToken : aPattern) // #i21237#
2855  {
2856  nTokenCount++;
2857  aRetSeq.realloc(nTokenCount);
2858  beans::PropertyValues* pTokenProps = aRetSeq.getArray();
2859 
2860  uno::Sequence< beans::PropertyValue >& rCurTokenSeq =
2861  pTokenProps[nTokenCount-1];
2863  aToken.sCharStyleName,
2864  aProgCharStyle,
2866  switch(aToken.eTokenType)
2867  {
2868  case TOKEN_ENTRY_NO:
2869  {
2870 // #i53420#
2871 // writing to file (from doc to properties)
2872  sal_Int32 nElements = 2;
2873  sal_Int32 nCurrentElement = 0;
2874 
2875  // check for default value
2876  if (aToken.nChapterFormat != CF_NUMBER)
2877  {
2878  nElements++;//we need the element
2879  }
2880  if( aToken.nOutlineLevel != MAXLEVEL )
2881  {
2882  nElements++;
2883  }
2884 
2885  rCurTokenSeq.realloc( nElements );
2886 
2887  beans::PropertyValue* pArr = rCurTokenSeq.getArray();
2888 
2889  pArr[nCurrentElement].Name = "TokenType";
2890  pArr[nCurrentElement++].Value <<=
2891  OUString("TokenEntryNumber");
2892 
2893  pArr[nCurrentElement].Name = "CharacterStyleName";
2894  pArr[nCurrentElement++].Value <<= aProgCharStyle;
2895  if( aToken.nChapterFormat != CF_NUMBER )
2896  {
2897  pArr[nCurrentElement].Name = "ChapterFormat";
2898  sal_Int16 nVal;
2899 // the allowed values for chapter format, when used as entry number,
2900 // are CF_NUMBER and CF_NUM_NOPREPST_TITLE only, all else forced to
2901 //CF_NUMBER
2902  switch(aToken.nChapterFormat)
2903  {
2904  default:
2905  case CF_NUMBER:
2906  nVal = text::ChapterFormat::NUMBER;
2907  break;
2908  case CF_NUM_NOPREPST_TITLE:
2909  nVal = text::ChapterFormat::DIGIT;
2910  break;
2911  }
2912  pArr[nCurrentElement++].Value <<= nVal;
2913  }
2914 
2915  // only a ChapterLevel != MAXLEVEL is registered
2916  if (aToken.nOutlineLevel != MAXLEVEL)
2917  {
2918  pArr[nCurrentElement].Name = "ChapterLevel";
2919  pArr[nCurrentElement].Value <<= aToken.nOutlineLevel;
2920  }
2921  }
2922  break;
2923  case TOKEN_ENTRY: // no difference between Entry and Entry Text
2924  case TOKEN_ENTRY_TEXT:
2925  {
2926  rCurTokenSeq.realloc( 2 );
2927  beans::PropertyValue* pArr = rCurTokenSeq.getArray();
2928 
2929  pArr[0].Name = "TokenType";
2930  pArr[0].Value <<= OUString("TokenEntryText");
2931 
2932  pArr[1].Name = "CharacterStyleName";
2933  pArr[1].Value <<= aProgCharStyle;
2934  }
2935  break;
2936  case TOKEN_TAB_STOP:
2937  {
2938  rCurTokenSeq.realloc(5); // #i21237#
2939  beans::PropertyValue* pArr = rCurTokenSeq.getArray();
2940 
2941  pArr[0].Name = "TokenType";
2942  pArr[0].Value <<= OUString("TokenTabStop");
2943 
2944  if(SvxTabAdjust::End == aToken.eTabAlign)
2945  {
2946  pArr[1].Name = "TabStopRightAligned";
2947  pArr[1].Value <<= true;
2948  }
2949  else
2950  {
2951  pArr[1].Name = "TabStopPosition";
2952  sal_Int32 nPos = convertTwipToMm100(aToken.nTabStopPosition);
2953  if(nPos < 0)
2954  nPos = 0;
2955  pArr[1].Value <<= nPos;
2956  }
2957  pArr[2].Name = "TabStopFillCharacter";
2958  pArr[2].Value <<= OUString(aToken.cTabFillChar);
2959  pArr[3].Name = "CharacterStyleName";
2960  pArr[3].Value <<= aProgCharStyle;
2961  // #i21237#
2962  pArr[4].Name = "WithTab";
2963  pArr[4].Value <<= aToken.bWithTab;
2964  }
2965  break;
2966  case TOKEN_TEXT:
2967  {
2968  rCurTokenSeq.realloc( 3 );
2969  beans::PropertyValue* pArr = rCurTokenSeq.getArray();
2970 
2971  pArr[0].Name = "TokenType";
2972  pArr[0].Value <<= OUString("TokenText");
2973 
2974  pArr[1].Name = "CharacterStyleName";
2975  pArr[1].Value <<= aProgCharStyle;
2976 
2977  pArr[2].Name = "Text";
2978  pArr[2].Value <<= aToken.sText;
2979  }
2980  break;
2981  case TOKEN_PAGE_NUMS:
2982  {
2983  rCurTokenSeq.realloc( 2 );
2984  beans::PropertyValue* pArr = rCurTokenSeq.getArray();
2985 
2986  pArr[0].Name = "TokenType";
2987  pArr[0].Value <<= OUString("TokenPageNumber");
2988 
2989  pArr[1].Name = "CharacterStyleName";
2990  pArr[1].Value <<= aProgCharStyle;
2991  }
2992  break;
2993  case TOKEN_CHAPTER_INFO:
2994  {
2995  rCurTokenSeq.realloc( 4 );
2996  beans::PropertyValue* pArr = rCurTokenSeq.getArray();
2997 
2998  pArr[0].Name = "TokenType";
2999  pArr[0].Value <<= OUString("TokenChapterInfo");
3000 
3001  pArr[1].Name = "CharacterStyleName";
3002  pArr[1].Value <<= aProgCharStyle;
3003 
3004  pArr[2].Name = "ChapterFormat";
3005  sal_Int16 nVal = text::ChapterFormat::NUMBER;
3006  switch(aToken.nChapterFormat)
3007  {
3008  case CF_NUMBER:
3009  nVal = text::ChapterFormat::NUMBER;
3010  break;
3011  case CF_TITLE:
3013  break;
3014  case CF_NUM_TITLE:
3015  nVal = text::ChapterFormat::NAME_NUMBER;
3016  break;
3017  case CF_NUMBER_NOPREPST:
3018  nVal = text::ChapterFormat::NO_PREFIX_SUFFIX;
3019  break;
3020  case CF_NUM_NOPREPST_TITLE:
3021  nVal = text::ChapterFormat::DIGIT;
3022  break;
3023  }
3024  pArr[2].Value <<= nVal;
3025 // #i53420#
3026  pArr[3].Name = "ChapterLevel";
3027  pArr[3].Value <<= aToken.nOutlineLevel;
3028  }
3029  break;
3030  case TOKEN_LINK_START:
3031  {
3032  rCurTokenSeq.realloc( 2 );
3033  beans::PropertyValue* pArr = rCurTokenSeq.getArray();
3034 
3035  pArr[0].Name = "TokenType";
3036  pArr[0].Value <<=
3037  OUString("TokenHyperlinkStart");
3038  pArr[1].Name = "CharacterStyleName";
3039  pArr[1].Value <<= aProgCharStyle;
3040  }
3041  break;
3042  case TOKEN_LINK_END:
3043  {
3044  rCurTokenSeq.realloc( 1 );
3045  beans::PropertyValue* pArr = rCurTokenSeq.getArray();
3046 
3047  pArr[0].Name = "TokenType";
3048  pArr[0].Value <<=
3049  OUString("TokenHyperlinkEnd");
3050  }
3051  break;
3052  case TOKEN_AUTHORITY:
3053  {
3054  rCurTokenSeq.realloc( 3 );
3055  beans::PropertyValue* pArr = rCurTokenSeq.getArray();
3056 
3057  pArr[0].Name = "TokenType";
3058  pArr[0].Value <<=
3059  OUString("TokenBibliographyDataField");
3060 
3061  pArr[1].Name = "CharacterStyleName";
3062  pArr[1].Value <<= aProgCharStyle;
3063 
3064  pArr[2].Name = "BibliographyDataField";
3065  pArr[2].Value <<= sal_Int16(aToken.nAuthorityField);
3066  }
3067  break;
3068 
3069  default:
3070  ;
3071  }
3072  }
3073 
3074  uno::Any aRet;
3075  aRet <<= aRetSeq;
3076  return aRet;
3077 }
3078 
3079 uno::Type SAL_CALL
3081 {
3083 }
3084 
3085 sal_Bool SAL_CALL
3087 {
3088  return true;
3089 }
3090 
3091 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
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:2275
const SwEndNode * EndOfSectionNode() const
Definition: node.hxx:686
std::vector< SwFormToken > SwFormTokens
Vector of tokens.
Definition: tox.hxx:286
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:2547
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:180
#define WID_TOC_PARAGRAPH_OUTLINE_LEVEL
Definition: unomap.hxx:225
std::vector< SwSection * > SwSections
Definition: section.hxx:41
SAL_DLLPRIVATE css::uno::WeakReference< css::text::XDocumentIndexMark > const & GetXTOXMark() const
Definition: tox.hxx:163
#define WID_IS_COMMA_SEPARATED
Definition: unomap.hxx:210
SwTOIOptions
Definition: tox.hxx:386
bool GoInContent(SwPaM &rPam, SwMoveFnCollection const &fnMove)
Definition: pam.cxx:970
::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:3080
TokenAccess_Impl(SwXDocumentIndex &rParentIdx)
Definition: unoidx.cxx:2589
SwTOXElement GetCreateType() const
Definition: tox.hxx:701
virtual sal_Bool SAL_CALL hasElements() override
Definition: unoidx.cxx:3086
virtual void SAL_CALL setMarkEntry(const OUString &rIndexEntry) override
Definition: unoidx.cxx:1718
SwSectionFormat * m_pFormat
Definition: unoidx.cxx:295
#define WID_PARA_SEP
Definition: unomap.hxx:199
virtual css::uno::Any SAL_CALL getByName(const OUString &rName) override
Definition: unoidx.cxx:2377
constexpr auto toTwips(N number, Length from)
#define WID_CREATE_FROM_STAR_DRAW
Definition: unomap.hxx:195
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:2645
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:1078
#define WID_USE_COMBINED_ENTRIES
Definition: unomap.hxx:173
static void lcl_AnyToBitMask(uno::Any const &rValue, T &rBitMask, const T nBit)
Definition: unoidx.cxx:84
sal_uInt16 nOutlineLevel
Definition: tox.hxx:252
virtual sal_Int32 SAL_CALL getCount() override
Definition: unoidx.cxx:2325
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:592
void InsertTOXMark(const SwTOXType &rTOXType, SwTOXMark &rMark, SwPaM &rPam, SwXTextCursor const *const pTextCursor)
Definition: unoidx.cxx:1887
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:447
SwTOOElements
Definition: tox.hxx:409
Definition: tox.hxx:313
SwNodeIndex nNode
Definition: pam.hxx:38
const SwTOXType * InsertTOXType(const SwTOXType &rTyp)
Definition: doctxm.cxx:628
OUString sCharStyleName
#define WID_CREATE_FROM_STAR_CALC
Definition: unomap.hxx:194
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:1547
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:182
#define PROPERTY_MAP_INDEX_CNTNT
Definition: unomap.hxx:42
SAL_DLLPRIVATE void SetXTOXMark(css::uno::Reference< css::text::XDocumentIndexMark > const &xMark)
Definition: tox.hxx:165
std::vector< SwTOXMark * > SwTOXMarks
Definition: tox.hxx:46
#define WID_IS_RELATIVE_TABSTOPS
Definition: unomap.hxx:212
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:672
const SwPosition * GetMark() const
Definition: pam.hxx:210
void CollectTextMarks(SwTOXMarks &rMarks) const
Definition: tox.hxx:184
#define PROPERTY_MAP_INDEX_IDX
Definition: unomap.hxx:43
#define TOX_STYLE_DELIMITER
Definition: tox.hxx:422
sal_Int64 n
css::uno::Reference< css::frame::XModel3 > GetModel() const
#define WID_PARA_LEV1
Definition: unomap.hxx:200
Definition: doc.hxx:188
only chapter number without post-/prefix
Definition: chpfld.hxx:35
#define WID_USER_IDX_NAME
Definition: unomap.hxx:197
virtual void SAL_CALL update() override
Definition: unoidx.cxx:512
constexpr sal_uInt8 MAXLEVEL
Definition: swtypes.hxx:93
#define WID_MAIN_ENTRY
Definition: unomap.hxx:168
SwSectionFormat * GetSectionFormat() const
Definition: unoidx.cxx:330
bool IsAtEndOfMeta() const
Definition: unoobj.cxx:796
#define WID_CREATE_FROM_TABLES
Definition: unomap.hxx:186
#define WID_USE_P_P
Definition: unomap.hxx:175
::osl::Mutex m_Mutex
Definition: unoidx.cxx:294
SwNode & GetNode() const
Definition: ndindex.hxx:121
#define WID_PARA_LEV5
Definition: unomap.hxx:204
virtual void SAL_CALL removeVetoableChangeListener(const OUString &rPropertyName, const css::uno::Reference< css::beans::XVetoableChangeListener > &xListener) override
Definition: unoidx.cxx:2291
#define WID_PRIMARY_KEY
Definition: unomap.hxx:161
SwSectionFormat * GetFormat()
Definition: section.hxx:337
sal_uInt16 GetFormMax() const
Definition: tox.hxx:683
const TOXTypes m_eTOXType
Definition: unoidx.cxx:301
OUString Name
const SwTOXType * GetTOXType() const
Definition: tox.hxx:576
virtual css::uno::Any SAL_CALL getByIndex(sal_Int32 nIndex) override
Definition: unoidx.cxx:2347
static const SwAttrSet & GetTOXBaseAttrSet(const SwTOXBase &rTOX)
Definition: doctxm.cxx:467
#define USER_AND_SUFFIXLEN
Definition: unoidx.cxx:126
virtual uno::Any SAL_CALL getByIndex(sal_Int32 nIndex) override
Definition: unoidx.cxx:2836
virtual uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
Definition: unoidx.cxx:2499
static void lcl_ConvertTOUNameToUserName(OUString &rTmp)
Definition: unoidx.cxx:145
sal_uInt16 nPoolId
Definition: tox.hxx:249
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:2298
constexpr OUStringLiteral cUserDefined
Definition: unoidx.cxx:123
bool bWithTab
Definition: tox.hxx:255
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:254
virtual OUString SAL_CALL getMarkEntry() override
Definition: unoidx.cxx:1699
static css::uno::Reference< css::text::XTextSection > CreateXTextSection(SwSectionFormat *const pFormat, const bool bIndexHeader=false)
Definition: unosect.cxx:196
virtual css::uno::Reference< css::text::XTextRange > SAL_CALL getAnchor() override
Definition: unoidx.cxx:1342
Array of Undo-history.
Definition: docary.hxx:192
virtual css::uno::Sequence< OUString > SAL_CALL getElementNames() override
Definition: unoidx.cxx:2405
constexpr auto convertTwipToMm100(N n)
virtual sal_Bool SAL_CALL supportsService(const OUString &rServiceName) override
Definition: unoidx.cxx:1664
OUString SwResId(TranslateId aId)
Definition: swmodule.cxx:165
Value
SwXDocumentIndexMark & m_rThis
Definition: unoidx.cxx:1482
const SwDoc & GetDoc() const
Definition: unoobj2.cxx:767
const SwTOXType * GetTOXType() const
Definition: tox.hxx:698
virtual void SAL_CALL attach(const css::uno::Reference< css::text::XTextRange > &xTextRange) override
Definition: unoidx.cxx:1751
#define WID_LEVEL_FORMAT
Definition: unomap.hxx:181
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:952
A wrapper around SfxPoolItem to store the start position of (usually) a text portion, with an optional end.
Definition: txatbase.hxx:41
bool IsValid() const
Definition: unocoll.hxx:57
OUString sText
Definition: tox.hxx:245
int nCount
virtual ::sfx2::Metadatable * GetCoreObject() override
Definition: unoidx.cxx:1447
virtual sal_Int32 SAL_CALL getCount() override
Definition: unoidx.cxx:2827
bool CPPUHELPER_DLLPUBLIC supportsService(css::lang::XServiceInfo *implementation, rtl::OUString const &name)
sal_Int32 GetStart() const
Definition: txatbase.hxx:86
static SW_DLLPUBLIC sal_uInt16 GetPoolIdFromUIName(const OUString &rName, SwGetPoolIdFromName)
virtual void Notify(const SfxHint &) override
Definition: unoidx.cxx:1585
#define WID_USE_DASH
Definition: unomap.hxx:176
virtual OUString SAL_CALL getImplementationName() override
Definition: unoidx.cxx:2487
#define WID_IDX_SORT_ALGORITHM
Definition: unomap.hxx:217
bool DeleteTOX(const SwTOXBase &rTOXBase, bool bDelNodes)
Delete table of contents.
Definition: doctxm.cxx:523
sal_uInt16 GetTOXTypeCount(TOXTypes eTyp) const
Manage table of content types.
Definition: doctxm.cxx:610
#define WID_PARA_LEV7
Definition: unomap.hxx:206
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:582
::comphelper::OInterfaceContainerHelper3< css::lang::XEventListener > m_EventListeners
Definition: unoidx.cxx:1490
void Normalize(bool bPointFirst=true)
Normalizes PaM, i.e.
Definition: pam.cxx:541
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:216
#define WID_TAB_IN_TOC
Definition: unomap.hxx:184
void UpdatePageNum()
Calculate PageNumber and insert after formatting.
Definition: doctxm.cxx:1586
void EndListeningAll()
const OUString & GetAlternativeText() const
Definition: tox.hxx:570
#define WID_PARA_LEV6
Definition: unomap.hxx:205
PaM is Point and Mark: a selection of the document model.
Definition: pam.hxx:137
static OUString GetProviderName(SwServiceType nObjectType)
Definition: unocoll.cxx:471
OUString GetString() const
Definition: tox.cxx:655
bool Move(SwMoveFnCollection const &fnMove=fnMoveForward, SwGoInDoc fnGo=GoInContent)
Movement of cursor.
Definition: pam.cxx:504
virtual OUString SAL_CALL getImplementationName() override
Definition: unoidx.cxx:2600
#define WID_TOC_NEWLINE
Definition: unomap.hxx:224
#define WID_CREATE_FROM_STAR_MATH
Definition: unomap.hxx:190
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:1974
virtual sal_Bool SAL_CALL supportsService(const OUString &rServiceName) override
Definition: unoidx.cxx:2493
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:1670
#define WID_IDX_NAME
Definition: unomap.hxx:218
virtual sal_Int64 SAL_CALL getSomething(const css::uno::Sequence< sal_Int8 > &rIdentifier) override
Definition: unoidx.cxx:1653
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:598
virtual OUString SAL_CALL getServiceName() override
Definition: unoidx.cxx:487
SwTOXElement
Definition: tox.hxx:365
#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:610
FormTokenType eTokenType
Definition: tox.hxx:248
virtual sal_Bool SAL_CALL supportsService(const OUString &rServiceName) override
Definition: unoidx.cxx:2313
SwEditShell const * GetEditShell() const
Definition: doccorr.cxx:328
OUString sCharStyleName
Definition: tox.hxx:246
#define WID_IDX_CONTENT_SECTION
Definition: unomap.hxx:214
virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo() override
Definition: unoidx.cxx:518
#define WID_CREATE_FROM_LABELS
Definition: unomap.hxx:170
#define WID_USE_UPPER_CASE
Definition: unomap.hxx:177
uno::WeakReference< container::XIndexReplace > m_wStyleAccess
Definition: unoidx.cxx:305
#define WID_CREATE_FROM_MARKS
Definition: unomap.hxx:166
::cppu::WeakImplHelper< lang::XServiceInfo, container::XIndexReplace > SwXDocumentIndexStyleAccess_Base
Definition: unoidx.cxx:167
virtual uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
Definition: unoidx.cxx:2612
SetAttrMode
Definition: swtypes.hxx:133
void Exchange()
Definition: pam.cxx:492
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:616
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:2578
size_t size() const
Definition: docary.hxx:88
unsigned char sal_Bool
static css::uno::Reference< css::text::XDocumentIndexMark > CreateXDocumentIndexMark(SwDoc &rDoc, SwTOXMark *pMark, TOXTypes eType=TOX_INDEX)
Definition: unoidx.cxx:1614
virtual OUString SAL_CALL getImplementationName() override
Definition: unoidx.cxx:2308
virtual sal_Bool SAL_CALL supportsService(const OUString &rServiceName) override
Definition: unoidx.cxx:2605
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:690
static const css::uno::Sequence< sal_Int8 > & getUnoTunnelId()
Definition: unoidx.cxx:1646
virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo() override
Definition: unoidx.cxx:2002
#define WID_USE_KEY_AS_ENTRY
Definition: unomap.hxx:172
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:251
Marks a node in the document model.
Definition: ndindex.hxx:32
css::uno::Type const & get()
#define WID_INDEX_MARKS
Definition: unomap.hxx:211
sal_uInt16 nAuthorityField
Definition: tox.hxx:253
virtual void SAL_CALL setPropertyValue(const OUString &rPropertyName, const css::uno::Any &rValue) override
Definition: unoidx.cxx:2031
#define WID_SECONDARY_KEY
Definition: unomap.hxx:162
#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:123
bool StartListening(SvtBroadcaster &rBroadcaster)
#define WID_CREATE_FROM_STAR_CHART
Definition: unomap.hxx:193
static sal_uInt16 GetFormMaxLevel(TOXTypes eType)
Definition: tox.cxx:443
#define WID_PARA_LEV3
Definition: unomap.hxx:202
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:169
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:196
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:167
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:222
#define WID_PRIMARY_KEY_READING
Definition: unomap.hxx:221
::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:102
const char cUserSuffix[]
Definition: unoidx.cxx:124
uno::WeakReference< uno::XInterface > m_wThis
Definition: unoidx.cxx:1487
const SwTextNode & GetTextNode() const
Definition: txttxmrk.hxx:49
virtual css::uno::Reference< css::text::XTextRange > SAL_CALL getAnchor() override
Definition: unoidx.cxx:1940
#define WID_HIDE_TABLEADER_PAGENUMBERS
Definition: unomap.hxx:183
#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:154
std::unique_ptr< SwDocIndexDescriptorProperties_Impl > m_pProps
Definition: unoidx.cxx:304
bool IsRelTabPos() const
Definition: tox.hxx:344
virtual void SAL_CALL removeEventListener(const css::uno::Reference< css::lang::XEventListener > &xListener) override
Definition: unoidx.cxx:1994
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:213
#define WID_TOC_BOOKMARK
Definition: unomap.hxx:223
SwTwips nTabStopPosition
Definition: tox.hxx:247
void Update(const SfxItemSet *pAttr=nullptr, SwRootFrame const *pLayout=nullptr, const bool _bNewTOX=false)
Collect table of contents content.
Definition: doctxm.cxx:768
#define WID_LEVEL
Definition: unomap.hxx:165
virtual css::uno::Type SAL_CALL getElementType() override
Definition: unoidx.cxx:2465
virtual void SAL_CALL replaceByIndex(sal_Int32 Index, const uno::Any &rElement) override
Definition: unoidx.cxx:2641
virtual const SwViewShell * GetCurrentViewShell() const =0
Returns the layout set at the document.
virtual sal_Bool SAL_CALL hasElements() override
Definition: unoidx.cxx:2584
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:2283
static void lcl_ConvertTOUNameToProgrammaticName(OUString &rTmp)
Definition: unoidx.cxx:128
OUString const & GetStyleNames(sal_uInt16 nLevel) const
Definition: tox.hxx:519
#define WID_CREATE_FROM_TEXT_FRAMES
Definition: unomap.hxx:187
bool IsCommaSeparated() const
Definition: tox.hxx:347
static void FillProgName(const OUString &rName, OUString &rFillName, SwGetPoolIdFromName)
virtual ~TokenAccess_Impl() override
Definition: unoidx.cxx:2595
virtual css::uno::Any SAL_CALL getPropertyValue(const OUString &rPropertyName) override
Definition: unoidx.cxx:2160
static sal_uInt16 lcl_TypeToPropertyMap_Index(const TOXTypes eType)
Definition: unoidx.cxx:275
#define WID_TEXT_READING
Definition: unomap.hxx:220
#define WID_PARA_LEV9
Definition: unomap.hxx:208
void SetBookmarkName(const OUString &bName)
Definition: tox.hxx:587
const sal_Int32 * End() const
Definition: txatbase.hxx:152
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:209
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:604
#define WID_PARA_HEAD
Definition: unomap.hxx:198
TOXTypes GetType() const
Definition: tox.hxx:693
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:1489
#define WID_PARA_LEV2
Definition: unomap.hxx:201
#define WID_CREATE_FROM_EMBEDDED_OBJECTS
Definition: unomap.hxx:189
#define WID_IDX_TITLE
Definition: unomap.hxx:164
#define PROPERTY_MAP_PARAGRAPH_EXTENSIONS
Definition: unomap.hxx:51
virtual ~StyleAccess_Impl() override
Definition: unoidx.cxx:2482
static const css::uno::Sequence< sal_Int8 > & getUnoTunnelId()
Definition: unoidx.cxx:428
SvxTabAdjust eTabAlign
Definition: tox.hxx:250
#define WID_PARA_LEV8
Definition: unomap.hxx:207
#define WID_PROTECTED
Definition: unomap.hxx:191
void disposeAndClear(const css::lang::EventObject &rEvt)
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:188
SwDoc & GetDoc() const
Definition: pam.hxx:244
SwXDocumentIndex(SwTOXBaseSection &, SwDoc &)
Definition: unoidx.cxx:384
virtual ~SwXDocumentIndexMark() override
Definition: unoidx.cxx:1609
#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:478
SectionType GetType() const
Definition: section.hxx:170
const SwTOXType * GetTOXType(TOXTypes eTyp, sal_uInt16 nId) const
Definition: doctxm.cxx:619
#define WID_LABEL_DISPLAY_TYPE
Definition: unomap.hxx:179
#define WID_USE_ALPHABETICAL_SEPARATORS
Definition: unomap.hxx:171
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:2505
const SwForm & GetTOXForm() const
Definition: tox.hxx:713
::sw::UnoImplPtr< Impl > m_pImpl
Definition: unoidx.hxx:61
::std::unique_ptr< XmlIdRegistry_Impl > m_pImpl
SwSection * GetSection() const
Definition: section.cxx:669
#define WID_MAIN_ENTRY_CHARACTER_STYLE_NAME
Definition: unomap.hxx:185
SfxItemPropertySet const & m_rPropSet
Definition: unoidx.cxx:1488
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
Definition: unoidx.cxx:2319
static T lcl_AnyToType(uno::Any const &rVal)
Definition: unoidx.cxx:72
void SetSecondaryKeyReading(const OUString &rStr)
Definition: tox.hxx:622
#define WID_LABEL_CATEGORY
Definition: unomap.hxx:178
#define WID_PARA_LEV4
Definition: unomap.hxx:203
SwSectionFormats & GetSections()
Definition: doc.hxx:1338
virtual sal_Int32 SAL_CALL getCount() override
Definition: unoidx.cxx:2541
virtual sal_Bool SAL_CALL supportsService(const OUString &rServiceName) override
Definition: unoidx.cxx:447
#define WID_IDX_HEADER_SECTION
Definition: unomap.hxx:215
SfxItemPropertySet const & m_rPropSet
Definition: unoidx.cxx:300
struct _ADOIndex Index
void SetMainEntry(bool bSet)
Definition: tox.hxx:156
SwXDocumentIndexMark(SwDoc &rDoc, const SwTOXType &rType, const SwTOXMark &rMark)
Definition: unoidx.cxx:1602
virtual ~SwXDocumentIndex() override
Definition: unoidx.cxx:396
FormTokenType
Definition: tox.hxx:228
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:2476
virtual OUString SAL_CALL getImplementationName() override
Definition: unoidx.cxx:1659
virtual void SAL_CALL addPropertyChangeListener(const OUString &rPropertyName, const css::uno::Reference< css::beans::XPropertyChangeListener > &xListener) override
Definition: unoidx.cxx:2267
const SfxItemPropertyMapEntry * GetPropertyMapEntries(sal_uInt16 PropertyId)
Definition: unomap.cxx:71
sal_uInt16 nPos
SwTOXType * GetTOXType() const
Definition: unoidx.cxx:1534
#define WID_ALT_TEXT
Definition: unomap.hxx:163
::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:2440
const struct TokenType_ g_TokenTypes[]
Definition: unoidx.cxx:2626
virtual sal_Bool SAL_CALL hasElements() override
Definition: unoidx.cxx:2471
static const OUString & GetSpecialExtraUIName(const OUString &rExtraProgName)
only the title
Definition: chpfld.hxx:33
virtual void SAL_CALL addEventListener(const css::uno::Reference< css::lang::XEventListener > &xListener) override
Definition: unoidx.cxx:1986
#define WID_IS_CASE_SENSITIVE
Definition: unomap.hxx:174
#define PROPERTY_MAP_INDEX_TABLES
Definition: unomap.hxx:54
virtual ~SwXDocumentIndexes() override
Definition: unoidx.cxx:2303