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