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