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