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