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