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