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