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  {
638  rTOXBase.SetEntryTypeName(lcl_AnyToType<OUString>(rValue));
640  rTOXBase.SetCreate(nCreate);
641  }
642  break;
644  lcl_AnyToBitMask(rValue, nCreate, SwTOXElement::Mark);
645  break;
648  break;
651  break;
652  case WID_TAB_IN_TOC:
653  lcl_AnyToBitMask(rValue, nCreate, SwTOXElement::TableInToc);
654  break;
655  case WID_TOC_NEWLINE:
656  lcl_AnyToBitMask(rValue, nCreate, SwTOXElement::Newline);
657  break;
658 // case WID_PARAGRAPH_STYLE_NAMES :OSL_FAIL("not implemented")
659 // break;
662  break ;
664  rTOXBase.SetFromChapter(lcl_AnyToType<bool>(rValue));
665  break;
667  rTOXBase.SetFromObjectNames(! lcl_AnyToType<bool>(rValue));
668  break;
669  case WID_PROTECTED:
670  {
671  bool bSet = lcl_AnyToType<bool>(rValue);
672  rTOXBase.SetProtected(bSet);
673  if (pSectionFormat)
674  {
675  static_cast<SwTOXBaseSection &>(rTOXBase).SetProtect(bSet);
676  }
677  }
678  break;
680  lcl_AnyToBitMask(rValue, nTOIOptions,
682  break;
684  lcl_AnyToBitMask(rValue, nTOIOptions,
686  break;
688  lcl_AnyToBitMask(rValue, nTOIOptions,
690  break;
692  lcl_AnyToBitMask(rValue, nTOIOptions,
694  break;
695  case WID_USE_P_P:
696  lcl_AnyToBitMask(rValue, nTOIOptions, SwTOIOptions::FF);
697  break;
698  case WID_USE_DASH:
699  lcl_AnyToBitMask(rValue, nTOIOptions, SwTOIOptions::Dash);
700  break;
701  case WID_USE_UPPER_CASE:
702  lcl_AnyToBitMask(rValue, nTOIOptions,
704  break;
706  bForm = true;
707  aForm.SetCommaSeparated(lcl_AnyToType<bool>(rValue));
708  break;
709  case WID_LABEL_CATEGORY:
710  {
711  // convert file-format/API/external programmatic english name
712  // to internal UI name before usage
713  rTOXBase.SetSequenceName( SwStyleNameMapper::GetSpecialExtraUIName(
714  lcl_AnyToType<OUString>(rValue) ) );
715  }
716  break;
718  {
719  const sal_Int16 nVal = lcl_AnyToType<sal_Int16>(rValue);
720  sal_uInt16 nSet = CAPTION_COMPLETE;
721  switch (nVal)
722  {
723  case text::ReferenceFieldPart::TEXT:
724  nSet = CAPTION_COMPLETE;
725  break;
726  case text::ReferenceFieldPart::CATEGORY_AND_NUMBER:
727  nSet = CAPTION_NUMBER;
728  break;
729  case text::ReferenceFieldPart::ONLY_CAPTION:
730  nSet = CAPTION_TEXT;
731  break;
732  default:
733  throw lang::IllegalArgumentException();
734  }
735  rTOXBase.SetCaptionDisplay(static_cast<SwCaptionDisplay>(nSet));
736  }
737  break;
739  rTOXBase.SetLevelFromChapter(lcl_AnyToType<bool>(rValue));
740  break;
742  {
743  OUString aString;
744  SwStyleNameMapper::FillUIName(lcl_AnyToType<OUString>(rValue),
745  aString, SwGetPoolIdFromName::ChrFmt);
746  rTOXBase.SetMainEntryCharStyle( aString );
747  }
748  break;
750  lcl_AnyToBitMask(rValue, nCreate, SwTOXElement::Table);
751  break;
753  lcl_AnyToBitMask(rValue, nCreate, SwTOXElement::Frame);
754  break;
756  lcl_AnyToBitMask(rValue, nCreate, SwTOXElement::Graphic);
757  break;
759  lcl_AnyToBitMask(rValue, nCreate, SwTOXElement::Ole);
760  break;
762  lcl_AnyToBitMask(rValue, nOLEOptions, SwTOOElements::Math);
763  break;
765  lcl_AnyToBitMask(rValue, nOLEOptions, SwTOOElements::Chart);
766  break;
768  lcl_AnyToBitMask(rValue, nOLEOptions, SwTOOElements::Calc);
769  break;
771  lcl_AnyToBitMask(rValue, nOLEOptions,
773  break;
775  lcl_AnyToBitMask(rValue, nOLEOptions, SwTOOElements::Other);
776  break;
777  case WID_PARA_HEAD:
778  {
779  OUString aString;
780  SwStyleNameMapper::FillUIName( lcl_AnyToType<OUString>(rValue),
782  bForm = true;
783  // Header is on Pos 0
784  aForm.SetTemplate( 0, aString );
785  }
786  break;
788  bForm = true;
789  aForm.SetRelTabPos(lcl_AnyToType<bool>(rValue));
790  break;
791  case WID_PARA_SEP:
792  {
793  OUString aString;
794  bForm = true;
795  SwStyleNameMapper::FillUIName( lcl_AnyToType<OUString>(rValue),
797  aForm.SetTemplate( 1, aString );
798  }
799  break;
801  lcl_AnyToBitMask(rValue, nCreate, SwTOXElement::Template);
802  break;
803 
804  case WID_PARA_LEV1:
805  case WID_PARA_LEV2:
806  case WID_PARA_LEV3:
807  case WID_PARA_LEV4:
808  case WID_PARA_LEV5:
809  case WID_PARA_LEV6:
810  case WID_PARA_LEV7:
811  case WID_PARA_LEV8:
812  case WID_PARA_LEV9:
813  case WID_PARA_LEV10:
814  {
815  bForm = true;
816  // in sdbcx::Index Label 1 begins at Pos 2 otherwise at Pos 1
817  const sal_uInt16 nLPos = rTOXBase.GetType() == TOX_INDEX ? 2 : 1;
818  OUString aString;
819  SwStyleNameMapper::FillUIName( lcl_AnyToType<OUString>(rValue),
821  aForm.SetTemplate(nLPos + pEntry->nWID - WID_PARA_LEV1, aString );
822  }
823  break;
824  default:
825  //this is for items only
826  if (WID_PRIMARY_KEY > pEntry->nWID)
827  {
828  const SwAttrSet& rSet =
829  SwDoc::GetTOXBaseAttrSet(rTOXBase);
830  SfxItemSet aAttrSet(rSet);
831  m_pImpl->m_rPropSet.setPropertyValue(
832  rPropertyName, rValue, aAttrSet);
833 
834  const SwSectionFormats& rSects = m_pImpl->m_pDoc->GetSections();
835  for (size_t i = 0; i < rSects.size(); ++i)
836  {
837  const SwSectionFormat* pTmpFormat = rSects[ i ];
838  if (pTmpFormat == pSectionFormat)
839  {
840  SwSectionData tmpData(
841  static_cast<SwTOXBaseSection&>(rTOXBase));
842  m_pImpl->m_pDoc->UpdateSection(i, tmpData, & aAttrSet);
843  break;
844  }
845  }
846  }
847  }
848  rTOXBase.SetCreate(nCreate);
849  rTOXBase.SetOLEOptions(nOLEOptions);
850  if (rTOXBase.GetTOXType()->GetType() == TOX_INDEX)
851  {
852  rTOXBase.SetOptions(nTOIOptions);
853  }
854  if (bForm)
855  {
856  rTOXBase.SetTOXForm(aForm);
857  }
858 }
859 
860 uno::Any SAL_CALL
861 SwXDocumentIndex::getPropertyValue(const OUString& rPropertyName)
862 {
863  SolarMutexGuard aGuard;
864 
865  uno::Any aRet;
866  SfxItemPropertyMapEntry const*const pEntry =
867  m_pImpl->m_rPropSet.getPropertyMap().getByName(rPropertyName);
868  if (!pEntry)
869  {
870  throw beans::UnknownPropertyException(
871  "Unknown property: " + rPropertyName,
872  static_cast< cppu::OWeakObject * >(this));
873  }
874  // TODO: is this the best approach to tell API clients about the change?
875  if (pEntry->nWID == RES_BACKGROUND && pEntry->nMemberId == MID_GRAPHIC_URL)
876  {
877  throw uno::RuntimeException("Getting GraphicURL property is not supported");
878  }
879 
880  SwSectionFormat *const pSectionFormat( m_pImpl->GetSectionFormat() );
881  SwTOXBase* pTOXBase = nullptr;
882  if (pSectionFormat)
883  {
884  pTOXBase = static_cast<SwTOXBaseSection*>(pSectionFormat->GetSection());
885  }
886  else if (m_pImpl->m_bIsDescriptor)
887  {
888  pTOXBase = &m_pImpl->m_pProps->GetTOXBase();
889  }
890  if(pTOXBase)
891  {
892  const SwTOXElement nCreate = pTOXBase->GetCreateType();
893  const SwTOOElements nOLEOptions = pTOXBase->GetOLEOptions();
894  const SwTOIOptions nTOIOptions =
895  (pTOXBase->GetTOXType()->GetType() == TOX_INDEX)
896  ? pTOXBase->GetOptions()
898  const SwForm& rForm = pTOXBase->GetTOXForm();
899  switch(pEntry->nWID)
900  {
903  if(WID_IDX_CONTENT_SECTION == pEntry->nWID)
904  {
905  const uno::Reference <text::XTextSection> xContentSect =
906  SwXTextSection::CreateXTextSection( pSectionFormat );
907  aRet <<= xContentSect;
908  }
909  else if (pSectionFormat)
910  {
911  SwSections aSectArr;
912  pSectionFormat->GetChildSections(aSectArr,
913  SectionSort::Not, false);
914  for(SwSection* pSect : aSectArr)
915  {
916  if(pSect->GetType() == SectionType::ToxHeader)
917  {
918  const uno::Reference <text::XTextSection> xHeader =
920  pSect->GetFormat() );
921  aRet <<= xHeader;
922  break;
923  }
924  }
925  }
926  break;
927  case WID_IDX_TITLE :
928  {
929  aRet <<= pTOXBase->GetTitle();
930  break;
931  }
932  case WID_IDX_NAME:
933  aRet <<= pTOXBase->GetTOXName();
934  break;
935  case WID_USER_IDX_NAME:
936  {
937  OUString sTmp((!m_pImpl->m_bIsDescriptor)
938  ? pTOXBase->GetTOXType()->GetTypeName()
939  : m_pImpl->m_pProps->GetTypeName());
940  //I18N
942  aRet <<= sTmp;
943  }
944  break;
945  case WID_IDX_LOCALE:
946  aRet <<= LanguageTag(pTOXBase->GetLanguage()).getLocale();
947  break;
949  aRet <<= pTOXBase->GetSortAlgorithm();
950  break;
951  case WID_LEVEL :
952  aRet <<= static_cast<sal_Int16>(pTOXBase->GetLevel());
953  break;
954  case WID_TOC_BOOKMARK :
955  aRet <<= pTOXBase->GetBookmarkName();
956  break;
957  case WID_INDEX_ENTRY_TYPE :
958  aRet <<= pTOXBase->GetEntryTypeName();
959  break;
961  lcl_BitMaskToAny(aRet, nCreate, SwTOXElement::Mark);
962  break;
964  lcl_BitMaskToAny(aRet, nCreate,
966  break;
968  {
969  const bool bRet = pTOXBase->IsFromChapter();
970  aRet <<= bRet;
971  }
972  break;
974  {
975  const bool bRet = ! pTOXBase->IsFromObjectNames();
976  aRet <<= bRet;
977  }
978  break;
979  case WID_PROTECTED:
980  {
981  const bool bRet = pTOXBase->IsProtected();
982  aRet <<= bRet;
983  }
984  break;
986  lcl_BitMaskToAny(aRet, nTOIOptions,
988  break;
990  lcl_BitMaskToAny(aRet, nTOIOptions,
992  break;
994  lcl_BitMaskToAny(aRet, nTOIOptions,
996  break;
998  lcl_BitMaskToAny(aRet, nTOIOptions,
1000  break;
1001  case WID_USE_P_P:
1002  lcl_BitMaskToAny(aRet, nTOIOptions, SwTOIOptions::FF);
1003  break;
1004  case WID_USE_DASH:
1005  lcl_BitMaskToAny(aRet, nTOIOptions, SwTOIOptions::Dash);
1006  break;
1007  case WID_USE_UPPER_CASE:
1008  lcl_BitMaskToAny(aRet, nTOIOptions,
1010  break;
1012  {
1013  const bool bRet = rForm.IsCommaSeparated();
1014  aRet <<= bRet;
1015  }
1016  break;
1017  case WID_LABEL_CATEGORY:
1018  {
1019  // convert internal UI name to
1020  // file-format/API/external programmatic english name
1021  // before usage
1023  pTOXBase->GetSequenceName() );
1024  }
1025  break;
1027  {
1028  sal_Int16 nSet = text::ReferenceFieldPart::TEXT;
1029  switch (pTOXBase->GetCaptionDisplay())
1030  {
1031  case CAPTION_COMPLETE:
1032  nSet = text::ReferenceFieldPart::TEXT;
1033  break;
1034  case CAPTION_NUMBER:
1035  nSet = text::ReferenceFieldPart::CATEGORY_AND_NUMBER;
1036  break;
1037  case CAPTION_TEXT:
1038  nSet = text::ReferenceFieldPart::ONLY_CAPTION;
1039  break;
1040  }
1041  aRet <<= nSet;
1042  }
1043  break;
1045  {
1046  const bool bRet = pTOXBase->IsLevelFromChapter();
1047  aRet <<= bRet;
1048  }
1049  break;
1050  case WID_LEVEL_FORMAT:
1051  {
1052  uno::Reference< container::XIndexReplace > xTokenAccess(
1053  m_pImpl->m_wTokenAccess);
1054  if (!xTokenAccess.is())
1055  {
1056  xTokenAccess = new TokenAccess_Impl(*this);
1057  m_pImpl->m_wTokenAccess = xTokenAccess;
1058  }
1059  aRet <<= xTokenAccess;
1060  }
1061  break;
1063  {
1064  uno::Reference< container::XIndexReplace > xStyleAccess(
1065  m_pImpl->m_wStyleAccess);
1066  if (!xStyleAccess.is())
1067  {
1068  xStyleAccess = new StyleAccess_Impl(*this);
1069  m_pImpl->m_wStyleAccess = xStyleAccess;
1070  }
1071  aRet <<= xStyleAccess;
1072  }
1073  break;
1075  {
1076  OUString aString;
1078  pTOXBase->GetMainEntryCharStyle(),
1079  aString,
1081  aRet <<= aString;
1082  }
1083  break;
1085  lcl_BitMaskToAny(aRet, nCreate, SwTOXElement::Table);
1086  break;
1088  lcl_BitMaskToAny(aRet, nCreate, SwTOXElement::Frame);
1089  break;
1091  lcl_BitMaskToAny(aRet, nCreate, SwTOXElement::Graphic);
1092  break;
1094  lcl_BitMaskToAny(aRet, nCreate, SwTOXElement::Ole);
1095  break;
1097  lcl_BitMaskToAny(aRet, nOLEOptions, SwTOOElements::Math);
1098  break;
1100  lcl_BitMaskToAny(aRet, nOLEOptions, SwTOOElements::Chart);
1101  break;
1103  lcl_BitMaskToAny(aRet, nOLEOptions, SwTOOElements::Calc);
1104  break;
1106  lcl_BitMaskToAny(aRet, nOLEOptions,
1108  break;
1110  lcl_BitMaskToAny(aRet, nOLEOptions, SwTOOElements::Other);
1111  break;
1113  lcl_BitMaskToAny(aRet, nCreate, SwTOXElement::Template);
1114  break;
1115  case WID_PARA_HEAD:
1116  {
1117  //Header is at position 0
1118  OUString aString;
1119  SwStyleNameMapper::FillProgName(rForm.GetTemplate( 0 ), aString,
1121  aRet <<= aString;
1122  }
1123  break;
1124  case WID_PARA_SEP:
1125  {
1126  OUString aString;
1128  rForm.GetTemplate( 1 ),
1129  aString,
1131  aRet <<= aString;
1132  }
1133  break;
1134  case WID_PARA_LEV1:
1135  case WID_PARA_LEV2:
1136  case WID_PARA_LEV3:
1137  case WID_PARA_LEV4:
1138  case WID_PARA_LEV5:
1139  case WID_PARA_LEV6:
1140  case WID_PARA_LEV7:
1141  case WID_PARA_LEV8:
1142  case WID_PARA_LEV9:
1143  case WID_PARA_LEV10:
1144  {
1145  // in sdbcx::Index Label 1 begins at Pos 2 otherwise at Pos 1
1146  const sal_uInt16 nLPos = pTOXBase->GetType() == TOX_INDEX ? 2 : 1;
1147  OUString aString;
1149  rForm.GetTemplate(nLPos + pEntry->nWID - WID_PARA_LEV1),
1150  aString,
1152  aRet <<= aString;
1153  }
1154  break;
1156  {
1157  const bool bRet = rForm.IsRelTabPos();
1158  aRet <<= bRet;
1159  }
1160  break;
1161  case WID_INDEX_MARKS:
1162  {
1163  SwTOXMarks aMarks;
1164  const SwTOXType* pType = pTOXBase->GetTOXType();
1165  pType->CollectTextMarks(aMarks);
1166  uno::Sequence< uno::Reference<text::XDocumentIndexMark> > aXMarks(aMarks.size());
1167  uno::Reference<text::XDocumentIndexMark>* pxMarks = aXMarks.getArray();
1168  for(size_t i = 0; i < aMarks.size(); ++i)
1169  {
1170  SwTOXMark* pMark = aMarks[i];
1172  *m_pImpl->m_pDoc, pMark);
1173  }
1174  aRet <<= aXMarks;
1175  }
1176  break;
1177  default:
1178  //this is for items only
1179  if(WID_PRIMARY_KEY > pEntry->nWID)
1180  {
1181  const SwAttrSet& rSet =
1182  SwDoc::GetTOXBaseAttrSet(*pTOXBase);
1183  aRet = m_pImpl->m_rPropSet.getPropertyValue(
1184  rPropertyName, rSet);
1185  }
1186  }
1187  }
1188  return aRet;
1189 }
1190 
1191 void SAL_CALL
1193  const OUString& /*rPropertyName*/,
1194  const uno::Reference< beans::XPropertyChangeListener >& /*xListener*/)
1195 {
1196  OSL_FAIL("SwXDocumentIndex::addPropertyChangeListener(): not implemented");
1197 }
1198 
1199 void SAL_CALL
1201  const OUString& /*rPropertyName*/,
1202  const uno::Reference< beans::XPropertyChangeListener >& /*xListener*/)
1203 {
1204  OSL_FAIL("SwXDocumentIndex::removePropertyChangeListener(): not implemented");
1205 }
1206 
1207 void SAL_CALL
1209  const OUString& /*rPropertyName*/,
1210  const uno::Reference< beans::XVetoableChangeListener >& /*xListener*/)
1211 {
1212  OSL_FAIL("SwXDocumentIndex::addVetoableChangeListener(): not implemented");
1213 }
1214 
1215 void SAL_CALL
1217  const OUString& /*rPropertyName*/,
1218  const uno::Reference< beans::XVetoableChangeListener >& /*xListener*/)
1219 {
1220  OSL_FAIL("SwXDocumentIndex::removeVetoableChangeListener(): not implemented");
1221 }
1222 
1223 static void lcl_CalcLayout(SwDoc *pDoc)
1224 {
1225  SwViewShell *pViewShell = nullptr;
1226  SwEditShell* pEditShell = nullptr;
1227  if( pDoc )
1228  {
1229  pViewShell = pDoc->getIDocumentLayoutAccess().GetCurrentViewShell();
1230  pEditShell = pDoc->GetEditShell();
1231  }
1232 
1233  if (pEditShell)
1234  {
1235  pEditShell->CalcLayout();
1236  }
1237  else if (pViewShell)
1238  {
1239  pViewShell->CalcLayout();
1240  }
1241 }
1242 
1243 // XRefreshable
1245 {
1246  {
1247  SolarMutexGuard g;
1248 
1249  SwSectionFormat *const pFormat = m_pImpl->GetSectionFormat();
1250  SwTOXBaseSection *const pTOXBase = pFormat ?
1251  static_cast<SwTOXBaseSection*>(pFormat->GetSection()) : nullptr;
1252  if (!pTOXBase)
1253  {
1254  throw uno::RuntimeException(
1255  "SwXDocumentIndex::refresh: must be in attached state",
1256  static_cast< ::cppu::OWeakObject*>(this));
1257  }
1258  pTOXBase->Update(nullptr, m_pImpl->m_pDoc->getIDocumentLayoutAccess().GetCurrentLayout());
1259 
1260  // the insertion of TOC will affect the document layout
1261  lcl_CalcLayout(m_pImpl->m_pDoc);
1262 
1263  // page numbers
1264  pTOXBase->UpdatePageNum();
1265  }
1266 
1267  ::comphelper::OInterfaceContainerHelper2 *const pContainer(
1268  m_pImpl->m_Listeners.getContainer(
1270  if (pContainer)
1271  {
1272  lang::EventObject const event(static_cast< ::cppu::OWeakObject*>(this));
1273  pContainer->notifyEach(& util::XRefreshListener::refreshed, event);
1274  }
1275 }
1276 
1278  const uno::Reference<util::XRefreshListener>& xListener)
1279 {
1280  // no need to lock here as m_pImpl is const and container threadsafe
1281  m_pImpl->m_Listeners.addInterface(
1283 }
1284 
1286  const uno::Reference<util::XRefreshListener>& xListener)
1287 {
1288  // no need to lock here as m_pImpl is const and container threadsafe
1289  m_pImpl->m_Listeners.removeInterface(
1291 }
1292 
1293 void SAL_CALL
1294 SwXDocumentIndex::attach(const uno::Reference< text::XTextRange > & xTextRange)
1295 {
1296  SolarMutexGuard aGuard;
1297 
1298  if (!m_pImpl->m_bIsDescriptor)
1299  {
1300  throw uno::RuntimeException();
1301  }
1302  const uno::Reference<XUnoTunnel> xRangeTunnel( xTextRange, uno::UNO_QUERY);
1303  SwXTextRange *const pRange =
1304  comphelper::getFromUnoTunnel<SwXTextRange>(xRangeTunnel);
1305  OTextCursorHelper *const pCursor =
1306  comphelper::getFromUnoTunnel<OTextCursorHelper>(xRangeTunnel);
1307 
1308  SwDoc *const pDoc =
1309  pRange ? &pRange->GetDoc() : (pCursor ? pCursor->GetDoc() : nullptr);
1310  if (!pDoc)
1311  {
1312  throw lang::IllegalArgumentException();
1313  }
1314 
1315  SwUnoInternalPaM aPam(*pDoc);
1316  // this now needs to return TRUE
1317  ::sw::XTextRangeToSwPaM(aPam, xTextRange);
1318 
1319  const SwTOXBase* pOld = SwDoc::GetCurTOX( *aPam.Start() );
1320  if (pOld)
1321  {
1322  throw lang::IllegalArgumentException();
1323  }
1324 
1325  UnoActionContext aAction(pDoc);
1326 
1327  SwTOXBase & rTOXBase = m_pImpl->m_pProps->GetTOXBase();
1328  SwTOXType const*const pTOXType = rTOXBase.GetTOXType();
1329  if ((TOX_USER == pTOXType->GetType()) &&
1330  m_pImpl->m_pProps->GetTypeName() != pTOXType->GetTypeName())
1331  {
1332  lcl_ReAssignTOXType(*pDoc, rTOXBase, m_pImpl->m_pProps->GetTypeName());
1333  }
1334  //TODO: apply Section attributes (columns and background)
1335  SwTOXBaseSection *const pTOX =
1336  pDoc->InsertTableOf( aPam, rTOXBase, nullptr, false,
1337  m_pImpl->m_pDoc->getIDocumentLayoutAccess().GetCurrentLayout());
1338 
1339  pDoc->SetTOXBaseName(*pTOX, m_pImpl->m_pProps->GetTOXBase().GetTOXName());
1340 
1341  // update page numbers
1342  m_pImpl->SetSectionFormat(*pTOX->GetFormat());
1343  pTOX->GetFormat()->SetXObject(static_cast< ::cppu::OWeakObject*>(this));
1344  pTOX->UpdatePageNum();
1345 
1346  m_pImpl->m_pProps.reset();
1347  m_pImpl->m_pDoc = pDoc;
1348  m_pImpl->m_bIsDescriptor = false;
1349 }
1350 
1351 uno::Reference< text::XTextRange > SAL_CALL
1353 {
1354  SolarMutexGuard aGuard;
1355 
1356  SwSectionFormat *const pSectionFormat( m_pImpl->GetSectionFormat() );
1357  if (!pSectionFormat)
1358  {
1359  throw uno::RuntimeException();
1360  }
1361 
1362  uno::Reference< text::XTextRange > xRet;
1363  SwNodeIndex const*const pIdx( pSectionFormat->GetContent().GetContentIdx() );
1364  if (pIdx && pIdx->GetNode().GetNodes().IsDocNodes())
1365  {
1366  SwPaM aPaM(*pIdx);
1367  aPaM.Move( fnMoveForward, GoInContent );
1368  aPaM.SetMark();
1369  aPaM.GetPoint()->nNode = *pIdx->GetNode().EndOfSectionNode();
1370  aPaM.Move( fnMoveBackward, GoInContent );
1371  xRet = SwXTextRange::CreateXTextRange(*pSectionFormat->GetDoc(),
1372  *aPaM.GetMark(), aPaM.GetPoint());
1373  }
1374  return xRet;
1375 }
1376 
1378 {
1379  SolarMutexGuard aGuard;
1380 
1381  SwSectionFormat *const pSectionFormat( m_pImpl->GetSectionFormat() );
1382  if (pSectionFormat)
1383  {
1384  pSectionFormat->GetDoc()->DeleteTOX(
1385  *static_cast<SwTOXBaseSection*>(pSectionFormat->GetSection()),
1386  true);
1387  }
1388 }
1389 
1390 void SAL_CALL
1392  const uno::Reference< lang::XEventListener > & xListener)
1393 {
1394  // no need to lock here as m_pImpl is const and container threadsafe
1395  m_pImpl->m_Listeners.addInterface(
1397 }
1398 
1399 void SAL_CALL
1401  const uno::Reference< lang::XEventListener > & xListener)
1402 {
1403  // no need to lock here as m_pImpl is const and container threadsafe
1404  m_pImpl->m_Listeners.removeInterface(
1406 }
1407 
1408 OUString SAL_CALL SwXDocumentIndex::getName()
1409 {
1410  SolarMutexGuard g;
1411 
1412  SwSectionFormat *const pSectionFormat( m_pImpl->GetSectionFormat() );
1413  if (m_pImpl->m_bIsDescriptor)
1414  {
1415  return m_pImpl->m_pProps->GetTOXBase().GetTOXName();
1416  }
1417 
1418  if(!pSectionFormat)
1419  {
1420  throw uno::RuntimeException();
1421  }
1422 
1423  return pSectionFormat->GetSection()->GetSectionName();
1424 }
1425 
1426 void SAL_CALL
1427 SwXDocumentIndex::setName(const OUString& rName)
1428 {
1429  SolarMutexGuard g;
1430 
1431  if (rName.isEmpty())
1432  {
1433  throw uno::RuntimeException();
1434  }
1435 
1436  SwSectionFormat *const pSectionFormat( m_pImpl->GetSectionFormat() );
1437  if (m_pImpl->m_bIsDescriptor)
1438  {
1439  m_pImpl->m_pProps->GetTOXBase().SetTOXName(rName);
1440  }
1441  else if (pSectionFormat)
1442  {
1443  const bool bSuccess = pSectionFormat->GetDoc()->SetTOXBaseName(
1444  *static_cast<SwTOXBaseSection*>(pSectionFormat->GetSection()), rName);
1445  if (!bSuccess)
1446  {
1447  throw uno::RuntimeException();
1448  }
1449  }
1450  else
1451  {
1452  throw uno::RuntimeException();
1453  }
1454 }
1455 
1456 // MetadatableMixin
1458 {
1459  SwSectionFormat *const pSectionFormat( m_pImpl->GetSectionFormat() );
1460  return pSectionFormat;
1461 }
1462 
1463 uno::Reference<frame::XModel> SwXDocumentIndex::GetModel()
1464 {
1465  SwSectionFormat *const pSectionFormat( m_pImpl->GetSectionFormat() );
1466  if (pSectionFormat)
1467  {
1468  SwDocShell const*const pShell( pSectionFormat->GetDoc()->GetDocShell() );
1469  return pShell ? pShell->GetModel() : nullptr;
1470  }
1471  return nullptr;
1472 }
1473 
1474 static sal_uInt16
1476 {
1477  switch (eType)
1478  {
1479  case TOX_INDEX: return PROPERTY_MAP_INDEX_MARK;
1482  //case TOX_USER:
1483  default:
1484  return PROPERTY_MAP_USER_MARK;
1485  }
1486 }
1487 
1489 {
1490 private:
1491  ::osl::Mutex m_Mutex; // just for OInterfaceContainerHelper2
1494 
1495 public:
1496 
1497  uno::WeakReference<uno::XInterface> m_wThis;
1505 
1507  sal_uInt16 m_nLevel;
1510  OUString m_sAltText;
1511  OUString m_sPrimaryKey;
1513  OUString m_sTextReading;
1517 
1519  SwDoc* const pDoc,
1520  const enum TOXTypes eType,
1521  const SwTOXType* pType,
1522  SwTOXMark const* pMark)
1523  : m_rThis(rThis)
1524  , m_bInReplaceMark(false)
1525  , m_rPropSet(
1526  *aSwMapProvider.GetPropertySet(lcl_TypeToPropertyMap_Mark(eType)))
1527  , m_eTOXType(eType)
1528  , m_EventListeners(m_Mutex)
1529  , m_bIsDescriptor(nullptr == pMark)
1530  , m_pTOXType(pType)
1531  , m_pTOXMark(pMark)
1532  , m_pDoc(pDoc)
1533  , m_bMainEntry(false)
1534  , m_nLevel(0)
1535  {
1536  auto pMarkNonConst = const_cast<SwTOXMark*>(m_pTOXMark);
1537  auto pTypeNonConst = const_cast<SwTOXType*>(m_pTOXType);
1538 
1539  if(pMarkNonConst)
1540  StartListening(pMarkNonConst->GetNotifier());
1541  if(pTypeNonConst)
1542  StartListening(pTypeNonConst->GetNotifier());
1543  }
1544 
1546  return const_cast<SwTOXType*>(m_pTOXType);
1547  }
1548 
1550  {
1551  m_pDoc->DeleteTOXMark(m_pTOXMark);
1552  Invalidate();
1553  }
1554 
1555  void InsertTOXMark(SwTOXType & rTOXType, SwTOXMark & rMark, SwPaM & rPam,
1556  SwXTextCursor const*const pTextCursor);
1557 
1558  void ReplaceTOXMark(SwTOXType & rTOXType, SwTOXMark & rMark, SwPaM & rPam)
1559  {
1560  m_bInReplaceMark = true;
1561  DeleteTOXMark();
1562  m_bInReplaceMark = false;
1563  try {
1564  InsertTOXMark(rTOXType, rMark, rPam, nullptr);
1565  } catch (...) {
1566  OSL_FAIL("ReplaceTOXMark() failed!");
1567  lang::EventObject const ev(
1568  static_cast< ::cppu::OWeakObject&>(m_rThis));
1569  m_EventListeners.disposeAndClear(ev);
1570  throw;
1571  }
1572  }
1573 
1574  void Invalidate();
1575  virtual void Notify(const SfxHint&) override;
1576 };
1577 
1579 {
1580  if (!m_bInReplaceMark) // #i109983# only dispose on delete, not on replace!
1581  {
1582  uno::Reference<uno::XInterface> const xThis(m_wThis);
1583  // fdo#72695: if UNO object is already dead, don't revive it with event
1584  if (xThis.is())
1585  {
1586  lang::EventObject const ev(xThis);
1588  }
1589  }
1590  EndListeningAll();
1591  m_pDoc = nullptr;
1592  m_pTOXMark = nullptr;
1593  m_pTOXType = nullptr;
1594 }
1595 
1597 {
1598  if(auto pModifyChangedHint = dynamic_cast<const sw::ModifyChangedHint*>(&rHint))
1599  {
1600  if(auto pNewType = dynamic_cast<const SwTOXType*>(pModifyChangedHint->m_pNew))
1601  m_pTOXType = pNewType;
1602 
1603  else
1604  Invalidate();
1605  }
1606 }
1607 
1609  : m_pImpl( new SwXDocumentIndexMark::Impl(*this, nullptr, eToxType, nullptr, nullptr) )
1610 {
1611 }
1612 
1614  SwTOXType & rType, SwTOXMark & rMark)
1615  : m_pImpl( new SwXDocumentIndexMark::Impl(*this, &rDoc, rType.GetType(),
1616  &rType, &rMark) )
1617 {
1618 }
1619 
1621 {
1622 }
1623 
1624 uno::Reference<text::XDocumentIndexMark>
1626  SwDoc & rDoc, SwTOXMark *const pMark, TOXTypes const eType)
1627 {
1628  // re-use existing SwXDocumentIndexMark
1629  // NB: xmloff depends on this caching to generate ID from the address!
1630  // #i105557#: do not iterate over the registered clients: race condition
1631  uno::Reference<text::XDocumentIndexMark> xTOXMark;
1632  if (pMark)
1633  {
1634  xTOXMark = pMark->GetXTOXMark();
1635  }
1636  if (!xTOXMark.is())
1637  {
1638  SwXDocumentIndexMark *const pNew(pMark
1639  ? new SwXDocumentIndexMark(rDoc,
1640  *const_cast<SwTOXType*>(pMark->GetTOXType()), *pMark)
1641  : new SwXDocumentIndexMark(eType));
1642  xTOXMark.set(pNew);
1643  if (pMark)
1644  {
1645  pMark->SetXTOXMark(xTOXMark);
1646  }
1647  // need a permanent Reference to initialize m_wThis
1648  pNew->m_pImpl->m_wThis = xTOXMark;
1649  }
1650  return xTOXMark;
1651 }
1652 
1653 namespace
1654 {
1655 }
1656 
1657 const uno::Sequence< sal_Int8 > & SwXDocumentIndexMark::getUnoTunnelId()
1658 {
1659  static const comphelper::UnoIdInit theSwXDocumentIndexMarkUnoTunnelId;
1660  return theSwXDocumentIndexMarkUnoTunnelId.getSeq();
1661 }
1662 
1663 sal_Int64 SAL_CALL
1664 SwXDocumentIndexMark::getSomething(const uno::Sequence< sal_Int8 >& rId)
1665 {
1666  return comphelper::getSomethingImpl<SwXDocumentIndexMark>(rId, this);
1667 }
1668 
1669 OUString SAL_CALL
1671 {
1672  return "SwXDocumentIndexMark";
1673 }
1674 
1675 sal_Bool SAL_CALL SwXDocumentIndexMark::supportsService(const OUString& rServiceName)
1676 {
1677  return cppu::supportsService(this, rServiceName);
1678 }
1679 
1680 uno::Sequence< OUString > SAL_CALL
1682 {
1683  SolarMutexGuard g;
1684 
1685  const sal_Int32 nCnt = (m_pImpl->m_eTOXType == TOX_INDEX) ? 4 : 3;
1686  uno::Sequence< OUString > aRet(nCnt);
1687  OUString* pArray = aRet.getArray();
1688  pArray[0] = "com.sun.star.text.BaseIndexMark";
1689  pArray[1] = "com.sun.star.text.TextContent";
1690  switch (m_pImpl->m_eTOXType)
1691  {
1692  case TOX_USER:
1693  pArray[2] = "com.sun.star.text.UserIndexMark";
1694  break;
1695  case TOX_CONTENT:
1696  pArray[2] = "com.sun.star.text.ContentIndexMark";
1697  break;
1698  case TOX_INDEX:
1699  pArray[2] = "com.sun.star.text.DocumentIndexMark";
1700  pArray[3] = "com.sun.star.text.DocumentIndexMarkAsian";
1701  break;
1702 
1703  default:
1704  ;
1705  }
1706  return aRet;
1707 }
1708 
1709 OUString SAL_CALL
1711 {
1712  SolarMutexGuard aGuard;
1713 
1714  SwTOXType *const pType = m_pImpl->GetTOXType();
1715  if (pType && m_pImpl->m_pTOXMark)
1716  {
1717  return m_pImpl->m_pTOXMark->GetAlternativeText();
1718  }
1719 
1720  if (!m_pImpl->m_bIsDescriptor)
1721  {
1722  throw uno::RuntimeException();
1723  }
1724 
1725  return m_pImpl->m_sAltText;
1726 }
1727 
1728 void SAL_CALL
1729 SwXDocumentIndexMark::setMarkEntry(const OUString& rIndexEntry)
1730 {
1731  SolarMutexGuard aGuard;
1732 
1733  SwTOXType *const pType = m_pImpl->GetTOXType();
1734  if (pType && m_pImpl->m_pTOXMark)
1735  {
1736  SwTOXMark aMark(*m_pImpl->m_pTOXMark);
1737  aMark.SetAlternativeText(rIndexEntry);
1738  SwTextTOXMark const*const pTextMark =
1739  m_pImpl->m_pTOXMark->GetTextTOXMark();
1740  SwPaM aPam(pTextMark->GetTextNode(), pTextMark->GetStart());
1741  aPam.SetMark();
1742  if(pTextMark->End())
1743  {
1744  aPam.GetPoint()->nContent = *pTextMark->End();
1745  }
1746  else
1747  ++aPam.GetPoint()->nContent;
1748 
1749  m_pImpl->ReplaceTOXMark(*pType, aMark, aPam);
1750  }
1751  else if (m_pImpl->m_bIsDescriptor)
1752  {
1753  m_pImpl->m_sAltText = rIndexEntry;
1754  }
1755  else
1756  {
1757  throw uno::RuntimeException();
1758  }
1759 }
1760 
1761 void SAL_CALL
1763  const uno::Reference< text::XTextRange > & xTextRange)
1764 {
1765  SolarMutexGuard aGuard;
1766 
1767  if (!m_pImpl->m_bIsDescriptor)
1768  {
1769  throw uno::RuntimeException();
1770  }
1771 
1772  const uno::Reference<XUnoTunnel> xRangeTunnel(xTextRange, uno::UNO_QUERY);
1773  SwXTextRange *const pRange =
1774  comphelper::getFromUnoTunnel<SwXTextRange>(xRangeTunnel);
1775  OTextCursorHelper *const pCursor =
1776  comphelper::getFromUnoTunnel<OTextCursorHelper>(xRangeTunnel);
1777  SwDoc *const pDoc =
1778  pRange ? &pRange->GetDoc() : (pCursor ? pCursor->GetDoc() : nullptr);
1779  if (!pDoc)
1780  {
1781  throw lang::IllegalArgumentException();
1782  }
1783 
1784  const SwTOXType* pTOXType = nullptr;
1785  switch (m_pImpl->m_eTOXType)
1786  {
1787  case TOX_INDEX:
1788  case TOX_CONTENT:
1789  case TOX_CITATION:
1790  pTOXType = pDoc->GetTOXType( m_pImpl->m_eTOXType, 0 );
1791  break;
1792  case TOX_USER:
1793  {
1794  if (m_pImpl->m_sUserIndexName.isEmpty())
1795  {
1796  pTOXType = pDoc->GetTOXType( m_pImpl->m_eTOXType, 0 );
1797  }
1798  else
1799  {
1800  const sal_uInt16 nCount =
1801  pDoc->GetTOXTypeCount(m_pImpl->m_eTOXType);
1802  for (sal_uInt16 i = 0; i < nCount; i++)
1803  {
1804  SwTOXType const*const pTemp =
1805  pDoc->GetTOXType( m_pImpl->m_eTOXType, i );
1806  if (m_pImpl->m_sUserIndexName == pTemp->GetTypeName())
1807  {
1808  pTOXType = pTemp;
1809  break;
1810  }
1811  }
1812  if (!pTOXType)
1813  {
1814  SwTOXType aUserType(*pDoc, TOX_USER, m_pImpl->m_sUserIndexName);
1815  pTOXType = pDoc->InsertTOXType(aUserType);
1816  }
1817  }
1818  }
1819  break;
1820 
1821  default:
1822  break;
1823  }
1824  if (!pTOXType)
1825  {
1826  throw lang::IllegalArgumentException();
1827  }
1828 
1829  SwUnoInternalPaM aPam(*pDoc);
1830  // this now needs to return TRUE
1831  ::sw::XTextRangeToSwPaM(aPam, xTextRange);
1832  SwTOXMark aMark (pTOXType);
1833  if (!m_pImpl->m_sAltText.isEmpty())
1834  {
1835  aMark.SetAlternativeText(m_pImpl->m_sAltText);
1836  }
1837  switch (m_pImpl->m_eTOXType)
1838  {
1839  case TOX_INDEX:
1840  if (!m_pImpl->m_sPrimaryKey.isEmpty())
1841  {
1842  aMark.SetPrimaryKey(m_pImpl->m_sPrimaryKey);
1843  }
1844  if (!m_pImpl->m_sSecondaryKey.isEmpty())
1845  {
1846  aMark.SetSecondaryKey(m_pImpl->m_sSecondaryKey);
1847  }
1848  if (!m_pImpl->m_sTextReading.isEmpty())
1849  {
1850  aMark.SetTextReading(m_pImpl->m_sTextReading);
1851  }
1852  if (!m_pImpl->m_sPrimaryKeyReading.isEmpty())
1853  {
1854  aMark.SetPrimaryKeyReading(m_pImpl->m_sPrimaryKeyReading);
1855  }
1856  if (!m_pImpl->m_sSecondaryKeyReading.isEmpty())
1857  {
1858  aMark.SetSecondaryKeyReading(m_pImpl->m_sSecondaryKeyReading);
1859  }
1860  aMark.SetMainEntry(m_pImpl->m_bMainEntry);
1861  break;
1862  case TOX_CITATION:
1863  aMark.SetMainEntry(m_pImpl->m_bMainEntry);
1864  break;
1865  case TOX_USER:
1866  case TOX_CONTENT:
1867  if (USHRT_MAX != m_pImpl->m_nLevel)
1868  {
1869  aMark.SetLevel(m_pImpl->m_nLevel+1);
1870  }
1871  break;
1872 
1873  default:
1874  break;
1875  }
1876 
1877  m_pImpl->InsertTOXMark(*const_cast<SwTOXType *>(pTOXType), aMark, aPam,
1878  dynamic_cast<SwXTextCursor const*>(pCursor));
1879 
1880  m_pImpl->m_bIsDescriptor = false;
1881 }
1882 
1883 namespace {
1884 
1885 template<typename T> struct NotContainedIn
1886 {
1887  std::vector<T> const& m_rVector;
1888  explicit NotContainedIn(std::vector<T> const& rVector)
1889  : m_rVector(rVector) { }
1890  bool operator() (T const& rT) {
1891  return std::find(m_rVector.begin(), m_rVector.end(), rT)
1892  == m_rVector.end();
1893  }
1894 };
1895 
1896 }
1897 
1899  SwTOXType & rTOXType, SwTOXMark & rMark, SwPaM & rPam,
1900  SwXTextCursor const*const pTextCursor)
1901 {
1902  SwDoc& rDoc(rPam.GetDoc());
1903  UnoActionContext aAction(&rDoc);
1904  bool bMark = *rPam.GetPoint() != *rPam.GetMark();
1905  // n.b.: toxmarks must have either alternative text or an extent
1906  if (bMark && !rMark.GetAlternativeText().isEmpty())
1907  {
1908  rPam.Normalize();
1909  rPam.DeleteMark();
1910  bMark = false;
1911  }
1912  // Marks without alternative text and without selected text cannot be inserted,
1913  // thus use a space - is this really the ideal solution?
1914  if (!bMark && rMark.GetAlternativeText().isEmpty())
1915  {
1916  rMark.SetAlternativeText( " " );
1917  }
1918 
1919  const bool bForceExpandHints( !bMark && pTextCursor && pTextCursor->IsAtEndOfMeta() );
1920  const SetAttrMode nInsertFlags = bForceExpandHints
1924 
1925  // rMark gets copied into the document pool;
1926  // pNewTextAttr comes back with the real format
1927  SwTextAttr *pNewTextAttr = nullptr;
1928  rDoc.getIDocumentContentOperations().InsertPoolItem(rPam, rMark, nInsertFlags,
1929  /*pLayout*/nullptr, &pNewTextAttr);
1930  if (bMark && *rPam.GetPoint() > *rPam.GetMark())
1931  {
1932  rPam.Exchange();
1933  }
1934 
1935  if (!pNewTextAttr)
1936  {
1937  throw uno::RuntimeException(
1938  "SwXDocumentIndexMark::InsertTOXMark(): cannot insert attribute",
1939  nullptr);
1940  }
1941 
1942  m_pDoc = &rDoc;
1943  m_pTOXMark = &pNewTextAttr->GetTOXMark();
1944  m_pTOXType = &rTOXType;
1945  EndListeningAll();
1946  StartListening(const_cast<SwTOXMark*>(m_pTOXMark)->GetNotifier());
1947  StartListening(const_cast<SwTOXType*>(m_pTOXType)->GetNotifier());
1948 }
1949 
1950 uno::Reference< text::XTextRange > SAL_CALL
1952 {
1953  SolarMutexGuard aGuard;
1954 
1955  SwTOXType *const pType = m_pImpl->GetTOXType();
1956  if (!pType || !m_pImpl->m_pTOXMark)
1957  {
1958  throw uno::RuntimeException();
1959  }
1960  if (!m_pImpl->m_pTOXMark->GetTextTOXMark())
1961  {
1962  throw uno::RuntimeException();
1963  }
1964  const SwTextTOXMark* pTextMark = m_pImpl->m_pTOXMark->GetTextTOXMark();
1965  SwPaM aPam(pTextMark->GetTextNode(), pTextMark->GetStart());
1966  aPam.SetMark();
1967  if(pTextMark->End())
1968  {
1969  aPam.GetPoint()->nContent = *pTextMark->End();
1970  }
1971  else
1972  {
1973  ++aPam.GetPoint()->nContent;
1974  }
1975  const uno::Reference< frame::XModel > xModel =
1976  m_pImpl->m_pDoc->GetDocShell()->GetBaseModel();
1977  const uno::Reference< text::XTextDocument > xTDoc(xModel, uno::UNO_QUERY);
1978  const uno::Reference< text::XTextRange > xRet =
1979  new SwXTextRange(aPam, xTDoc->getText());
1980 
1981  return xRet;
1982 }
1983 
1984 void SAL_CALL
1986 {
1987  SolarMutexGuard aGuard;
1988 
1989  SwTOXType *const pType = m_pImpl->GetTOXType();
1990  if (pType && m_pImpl->m_pTOXMark)
1991  {
1992  m_pImpl->DeleteTOXMark(); // call Invalidate() via modify!
1993  }
1994 }
1995 
1996 void SAL_CALL
1998  const uno::Reference< lang::XEventListener > & xListener)
1999 {
2000  // no need to lock here as m_pImpl is const and container threadsafe
2001  m_pImpl->m_EventListeners.addInterface(xListener);
2002 }
2003 
2004 void SAL_CALL
2006  const uno::Reference< lang::XEventListener > & xListener)
2007 {
2008  // no need to lock here as m_pImpl is const and container threadsafe
2009  m_pImpl->m_EventListeners.removeInterface(xListener);
2010 }
2011 
2012 uno::Reference< beans::XPropertySetInfo > SAL_CALL
2014 {
2015  SolarMutexGuard g;
2016 
2017  static uno::Reference< beans::XPropertySetInfo > xInfos[3];
2018  int nPos = 0;
2019  switch (m_pImpl->m_eTOXType)
2020  {
2021  case TOX_INDEX: nPos = 0; break;
2022  case TOX_CONTENT: nPos = 1; break;
2023  case TOX_USER: nPos = 2; break;
2024  default:
2025  ;
2026  }
2027  if(!xInfos[nPos].is())
2028  {
2029  const uno::Reference< beans::XPropertySetInfo > xInfo =
2030  m_pImpl->m_rPropSet.getPropertySetInfo();
2031  // extend PropertySetInfo!
2032  const uno::Sequence<beans::Property> aPropSeq = xInfo->getProperties();
2033  xInfos[nPos] = new SfxExtItemPropertySetInfo(
2036  aPropSeq );
2037  }
2038  return xInfos[nPos];
2039 }
2040 
2041 void SAL_CALL
2043  const OUString& rPropertyName, const uno::Any& rValue)
2044 {
2045  SolarMutexGuard aGuard;
2046 
2047  SfxItemPropertyMapEntry const*const pEntry =
2048  m_pImpl->m_rPropSet.getPropertyMap().getByName(rPropertyName);
2049  if (!pEntry)
2050  {
2051  throw beans::UnknownPropertyException(
2052  "Unknown property: " + rPropertyName,
2053  static_cast<cppu::OWeakObject *>(this));
2054  }
2055  if (pEntry->nFlags & beans::PropertyAttribute::READONLY)
2056  {
2057  throw beans::PropertyVetoException(
2058  "Property is read-only: " + rPropertyName,
2059  static_cast<cppu::OWeakObject *>(this));
2060  }
2061 
2062  SwTOXType *const pType = m_pImpl->GetTOXType();
2063  if (pType && m_pImpl->m_pTOXMark)
2064  {
2065  SwTOXMark aMark(*m_pImpl->m_pTOXMark);
2066  switch(pEntry->nWID)
2067  {
2068  case WID_ALT_TEXT:
2069  aMark.SetAlternativeText(lcl_AnyToType<OUString>(rValue));
2070  break;
2071  case WID_LEVEL:
2072  aMark.SetLevel(std::min( static_cast<sal_Int8>( MAXLEVEL ),
2073  static_cast<sal_Int8>(lcl_AnyToType<sal_Int16>(rValue)+1)));
2074  break;
2075  case WID_TOC_BOOKMARK :
2076  aMark.SetBookmarkName(lcl_AnyToType<OUString>(rValue));
2077  break;
2078  case WID_INDEX_ENTRY_TYPE :
2079  aMark.SetEntryTypeName(lcl_AnyToType<OUString>(rValue));
2080  break;
2081  case WID_PRIMARY_KEY :
2082  aMark.SetPrimaryKey(lcl_AnyToType<OUString>(rValue));
2083  break;
2084  case WID_SECONDARY_KEY:
2085  aMark.SetSecondaryKey(lcl_AnyToType<OUString>(rValue));
2086  break;
2087  case WID_MAIN_ENTRY:
2088  aMark.SetMainEntry(lcl_AnyToType<bool>(rValue));
2089  break;
2090  case WID_TEXT_READING:
2091  aMark.SetTextReading(lcl_AnyToType<OUString>(rValue));
2092  break;
2094  aMark.SetPrimaryKeyReading(lcl_AnyToType<OUString>(rValue));
2095  break;
2097  aMark.SetSecondaryKeyReading(lcl_AnyToType<OUString>(rValue));
2098  break;
2099  }
2100  SwTextTOXMark const*const pTextMark =
2101  m_pImpl->m_pTOXMark->GetTextTOXMark();
2102  SwPaM aPam(pTextMark->GetTextNode(), pTextMark->GetStart());
2103  aPam.SetMark();
2104  if(pTextMark->End())
2105  {
2106  aPam.GetPoint()->nContent = *pTextMark->End();
2107  }
2108  else
2109  {
2110  ++aPam.GetPoint()->nContent;
2111  }
2112 
2113  m_pImpl->ReplaceTOXMark(*pType, aMark, aPam);
2114  }
2115  else if (m_pImpl->m_bIsDescriptor)
2116  {
2117  switch(pEntry->nWID)
2118  {
2119  case WID_ALT_TEXT:
2120  m_pImpl->m_sAltText = lcl_AnyToType<OUString>(rValue);
2121  break;
2122  case WID_LEVEL:
2123  {
2124  const sal_Int16 nVal = lcl_AnyToType<sal_Int16>(rValue);
2125  if(nVal < 0 || nVal >= MAXLEVEL)
2126  {
2127  throw lang::IllegalArgumentException();
2128  }
2129  m_pImpl->m_nLevel = nVal;
2130  }
2131  break;
2132  case WID_TOC_BOOKMARK :
2133  {
2134  m_pImpl->m_aBookmarkName = lcl_AnyToType<OUString>(rValue);
2135  }
2136  break;
2137  case WID_INDEX_ENTRY_TYPE :
2138  {
2139  m_pImpl->m_aEntryTypeName = lcl_AnyToType<OUString>(rValue);
2140  }
2141  break;
2142  case WID_PRIMARY_KEY:
2143  m_pImpl->m_sPrimaryKey = lcl_AnyToType<OUString>(rValue);
2144  break;
2145  case WID_SECONDARY_KEY:
2146  m_pImpl->m_sSecondaryKey = lcl_AnyToType<OUString>(rValue);
2147  break;
2148  case WID_TEXT_READING:
2149  m_pImpl->m_sTextReading = lcl_AnyToType<OUString>(rValue);
2150  break;
2152  m_pImpl->m_sPrimaryKeyReading = lcl_AnyToType<OUString>(rValue);
2153  break;
2155  m_pImpl->m_sSecondaryKeyReading = lcl_AnyToType<OUString>(rValue);
2156  break;
2157  case WID_USER_IDX_NAME:
2158  {
2159  OUString sTmp(lcl_AnyToType<OUString>(rValue));
2161  m_pImpl->m_sUserIndexName = sTmp;
2162  }
2163  break;
2164  case WID_MAIN_ENTRY:
2165  m_pImpl->m_bMainEntry = lcl_AnyToType<bool>(rValue);
2166  break;
2168  // unsupported
2169  break;
2170  }
2171  }
2172  else
2173  {
2174  throw uno::RuntimeException();
2175  }
2176 }
2177 
2178 uno::Any SAL_CALL
2179 SwXDocumentIndexMark::getPropertyValue(const OUString& rPropertyName)
2180 {
2181  SolarMutexGuard aGuard;
2182 
2183  uno::Any aRet;
2184  SfxItemPropertyMapEntry const*const pEntry =
2185  m_pImpl->m_rPropSet.getPropertyMap().getByName(rPropertyName);
2186  if (!pEntry)
2187  {
2188  throw beans::UnknownPropertyException(
2189  "Unknown property: " + rPropertyName,
2190  static_cast<cppu::OWeakObject *>(this));
2191  }
2192  if (::sw::GetDefaultTextContentValue(aRet, rPropertyName, pEntry->nWID))
2193  {
2194  return aRet;
2195  }
2196 
2197  SwTOXType *const pType = m_pImpl->GetTOXType();
2198  if (pType && m_pImpl->m_pTOXMark)
2199  {
2200  switch(pEntry->nWID)
2201  {
2202  case WID_ALT_TEXT:
2203  aRet <<= m_pImpl->m_pTOXMark->GetAlternativeText();
2204  break;
2205  case WID_LEVEL:
2206  aRet <<= static_cast<sal_Int16>(
2207  m_pImpl->m_pTOXMark->GetLevel() - 1);
2208  break;
2209  case WID_TOC_BOOKMARK :
2210  aRet <<= m_pImpl->m_pTOXMark->GetBookmarkName();
2211  break;
2212  case WID_INDEX_ENTRY_TYPE :
2213  aRet <<= m_pImpl->m_pTOXMark->GetEntryTypeName();
2214  break;
2215  case WID_PRIMARY_KEY :
2216  aRet <<= m_pImpl->m_pTOXMark->GetPrimaryKey();
2217  break;
2218  case WID_SECONDARY_KEY:
2219  aRet <<= m_pImpl->m_pTOXMark->GetSecondaryKey();
2220  break;
2221  case WID_TEXT_READING:
2222  aRet <<= m_pImpl->m_pTOXMark->GetTextReading();
2223  break;
2225  aRet <<= m_pImpl->m_pTOXMark->GetPrimaryKeyReading();
2226  break;
2228  aRet <<= m_pImpl->m_pTOXMark->GetSecondaryKeyReading();
2229  break;
2230  case WID_USER_IDX_NAME :
2231  {
2232  OUString sTmp(pType->GetTypeName());
2234  aRet <<= sTmp;
2235  }
2236  break;
2237  case WID_MAIN_ENTRY:
2238  {
2239  const bool bTemp = m_pImpl->m_pTOXMark->IsMainEntry();
2240  aRet <<= bTemp;
2241  }
2242  break;
2243  }
2244  }
2245  else if (m_pImpl->m_bIsDescriptor)
2246  {
2247  switch(pEntry->nWID)
2248  {
2249  case WID_ALT_TEXT:
2250  aRet <<= m_pImpl->m_sAltText;
2251  break;
2252  case WID_LEVEL:
2253  aRet <<= static_cast<sal_Int16>(m_pImpl->m_nLevel);
2254  break;
2255  case WID_TOC_BOOKMARK :
2256  aRet <<= m_pImpl->m_aBookmarkName;
2257  break;
2258  case WID_INDEX_ENTRY_TYPE :
2259  aRet <<= m_pImpl->m_aEntryTypeName;
2260  break;
2261  case WID_PRIMARY_KEY:
2262  aRet <<= m_pImpl->m_sPrimaryKey;
2263  break;
2264  case WID_SECONDARY_KEY:
2265  aRet <<= m_pImpl->m_sSecondaryKey;
2266  break;
2267  case WID_TEXT_READING:
2268  aRet <<= m_pImpl->m_sTextReading;
2269  break;
2271  aRet <<= m_pImpl->m_sPrimaryKeyReading;
2272  break;
2274  aRet <<= m_pImpl->m_sSecondaryKeyReading;
2275  break;
2276  case WID_USER_IDX_NAME :
2277  aRet <<= m_pImpl->m_sUserIndexName;
2278  break;
2279  case WID_MAIN_ENTRY:
2280  aRet <<= m_pImpl->m_bMainEntry;
2281  break;
2282  }
2283  }
2284  else
2285  {
2286  throw uno::RuntimeException();
2287  }
2288  return aRet;
2289 }
2290 
2291 void SAL_CALL
2293  const OUString& /*rPropertyName*/,
2294  const uno::Reference< beans::XPropertyChangeListener >& /*xListener*/)
2295 {
2296  OSL_FAIL("SwXDocumentIndexMark::addPropertyChangeListener(): not implemented");
2297 }
2298 
2299 void SAL_CALL
2301  const OUString& /*rPropertyName*/,
2302  const uno::Reference< beans::XPropertyChangeListener >& /*xListener*/)
2303 {
2304  OSL_FAIL("SwXDocumentIndexMark::removePropertyChangeListener(): not implemented");
2305 }
2306 
2307 void SAL_CALL
2309  const OUString& /*rPropertyName*/,
2310  const uno::Reference< beans::XVetoableChangeListener >& /*xListener*/)
2311 {
2312  OSL_FAIL("SwXDocumentIndexMark::addVetoableChangeListener(): not implemented");
2313 }
2314 
2315 void SAL_CALL
2317  const OUString& /*rPropertyName*/,
2318  const uno::Reference< beans::XVetoableChangeListener >& /*xListener*/)
2319 {
2320  OSL_FAIL("SwXDocumentIndexMark::removeVetoableChangeListener(): not implemented");
2321 }
2322 
2324  : SwUnoCollection(_pDoc)
2325 {
2326 }
2327 
2329 {
2330 }
2331 
2332 OUString SAL_CALL
2334 {
2335  return "SwXDocumentIndexes";
2336 }
2337 
2338 sal_Bool SAL_CALL SwXDocumentIndexes::supportsService(const OUString& rServiceName)
2339 {
2340  return cppu::supportsService(this, rServiceName);
2341 }
2342 
2343 uno::Sequence< OUString > SAL_CALL
2345 {
2346  return { "com.sun.star.text.DocumentIndexes" };
2347 }
2348 
2349 sal_Int32 SAL_CALL
2351 {
2352  SolarMutexGuard aGuard;
2353 
2354  if(!IsValid())
2355  throw uno::RuntimeException();
2356 
2357  sal_uInt32 nRet = 0;
2358  const SwSectionFormats& rFormats = GetDoc()->GetSections();
2359  for( size_t n = 0; n < rFormats.size(); ++n )
2360  {
2361  const SwSection* pSect = rFormats[ n ]->GetSection();
2362  if( SectionType::ToxContent == pSect->GetType() &&
2363  pSect->GetFormat()->GetSectionNode() )
2364  {
2365  ++nRet;
2366  }
2367  }
2368  return nRet;
2369 }
2370 
2371 uno::Any SAL_CALL
2373 {
2374  SolarMutexGuard aGuard;
2375 
2376  if(!IsValid())
2377  throw uno::RuntimeException();
2378 
2379  sal_Int32 nIdx = 0;
2380 
2381  const SwSectionFormats& rFormats = GetDoc()->GetSections();
2382  for( size_t n = 0; n < rFormats.size(); ++n )
2383  {
2384  SwSection* pSect = rFormats[ n ]->GetSection();
2385  if( SectionType::ToxContent == pSect->GetType() &&
2386  pSect->GetFormat()->GetSectionNode() &&
2387  nIdx++ == nIndex )
2388  {
2389  const uno::Reference< text::XDocumentIndex > xTmp =
2391  *GetDoc(), static_cast<SwTOXBaseSection *>(pSect));
2392  uno::Any aRet;
2393  aRet <<= xTmp;
2394  return aRet;
2395  }
2396  }
2397 
2398  throw lang::IndexOutOfBoundsException();
2399 }
2400 
2401 uno::Any SAL_CALL
2402 SwXDocumentIndexes::getByName(const OUString& rName)
2403 {
2404  SolarMutexGuard aGuard;
2405 
2406  if(!IsValid())
2407  throw uno::RuntimeException();
2408 
2409  const SwSectionFormats& rFormats = GetDoc()->GetSections();
2410  for( size_t n = 0; n < rFormats.size(); ++n )
2411  {
2412  SwSection* pSect = rFormats[ n ]->GetSection();
2413  if( SectionType::ToxContent == pSect->GetType() &&
2414  pSect->GetFormat()->GetSectionNode() &&
2415  (static_cast<SwTOXBaseSection const*>(pSect)->GetTOXName()
2416  == rName))
2417  {
2418  const uno::Reference< text::XDocumentIndex > xTmp =
2420  *GetDoc(), static_cast<SwTOXBaseSection *>(pSect));
2421  uno::Any aRet;
2422  aRet <<= xTmp;
2423  return aRet;
2424  }
2425  }
2426  throw container::NoSuchElementException();
2427 }
2428 
2429 uno::Sequence< OUString > SAL_CALL
2431 {
2432  SolarMutexGuard aGuard;
2433 
2434  if(!IsValid())
2435  throw uno::RuntimeException();
2436 
2437  const SwSectionFormats& rFormats = GetDoc()->GetSections();
2438  sal_Int32 nCount = 0;
2439  for( size_t n = 0; n < rFormats.size(); ++n )
2440  {
2441  SwSection const*const pSect = rFormats[ n ]->GetSection();
2442  if( SectionType::ToxContent == pSect->GetType() &&
2443  pSect->GetFormat()->GetSectionNode() )
2444  {
2445  ++nCount;
2446  }
2447  }
2448 
2449  uno::Sequence< OUString > aRet(nCount);
2450  OUString* pArray = aRet.getArray();
2451  sal_Int32 nCnt = 0;
2452  for( size_t n = 0; n < rFormats.size(); ++n )
2453  {
2454  SwSection const*const pSect = rFormats[ n ]->GetSection();
2455  if( SectionType::ToxContent == pSect->GetType() &&
2456  pSect->GetFormat()->GetSectionNode())
2457  {
2458  pArray[nCnt++] = static_cast<SwTOXBaseSection const*>(pSect)->GetTOXName();
2459  }
2460  }
2461  return aRet;
2462 }
2463 
2464 sal_Bool SAL_CALL
2465 SwXDocumentIndexes::hasByName(const OUString& rName)
2466 {
2467  SolarMutexGuard aGuard;
2468 
2469  if(!IsValid())
2470  throw uno::RuntimeException();
2471 
2472  const SwSectionFormats& rFormats = GetDoc()->GetSections();
2473  for( size_t n = 0; n < rFormats.size(); ++n )
2474  {
2475  SwSection const*const pSect = rFormats[ n ]->GetSection();
2476  if( SectionType::ToxContent == pSect->GetType() &&
2477  pSect->GetFormat()->GetSectionNode())
2478  {
2479  if (static_cast<SwTOXBaseSection const*>(pSect)->GetTOXName()
2480  == rName)
2481  {
2482  return true;
2483  }
2484  }
2485  }
2486  return false;
2487 }
2488 
2489 uno::Type SAL_CALL
2491 {
2493 }
2494 
2495 sal_Bool SAL_CALL
2497 {
2498  return 0 != getCount();
2499 }
2500 
2502  SwXDocumentIndex& rParentIdx)
2503  : m_xParent(&rParentIdx)
2504 {
2505 }
2506 
2508 {
2509 }
2510 
2511 OUString SAL_CALL
2513 {
2514  return "SwXDocumentIndex::StyleAccess_Impl";
2515 }
2516 
2517 sal_Bool SAL_CALL
2519 {
2520  return cppu::supportsService(this, rServiceName);
2521 }
2522 
2523 uno::Sequence< OUString > SAL_CALL
2525 {
2526  return { "com.sun.star.text.DocumentIndexParagraphStyles" };
2527 }
2528 
2529 void SAL_CALL
2531  sal_Int32 nIndex, const uno::Any& rElement)
2532 {
2533  SolarMutexGuard aGuard;
2534 
2535  if(nIndex < 0 || nIndex >= MAXLEVEL)
2536  {
2537  throw lang::IndexOutOfBoundsException();
2538  }
2539 
2540  SwTOXBase & rTOXBase( m_xParent->m_pImpl->GetTOXSectionOrThrow() );
2541 
2542  uno::Sequence<OUString> aSeq;
2543  if(!(rElement >>= aSeq))
2544  {
2545  throw lang::IllegalArgumentException();
2546  }
2547 
2548  const sal_Int32 nStyles = aSeq.getLength();
2549  const OUString* pStyles = aSeq.getConstArray();
2550  OUStringBuffer sSetStyles;
2551  OUString aString;
2552  for(sal_Int32 i = 0; i < nStyles; i++)
2553  {
2554  if(i)
2555  {
2556  sSetStyles.append(TOX_STYLE_DELIMITER);
2557  }
2558  SwStyleNameMapper::FillUIName(pStyles[i], aString,
2560  sSetStyles.append(aString);
2561  }
2562  rTOXBase.SetStyleNames(sSetStyles.makeStringAndClear(), o3tl::narrowing<sal_uInt16>(nIndex));
2563 }
2564 
2565 sal_Int32 SAL_CALL
2567 {
2568  return MAXLEVEL;
2569 }
2570 
2571 uno::Any SAL_CALL
2573 {
2574  SolarMutexGuard aGuard;
2575 
2576  if(nIndex < 0 || nIndex >= MAXLEVEL)
2577  {
2578  throw lang::IndexOutOfBoundsException();
2579  }
2580 
2581  SwTOXBase & rTOXBase( m_xParent->m_pImpl->GetTOXSectionOrThrow() );
2582 
2583  const OUString& rStyles =
2584  rTOXBase.GetStyleNames(o3tl::narrowing<sal_uInt16>(nIndex));
2585  const sal_Int32 nStyles = comphelper::string::getTokenCount(rStyles, TOX_STYLE_DELIMITER);
2586  uno::Sequence<OUString> aStyles(nStyles);
2587  OUString* pStyles = aStyles.getArray();
2588  OUString aString;
2589  sal_Int32 nPos = 0;
2590  for(sal_Int32 i = 0; i < nStyles; ++i)
2591  {
2593  rStyles.getToken(0, TOX_STYLE_DELIMITER, nPos),
2594  aString,
2596  pStyles[i] = aString;
2597  }
2598  uno::Any aRet(&aStyles, cppu::UnoType<uno::Sequence<OUString>>::get());
2599  return aRet;
2600 }
2601 
2602 uno::Type SAL_CALL
2604 {
2606 }
2607 
2608 sal_Bool SAL_CALL
2610 {
2611  return true;
2612 }
2613 
2615  SwXDocumentIndex& rParentIdx)
2616  : m_xParent(&rParentIdx)
2617 {
2618 }
2619 
2621 {
2622 }
2623 
2624 OUString SAL_CALL
2626 {
2627  return "SwXDocumentIndex::TokenAccess_Impl";
2628 }
2629 
2631  const OUString& rServiceName)
2632 {
2633  return cppu::supportsService(this, rServiceName);
2634 }
2635 
2636 uno::Sequence< OUString > SAL_CALL
2638 {
2639  return { "com.sun.star.text.DocumentIndexLevelFormat" };
2640 }
2641 
2642 namespace {
2643 
2644 struct TokenType_ {
2645  const char *pName;
2646  enum FormTokenType eTokenType;
2647 };
2648 
2649 }
2650 
2651 const struct TokenType_ g_TokenTypes[] =
2652 {
2653  { "TokenEntryNumber", TOKEN_ENTRY_NO },
2654  { "TokenEntryText", TOKEN_ENTRY_TEXT },
2655  { "TokenTabStop", TOKEN_TAB_STOP },
2656  { "TokenText", TOKEN_TEXT },
2657  { "TokenPageNumber", TOKEN_PAGE_NUMS },
2658  { "TokenChapterInfo", TOKEN_CHAPTER_INFO },
2659  { "TokenHyperlinkStart", TOKEN_LINK_START },
2660  { "TokenHyperlinkEnd", TOKEN_LINK_END },
2661  { "TokenBibliographyDataField", TOKEN_AUTHORITY },
2662  { nullptr, static_cast<enum FormTokenType>(0) }
2663 };
2664 
2665 void SAL_CALL
2667  sal_Int32 nIndex, const uno::Any& rElement)
2668 {
2669  SolarMutexGuard aGuard;
2670 
2671  SwTOXBase & rTOXBase( m_xParent->m_pImpl->GetTOXSectionOrThrow() );
2672 
2673  if ((nIndex < 0) || (nIndex > rTOXBase.GetTOXForm().GetFormMax()))
2674  {
2675  throw lang::IndexOutOfBoundsException();
2676  }
2677 
2678  uno::Sequence<beans::PropertyValues> aSeq;
2679  if(!(rElement >>= aSeq))
2680  {
2681  throw lang::IllegalArgumentException();
2682  }
2683 
2684  OUStringBuffer sPattern;
2685  for(const beans::PropertyValues& rToken : std::as_const(aSeq))
2686  {
2687  const beans::PropertyValue* pProperties = rToken.getConstArray();
2688  const sal_Int32 nProperties = rToken.getLength();
2689  //create an invalid token
2690  SwFormToken aToken(TOKEN_END);
2691  for(sal_Int32 j = 0; j < nProperties; j++)
2692  {
2693  if ( pProperties[j].Name == "TokenType" )
2694  {
2695  const OUString sTokenType =
2696  lcl_AnyToType<OUString>(pProperties[j].Value);
2697  for (TokenType_ const* pTokenType = g_TokenTypes;
2698  pTokenType->pName; ++pTokenType)
2699  {
2700  if (sTokenType.equalsAscii(pTokenType->pName))
2701  {
2702  aToken.eTokenType = pTokenType->eTokenType;
2703  break;
2704  }
2705  }
2706  }
2707  else if ( pProperties[j].Name == "CharacterStyleName" )
2708  {
2709  OUString sCharStyleName;
2711  lcl_AnyToType<OUString>(pProperties[j].Value),
2712  sCharStyleName,
2714  aToken.sCharStyleName = sCharStyleName;
2716  sCharStyleName, SwGetPoolIdFromName::ChrFmt );
2717  }
2718  else if ( pProperties[j].Name == "TabStopRightAligned" )
2719  {
2720  const bool bRight = lcl_AnyToType<bool>(pProperties[j].Value);
2721  aToken.eTabAlign = bRight ?
2722  SvxTabAdjust::End : SvxTabAdjust::Left;
2723  }
2724  else if ( pProperties[j].Name == "TabStopPosition" )
2725  {
2726  sal_Int32 nPosition = 0;
2727  if (!(pProperties[j].Value >>= nPosition))
2728  {
2729  throw lang::IllegalArgumentException();
2730  }
2731  nPosition = o3tl::toTwips(nPosition, o3tl::Length::mm100);
2732  if(nPosition < 0)
2733  {
2734  throw lang::IllegalArgumentException();
2735  }
2736  aToken.nTabStopPosition = nPosition;
2737  }
2738  else if ( pProperties[j].Name == "TabStopFillCharacter" )
2739  {
2740  const OUString sFillChar =
2741  lcl_AnyToType<OUString>(pProperties[j].Value);
2742  if (sFillChar.getLength() > 1)
2743  {
2744  throw lang::IllegalArgumentException();
2745  }
2746  aToken.cTabFillChar =
2747  sFillChar.isEmpty() ? ' ' : sFillChar[0];
2748  }
2749  else if ( pProperties[j].Name == "Text" )
2750  {
2751  aToken.sText = lcl_AnyToType<OUString>(pProperties[j].Value);
2752  }
2753  else if ( pProperties[j].Name == "ChapterFormat" )
2754  {
2755  sal_Int16 nFormat = lcl_AnyToType<sal_Int16>(pProperties[j].Value);
2756  switch(nFormat)
2757  {
2758  case text::ChapterFormat::NUMBER:
2759  nFormat = CF_NUMBER;
2760  break;
2762  nFormat = CF_TITLE;
2763  break;
2764  case text::ChapterFormat::NAME_NUMBER:
2765  nFormat = CF_NUM_TITLE;
2766  break;
2767  case text::ChapterFormat::NO_PREFIX_SUFFIX:
2768  nFormat = CF_NUMBER_NOPREPST;
2769  break;
2770  case text::ChapterFormat::DIGIT:
2771  nFormat = CF_NUM_NOPREPST_TITLE;
2772  break;
2773  default:
2774  throw lang::IllegalArgumentException();
2775  }
2776  aToken.nChapterFormat = nFormat;
2777  }
2778 // #i53420#
2779  else if ( pProperties[j].Name == "ChapterLevel" )
2780  {
2781  const sal_Int16 nLevel = lcl_AnyToType<sal_Int16>(pProperties[j].Value);
2782  if( nLevel < 1 || nLevel > MAXLEVEL )
2783  {
2784  throw lang::IllegalArgumentException();
2785  }
2786  aToken.nOutlineLevel = nLevel;
2787  }
2788  else if ( pProperties[j].Name == "BibliographyDataField" )
2789  {
2790  sal_Int16 nType = 0;
2791  pProperties[j].Value >>= nType;
2792  if(nType < 0 || nType > text::BibliographyDataField::LOCAL_URL)
2793  {
2794  lang::IllegalArgumentException aExcept;
2795  aExcept.Message = "BibliographyDataField - wrong value";
2796  aExcept.ArgumentPosition = static_cast< sal_Int16 >(j);
2797  throw aExcept;
2798  }
2799  aToken.nAuthorityField = nType;
2800  }
2801  // #i21237#
2802  else if ( pProperties[j].Name == "WithTab" )
2803  {
2804  aToken.bWithTab = lcl_AnyToType<bool>(pProperties[j].Value);
2805  }
2806 
2807  }
2808  //exception if wrong TokenType
2809  if(TOKEN_END <= aToken.eTokenType )
2810  {
2811  throw lang::IllegalArgumentException();
2812  }
2813  // set TokenType from TOKEN_ENTRY_TEXT to TOKEN_ENTRY if it is
2814  // not a content index
2815  if(TOKEN_ENTRY_TEXT == aToken.eTokenType &&
2816  (TOX_CONTENT != rTOXBase.GetType()))
2817  {
2818  aToken.eTokenType = TOKEN_ENTRY;
2819  }
2820 // #i53420#
2821 // check for chapter format allowed values if it was TOKEN_ENTRY_NO type
2822 // only allowed value are CF_NUMBER and CF_NUM_NOPREPST_TITLE
2823 // reading from file
2824  if( TOKEN_ENTRY_NO == aToken.eTokenType )
2825  {
2826  switch(aToken.nChapterFormat)
2827  {
2828  case CF_NUMBER:
2829  case CF_NUM_NOPREPST_TITLE:
2830  break;
2831  default:
2832  throw lang::IllegalArgumentException();
2833  }
2834  }
2835 
2836  if (rTOXBase.GetType() == TOX_CONTENT)
2837  {
2838  if (aToken.eTokenType == TOKEN_LINK_START && aToken.sCharStyleName.isEmpty())
2839  {
2840  aToken.sCharStyleName = SwResId(STR_POOLCHR_TOXJUMP);
2841  }
2842  }
2843 
2844  sPattern.append(aToken.GetString());
2845  }
2846  SwForm aForm(rTOXBase.GetTOXForm());
2847  aForm.SetPattern(o3tl::narrowing<sal_uInt16>(nIndex), sPattern.makeStringAndClear());
2848  rTOXBase.SetTOXForm(aForm);
2849 }
2850 
2851 sal_Int32 SAL_CALL
2853 {
2854  SolarMutexGuard aGuard;
2855 
2856  const sal_Int32 nRet = m_xParent->m_pImpl->GetFormMax();
2857  return nRet;
2858 }
2859 
2860 uno::Any SAL_CALL
2862 {
2863  SolarMutexGuard aGuard;
2864 
2865  SwTOXBase & rTOXBase( m_xParent->m_pImpl->GetTOXSectionOrThrow() );
2866 
2867  if ((nIndex < 0) || (nIndex > rTOXBase.GetTOXForm().GetFormMax()))
2868  {
2869  throw lang::IndexOutOfBoundsException();
2870  }
2871 
2872  // #i21237#
2873  SwFormTokens aPattern = rTOXBase.GetTOXForm().
2874  GetPattern(o3tl::narrowing<sal_uInt16>(nIndex));
2875 
2876  sal_Int32 nTokenCount = 0;
2877  uno::Sequence< beans::PropertyValues > aRetSeq;
2878  OUString aProgCharStyle;
2879  for(const SwFormToken& aToken : aPattern) // #i21237#
2880  {
2881  nTokenCount++;
2882  aRetSeq.realloc(nTokenCount);
2883  beans::PropertyValues* pTokenProps = aRetSeq.getArray();
2884 
2885  uno::Sequence< beans::PropertyValue >& rCurTokenSeq =
2886  pTokenProps[nTokenCount-1];
2888  aToken.sCharStyleName,
2889  aProgCharStyle,
2891  switch(aToken.eTokenType)
2892  {
2893  case TOKEN_ENTRY_NO:
2894  {
2895 // #i53420#
2896 // writing to file (from doc to properties)
2897  sal_Int32 nElements = 2;
2898  sal_Int32 nCurrentElement = 0;
2899 
2900  // check for default value
2901  if (aToken.nChapterFormat != CF_NUMBER)
2902  {
2903  nElements++;//we need the element
2904  }
2905  if( aToken.nOutlineLevel != MAXLEVEL )
2906  {
2907  nElements++;
2908  }
2909 
2910  rCurTokenSeq.realloc( nElements );
2911 
2912  beans::PropertyValue* pArr = rCurTokenSeq.getArray();
2913 
2914  pArr[nCurrentElement].Name = "TokenType";
2915  pArr[nCurrentElement++].Value <<=
2916  OUString("TokenEntryNumber");
2917 
2918  pArr[nCurrentElement].Name = "CharacterStyleName";
2919  pArr[nCurrentElement++].Value <<= aProgCharStyle;
2920  if( aToken.nChapterFormat != CF_NUMBER )
2921  {
2922  pArr[nCurrentElement].Name = "ChapterFormat";
2923  sal_Int16 nVal;
2924 // the allowed values for chapter format, when used as entry number,
2925 // are CF_NUMBER and CF_NUM_NOPREPST_TITLE only, all else forced to
2926 //CF_NUMBER
2927  switch(aToken.nChapterFormat)
2928  {
2929  default:
2930  case CF_NUMBER:
2931  nVal = text::ChapterFormat::NUMBER;
2932  break;
2933  case CF_NUM_NOPREPST_TITLE:
2934  nVal = text::ChapterFormat::DIGIT;
2935  break;
2936  }
2937  pArr[nCurrentElement++].Value <<= nVal;
2938  }
2939 
2940  // only a ChapterLevel != MAXLEVEL is registered
2941  if (aToken.nOutlineLevel != MAXLEVEL)
2942  {
2943  pArr[nCurrentElement].Name = "ChapterLevel";
2944  pArr[nCurrentElement].Value <<= aToken.nOutlineLevel;
2945  }
2946  }
2947  break;
2948  case TOKEN_ENTRY: // no difference between Entry and Entry Text
2949  case TOKEN_ENTRY_TEXT:
2950  {
2951  rCurTokenSeq.realloc( 2 );
2952  beans::PropertyValue* pArr = rCurTokenSeq.getArray();
2953 
2954  pArr[0].Name = "TokenType";
2955  pArr[0].Value <<= OUString("TokenEntryText");
2956 
2957  pArr[1].Name = "CharacterStyleName";
2958  pArr[1].Value <<= aProgCharStyle;
2959  }
2960  break;
2961  case TOKEN_TAB_STOP:
2962  {
2963  rCurTokenSeq.realloc(5); // #i21237#
2964  beans::PropertyValue* pArr = rCurTokenSeq.getArray();
2965 
2966  pArr[0].Name = "TokenType";
2967  pArr[0].Value <<= OUString("TokenTabStop");
2968 
2969  if(SvxTabAdjust::End == aToken.eTabAlign)
2970  {
2971  pArr[1].Name = "TabStopRightAligned";
2972  pArr[1].Value <<= true;
2973  }
2974  else
2975  {
2976  pArr[1].Name = "TabStopPosition";
2977  sal_Int32 nPos = convertTwipToMm100(aToken.nTabStopPosition);
2978  if(nPos < 0)
2979  nPos = 0;
2980  pArr[1].Value <<= nPos;
2981  }
2982  pArr[2].Name = "TabStopFillCharacter";
2983  pArr[2].Value <<= OUString(aToken.cTabFillChar);
2984  pArr[3].Name = "CharacterStyleName";
2985  pArr[3].Value <<= aProgCharStyle;
2986  // #i21237#
2987  pArr[4].Name = "WithTab";
2988  pArr[4].Value <<= aToken.bWithTab;
2989  }
2990  break;
2991  case TOKEN_TEXT:
2992  {
2993  rCurTokenSeq.realloc( 3 );
2994  beans::PropertyValue* pArr = rCurTokenSeq.getArray();
2995 
2996  pArr[0].Name = "TokenType";
2997  pArr[0].Value <<= OUString("TokenText");
2998 
2999  pArr[1].Name = "CharacterStyleName";
3000  pArr[1].Value <<= aProgCharStyle;
3001 
3002  pArr[2].Name = "Text";
3003  pArr[2].Value <<= aToken.sText;
3004  }
3005  break;
3006  case TOKEN_PAGE_NUMS:
3007  {
3008  rCurTokenSeq.realloc( 2 );
3009  beans::PropertyValue* pArr = rCurTokenSeq.getArray();
3010 
3011  pArr[0].Name = "TokenType";
3012  pArr[0].Value <<= OUString("TokenPageNumber");
3013 
3014  pArr[1].Name = "CharacterStyleName";
3015  pArr[1].Value <<= aProgCharStyle;
3016  }
3017  break;
3018  case TOKEN_CHAPTER_INFO:
3019  {
3020  rCurTokenSeq.realloc( 4 );
3021  beans::PropertyValue* pArr = rCurTokenSeq.getArray();
3022 
3023  pArr[0].Name = "TokenType";
3024  pArr[0].Value <<= OUString("TokenChapterInfo");
3025 
3026  pArr[1].Name = "CharacterStyleName";
3027  pArr[1].Value <<= aProgCharStyle;
3028 
3029  pArr[2].Name = "ChapterFormat";
3030  sal_Int16 nVal = text::ChapterFormat::NUMBER;
3031  switch(aToken.nChapterFormat)
3032  {
3033  case CF_NUMBER:
3034  nVal = text::ChapterFormat::NUMBER;
3035  break;
3036  case CF_TITLE:
3038  break;
3039  case CF_NUM_TITLE:
3040  nVal = text::ChapterFormat::NAME_NUMBER;
3041  break;
3042  case CF_NUMBER_NOPREPST:
3043  nVal = text::ChapterFormat::NO_PREFIX_SUFFIX;
3044  break;
3045  case CF_NUM_NOPREPST_TITLE:
3046  nVal = text::ChapterFormat::DIGIT;
3047  break;
3048  }
3049  pArr[2].Value <<= nVal;
3050 // #i53420#
3051  pArr[3].Name = "ChapterLevel";
3052  pArr[3].Value <<= aToken.nOutlineLevel;
3053  }
3054  break;
3055  case TOKEN_LINK_START:
3056  {
3057  rCurTokenSeq.realloc( 2 );
3058  beans::PropertyValue* pArr = rCurTokenSeq.getArray();
3059 
3060  pArr[0].Name = "TokenType";
3061  pArr[0].Value <<=
3062  OUString("TokenHyperlinkStart");
3063  pArr[1].Name = "CharacterStyleName";
3064  pArr[1].Value <<= aProgCharStyle;
3065  }
3066  break;
3067  case TOKEN_LINK_END:
3068  {
3069  rCurTokenSeq.realloc( 1 );
3070  beans::PropertyValue* pArr = rCurTokenSeq.getArray();
3071 
3072  pArr[0].Name = "TokenType";
3073  pArr[0].Value <<=
3074  OUString("TokenHyperlinkEnd");
3075  }
3076  break;
3077  case TOKEN_AUTHORITY:
3078  {
3079  rCurTokenSeq.realloc( 3 );
3080  beans::PropertyValue* pArr = rCurTokenSeq.getArray();
3081 
3082  pArr[0].Name = "TokenType";
3083  pArr[0].Value <<=
3084  OUString("TokenBibliographyDataField");
3085 
3086  pArr[1].Name = "CharacterStyleName";
3087  pArr[1].Value <<= aProgCharStyle;
3088 
3089  pArr[2].Name = "BibliographyDataField";
3090  pArr[2].Value <<= sal_Int16(aToken.nAuthorityField);
3091  }
3092  break;
3093 
3094  default:
3095  ;
3096  }
3097  }
3098 
3099  uno::Any aRet;
3100  aRet <<= aRetSeq;
3101  return aRet;
3102 }
3103 
3104 uno::Type SAL_CALL
3106 {
3108 }
3109 
3110 sal_Bool SAL_CALL
3112 {
3113  return true;
3114 }
3115 
3116 /* 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:1294
virtual void SAL_CALL removePropertyChangeListener(const OUString &rPropertyName, const css::uno::Reference< css::beans::XPropertyChangeListener > &xListener) override
Definition: unoidx.cxx:2300
const SwEndNode * EndOfSectionNode() const
Definition: node.hxx:683
std::vector< SwFormToken > SwFormTokens
Vector of tokens.
Definition: tox.hxx:289
static void lcl_CalcLayout(SwDoc *pDoc)
Definition: unoidx.cxx:1223
virtual uno::Any SAL_CALL getByIndex(sal_Int32 nIndex) override
Definition: unoidx.cxx:2572
TOXTypes
Definition: toxe.hxx:39
void DeleteMark()
Definition: pam.hxx:177
static sal_uInt16 lcl_TypeToPropertyMap_Mark(const TOXTypes eType)
Definition: unoidx.cxx:1475
#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:166
#define WID_IS_COMMA_SEPARATED
Definition: unomap.hxx:210
SwTOIOptions
Definition: tox.hxx:390
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
void ReplaceTOXMark(SwTOXType &rTOXType, SwTOXMark &rMark, SwPaM &rPam)
Definition: unoidx.cxx:1558
virtual uno::Type SAL_CALL getElementType() override
Definition: unoidx.cxx:3105
TokenAccess_Impl(SwXDocumentIndex &rParentIdx)
Definition: unoidx.cxx:2614
SwTOXElement GetCreateType() const
Definition: tox.hxx:717
virtual sal_Bool SAL_CALL hasElements() override
Definition: unoidx.cxx:3111
virtual void SAL_CALL setMarkEntry(const OUString &rIndexEntry) override
Definition: unoidx.cxx:1729
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:2402
constexpr auto toTwips(N number, Length from)
#define WID_CREATE_FROM_STAR_DRAW
Definition: unomap.hxx:195
void SetPattern(sal_uInt16 nLevel, const SwFormTokens &rName)
Definition: tox.cxx:937
virtual void SAL_CALL removeVetoableChangeListener(const OUString &rPropertyName, const css::uno::Reference< css::beans::XVetoableChangeListener > &xListener) override
Definition: unoidx.cxx:1216
static ShellResource * GetShellRes()
Definition: viewsh.cxx:2553
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:984
#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:255
virtual sal_Int32 SAL_CALL getCount() override
Definition: unoidx.cxx:2350
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:608
virtual void SAL_CALL removeRefreshListener(const css::uno::Reference< css::util::XRefreshListener > &xListener) override
Definition: unoidx.cxx:1285
static SwTOXBase * GetCurTOX(const SwPosition &rPos)
Get current table of contents.
Definition: doctxm.cxx:447
SwTOOElements
Definition: tox.hxx:413
Definition: tox.hxx:316
SwNodeIndex nNode
Definition: pam.hxx:37
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
static LanguageType convertToLanguageType(const css::lang::Locale &rLocale, bool bResolveSystem=true)
virtual css::uno::Reference< css::frame::XModel > GetModel() override
Definition: unoidx.cxx:1463
#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:168
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:1208
OUString const & GetTemplate(sal_uInt16 nLevel) const
Definition: tox.hxx:688
const SwPosition * GetMark() const
Definition: pam.hxx:209
void SetEntryTypeName(const OUString &sName)
Definition: tox.hxx:604
void CollectTextMarks(SwTOXMarks &rMarks) const
Definition: tox.hxx:187
#define PROPERTY_MAP_INDEX_IDX
Definition: unomap.hxx:43
#define TOX_STYLE_DELIMITER
Definition: tox.hxx:426
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
void disposeAndClear(const css::lang::EventObject &rEvt)
SwSectionFormat * GetSectionFormat() const
Definition: unoidx.cxx:330
bool IsAtEndOfMeta() const
Definition: unoobj.cxx:795
#define WID_CREATE_FROM_TABLES
Definition: unomap.hxx:186
#define WID_USE_P_P
Definition: unomap.hxx:175
::comphelper::OInterfaceContainerHelper2 m_EventListeners
Definition: unoidx.cxx:1500
::osl::Mutex m_Mutex
Definition: unoidx.cxx:294
SwNode & GetNode() const
Definition: ndindex.hxx:119
#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:2316
#define WID_PRIMARY_KEY
Definition: unomap.hxx:161
SwSectionFormat * GetFormat()
Definition: section.hxx:336
sal_uInt16 GetFormMax() const
Definition: tox.hxx:699
const TOXTypes m_eTOXType
Definition: unoidx.cxx:301
OUString Name
const SwTOXType * GetTOXType() const
Definition: tox.hxx:588
virtual css::uno::Any SAL_CALL getByIndex(sal_Int32 nIndex) override
Definition: unoidx.cxx:2372
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:2861
virtual uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
Definition: unoidx.cxx:2524
static void lcl_ConvertTOUNameToUserName(OUString &rTmp)
Definition: unoidx.cxx:145
sal_uInt16 nPoolId
Definition: tox.hxx:252
const SwTOXType * m_pTOXType
Definition: unoidx.cxx:1502
virtual void SAL_CALL refresh() override
Definition: unoidx.cxx:1244
SwXDocumentIndexes(SwDoc *const pDoc)
Definition: unoidx.cxx:2323
constexpr OUStringLiteral cUserDefined
Definition: unoidx.cxx:123
bool bWithTab
Definition: tox.hxx:258
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:257
virtual OUString SAL_CALL getMarkEntry() override
Definition: unoidx.cxx:1710
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:1352
Array of Undo-history.
Definition: docary.hxx:192
virtual css::uno::Sequence< OUString > SAL_CALL getElementNames() override
Definition: unoidx.cxx:2430
constexpr auto convertTwipToMm100(N n)
virtual sal_Bool SAL_CALL supportsService(const OUString &rServiceName) override
Definition: unoidx.cxx:1675
OUString SwResId(TranslateId aId)
Definition: swmodule.cxx:165
Value
SwXDocumentIndexMark & m_rThis
Definition: unoidx.cxx:1492
const SwDoc & GetDoc() const
Definition: unoobj2.cxx:767
const SwTOXType * GetTOXType() const
Definition: tox.hxx:714
virtual void SAL_CALL attach(const css::uno::Reference< css::text::XTextRange > &xTextRange) override
Definition: unoidx.cxx:1762
#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:553
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:1427
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:248
int nCount
virtual ::sfx2::Metadatable * GetCoreObject() override
Definition: unoidx.cxx:1457
virtual sal_Int32 SAL_CALL getCount() override
Definition: unoidx.cxx:2852
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:1596
#define WID_USE_DASH
Definition: unomap.hxx:176
virtual OUString SAL_CALL getImplementationName() override
Definition: unoidx.cxx:2512
#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:1400
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:594
void Normalize(bool bPointFirst=true)
Normalizes PaM, i.e.
Definition: pam.cxx:541
sal_Int32 getTokenCount(std::string_view rIn, char cTok)
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:579
#define WID_PARA_LEV6
Definition: unomap.hxx:205
PaM is Point and Mark: a selection of the document model.
Definition: pam.hxx:136
static OUString GetProviderName(SwServiceType nObjectType)
Definition: unocoll.cxx:472
OUString GetString() const
Definition: tox.cxx:663
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:2625
#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:1985
virtual sal_Bool SAL_CALL supportsService(const OUString &rServiceName) override
Definition: unoidx.cxx:2518
virtual css::uno::Any SAL_CALL getPropertyValue(const OUString &rPropertyName) override
Definition: unoidx.cxx:861
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
Definition: unoidx.cxx:1681
#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:1664
number and title
Definition: chpfld.hxx:34
#define PROPERTY_MAP_INDEX_MARK
Definition: unomap.hxx:46
void InsertTOXMark(SwTOXType &rTOXType, SwTOXMark &rMark, SwPaM &rPam, SwXTextCursor const *const pTextCursor)
Definition: unoidx.cxx:1898
int i
void SetPrimaryKey(const OUString &rStr)
Definition: tox.hxx:614
virtual OUString SAL_CALL getServiceName() override
Definition: unoidx.cxx:487
SwTOXElement
Definition: tox.hxx:368
#define PROPERTY_MAP_INDEX_USER
Definition: unomap.hxx:41
const SwPosition * GetPoint() const
Definition: pam.hxx:207
void SetTextReading(const OUString &rStr)
Definition: tox.hxx:626
FormTokenType eTokenType
Definition: tox.hxx:251
virtual sal_Bool SAL_CALL supportsService(const OUString &rServiceName) override
Definition: unoidx.cxx:2338
SwEditShell const * GetEditShell() const
Definition: doccorr.cxx:328
OUString sCharStyleName
Definition: tox.hxx:249
#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:2637
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:632
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:1192
float u
virtual uno::Type SAL_CALL getElementType() override
Definition: unoidx.cxx:2603
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:1625
virtual OUString SAL_CALL getImplementationName() override
Definition: unoidx.cxx:2333
virtual sal_Bool SAL_CALL supportsService(const OUString &rServiceName) override
Definition: unoidx.cxx:2630
virtual void SAL_CALL addRefreshListener(const css::uno::Reference< css::util::XRefreshListener > &xListener) override
Definition: unoidx.cxx:1277
const OUString & GetTypeName() const
Definition: tox.hxx:706
static const css::uno::Sequence< sal_Int8 > & getUnoTunnelId()
Definition: unoidx.cxx:1657
virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo() override
Definition: unoidx.cxx:2013
#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:254
Marks a node in the document model.
Definition: ndindex.hxx:31
css::uno::Type const & get()
#define WID_INDEX_MARKS
Definition: unomap.hxx:211
sal_uInt16 nAuthorityField
Definition: tox.hxx:256
virtual void SAL_CALL setPropertyValue(const OUString &rPropertyName, const css::uno::Any &rValue) override
Definition: unoidx.cxx:2042
#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:444
#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
const SwPosition * Start() const
Definition: pam.hxx:212
#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:1200
#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:1497
const SwTextNode & GetTextNode() const
Definition: txttxmrk.hxx:49
virtual css::uno::Reference< css::text::XTextRange > SAL_CALL getAnchor() override
Definition: unoidx.cxx:1951
#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:347
virtual void SAL_CALL removeEventListener(const css::uno::Reference< css::lang::XEventListener > &xListener) override
Definition: unoidx.cxx:2005
const SwTOXMark * m_pTOXMark
Definition: unoidx.cxx:1503
virtual OUString SAL_CALL getName() override
Definition: unoidx.cxx:1408
#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:250
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:2490
virtual void SAL_CALL replaceByIndex(sal_Int32 Index, const uno::Any &rElement) override
Definition: unoidx.cxx:2666
virtual const SwViewShell * GetCurrentViewShell() const =0
Returns the layout set at the document.
virtual sal_Bool SAL_CALL hasElements() override
Definition: unoidx.cxx:2609
SwMoveFnCollection const & fnMoveForward
SwPam::Move()/Find() default argument.
Definition: paminit.cxx:59
SwXDocumentIndexMark(SwDoc &rDoc, SwTOXType &rType, SwTOXMark &rMark)
Definition: unoidx.cxx:1613
virtual void SAL_CALL addVetoableChangeListener(const OUString &rPropertyName, const css::uno::Reference< css::beans::XVetoableChangeListener > &xListener) override
Definition: unoidx.cxx:2308
static void lcl_ConvertTOUNameToProgrammaticName(OUString &rTmp)
Definition: unoidx.cxx:128
OUString const & GetStyleNames(sal_uInt16 nLevel) const
Definition: tox.hxx:528
#define WID_CREATE_FROM_TEXT_FRAMES
Definition: unomap.hxx:187
bool IsCommaSeparated() const
Definition: tox.hxx:350
static void FillProgName(const OUString &rName, OUString &rFillName, SwGetPoolIdFromName)
virtual ~TokenAccess_Impl() override
Definition: unoidx.cxx:2620
virtual css::uno::Any SAL_CALL getPropertyValue(const OUString &rPropertyName) override
Definition: unoidx.cxx:2179
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:599
const sal_Int32 * End() const
Definition: txatbase.hxx:152
#define WID_INDEX_ENTRY_TYPE
Definition: unomap.hxx:226
Impl(SwXDocumentIndexMark &rThis, SwDoc *const pDoc, const enum TOXTypes eType, const SwTOXType *pType, SwTOXMark const *pMark)
Definition: unoidx.cxx:1518
#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:1377
#define PROPERTY_MAP_FLDTYP_BIBLIOGRAPHY
Definition: unomap.hxx:110
Sequence< sal_Int8 > aSeq
void SetSecondaryKey(const OUString &rStr)
Definition: tox.hxx:620
#define WID_PARA_HEAD
Definition: unomap.hxx:198
TOXTypes GetType() const
Definition: tox.hxx:709
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:1499
#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:2507
static const css::uno::Sequence< sal_Int8 > & getUnoTunnelId()
Definition: unoidx.cxx:428
SvxTabAdjust eTabAlign
Definition: tox.hxx:253
#define WID_PARA_LEV8
Definition: unomap.hxx:207
#define WID_PROTECTED
Definition: unomap.hxx:191
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:243
SwXDocumentIndex(SwTOXBaseSection &, SwDoc &)
Definition: unoidx.cxx:384
virtual ~SwXDocumentIndexMark() override
Definition: unoidx.cxx:1620
#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:2530
const SwForm & GetTOXForm() const
Definition: tox.hxx:732
::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:1498
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
Definition: unoidx.cxx:2344
static T lcl_AnyToType(uno::Any const &rVal)
Definition: unoidx.cxx:72
void SetSecondaryKeyReading(const OUString &rStr)
Definition: tox.hxx:638
#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:2566
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:159
virtual ~SwXDocumentIndex() override
Definition: unoidx.cxx:396
FormTokenType
Definition: tox.hxx:231
virtual void SAL_CALL addEventListener(const css::uno::Reference< css::lang::XEventListener > &xListener) override
Definition: unoidx.cxx:1391
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:2501
virtual OUString SAL_CALL getImplementationName() override
Definition: unoidx.cxx:1670
virtual void SAL_CALL addPropertyChangeListener(const OUString &rPropertyName, const css::uno::Reference< css::beans::XPropertyChangeListener > &xListener) override
Definition: unoidx.cxx:2292
const SfxItemPropertyMapEntry * GetPropertyMapEntries(sal_uInt16 PropertyId)
Definition: unomap.cxx:71
sal_uInt16 nPos
SwTOXType * GetTOXType() const
Definition: unoidx.cxx:1545
#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:2465
const struct TokenType_ g_TokenTypes[]
Definition: unoidx.cxx:2651
virtual sal_Bool SAL_CALL hasElements() override
Definition: unoidx.cxx:2496
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:1997
#define WID_IS_CASE_SENSITIVE
Definition: unomap.hxx:174
#define PROPERTY_MAP_INDEX_TABLES
Definition: unomap.hxx:54
virtual ~SwXDocumentIndexes() override
Definition: unoidx.cxx:2328