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