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