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