xref: /aoo41x/main/sw/source/core/tox/txmsrt.cxx (revision 69a74367)
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 
28cdf0e10cSrcweir #include <tools/resid.hxx>
29cdf0e10cSrcweir #include <unotools/charclass.hxx>
30cdf0e10cSrcweir #include <com/sun/star/i18n/CollatorOptions.hpp>
31cdf0e10cSrcweir #include <editeng/unolingu.hxx>
32cdf0e10cSrcweir #include <txtfld.hxx>
33cdf0e10cSrcweir #include <doc.hxx>
34cdf0e10cSrcweir #include <docary.hxx>
35cdf0e10cSrcweir #include <cntfrm.hxx>
36cdf0e10cSrcweir #include <node.hxx>
37cdf0e10cSrcweir #include <frmatr.hxx>
38cdf0e10cSrcweir #include <pam.hxx>
39cdf0e10cSrcweir #include <txttxmrk.hxx>
40cdf0e10cSrcweir #include <frmfmt.hxx>
41cdf0e10cSrcweir #include <fmtfld.hxx>
42cdf0e10cSrcweir #include <txmsrt.hxx>
43cdf0e10cSrcweir #include <ndtxt.hxx>
44cdf0e10cSrcweir #include <txtatr.hxx>
45cdf0e10cSrcweir #include <swtable.hxx>
46cdf0e10cSrcweir #include <expfld.hxx>
47cdf0e10cSrcweir #include <authfld.hxx>
48cdf0e10cSrcweir #include <toxwrap.hxx>
49cdf0e10cSrcweir 
50cdf0e10cSrcweir #include <comcore.hrc>
51cdf0e10cSrcweir #include <numrule.hxx>
52cdf0e10cSrcweir 
53cdf0e10cSrcweir extern sal_Bool IsFrameBehind( const SwTxtNode& rMyNd, xub_StrLen nMySttPos,
54cdf0e10cSrcweir 						   const SwTxtNode& rBehindNd, xub_StrLen nSttPos );
55cdf0e10cSrcweir 
56cdf0e10cSrcweir using namespace ::com::sun::star;
57cdf0e10cSrcweir using namespace ::com::sun::star::uno;
58cdf0e10cSrcweir using ::rtl::OUString;
59cdf0e10cSrcweir /*--------------------------------------------------------------------
60cdf0e10cSrcweir 	Beschreibung: Strings initialisieren
61cdf0e10cSrcweir  --------------------------------------------------------------------*/
62cdf0e10cSrcweir 
63cdf0e10cSrcweir sal_uInt16 SwTOXSortTabBase::nOpt = 0;
64cdf0e10cSrcweir 
SV_IMPL_VARARR(SwTOXSources,SwTOXSource)65cdf0e10cSrcweir SV_IMPL_VARARR( SwTOXSources, SwTOXSource )
66cdf0e10cSrcweir 
67cdf0e10cSrcweir 
68cdf0e10cSrcweir SwTOXInternational::SwTOXInternational( LanguageType nLang, sal_uInt16 nOpt,
69cdf0e10cSrcweir                                         const String& rSortAlgorithm ) :
70cdf0e10cSrcweir     eLang( nLang ),
71cdf0e10cSrcweir     sSortAlgorithm(rSortAlgorithm),
72cdf0e10cSrcweir     nOptions( nOpt )
73cdf0e10cSrcweir {
74cdf0e10cSrcweir 	Init();
75cdf0e10cSrcweir }
76cdf0e10cSrcweir 
SwTOXInternational(const SwTOXInternational & rIntl)77cdf0e10cSrcweir SwTOXInternational::SwTOXInternational( const SwTOXInternational& rIntl ) :
78cdf0e10cSrcweir     eLang( rIntl.eLang ),
79cdf0e10cSrcweir     sSortAlgorithm(rIntl.sSortAlgorithm),
80cdf0e10cSrcweir     nOptions( rIntl.nOptions )
81cdf0e10cSrcweir {
82cdf0e10cSrcweir   Init();
83cdf0e10cSrcweir }
84cdf0e10cSrcweir 
Init()85cdf0e10cSrcweir void SwTOXInternational::Init()
86cdf0e10cSrcweir {
87cdf0e10cSrcweir 	pIndexWrapper = new IndexEntrySupplierWrapper();
88cdf0e10cSrcweir 
89cdf0e10cSrcweir     const lang::Locale aLcl( SvxCreateLocale( eLang ) );
90cdf0e10cSrcweir     pIndexWrapper->SetLocale( aLcl );
91cdf0e10cSrcweir 
92cdf0e10cSrcweir     if(!sSortAlgorithm.Len())
93cdf0e10cSrcweir     {
94cdf0e10cSrcweir         Sequence < OUString > aSeq( pIndexWrapper->GetAlgorithmList( aLcl ));
95cdf0e10cSrcweir         if(aSeq.getLength())
96cdf0e10cSrcweir             sSortAlgorithm = aSeq.getConstArray()[0];
97cdf0e10cSrcweir     }
98cdf0e10cSrcweir 
99cdf0e10cSrcweir     if ( nOptions & nsSwTOIOptions::TOI_CASE_SENSITIVE )
100cdf0e10cSrcweir         pIndexWrapper->LoadAlgorithm( aLcl, sSortAlgorithm, 0 );
101cdf0e10cSrcweir     else
102cdf0e10cSrcweir         pIndexWrapper->LoadAlgorithm( aLcl, sSortAlgorithm, SW_COLLATOR_IGNORES );
103cdf0e10cSrcweir 
104cdf0e10cSrcweir 	pCharClass = new CharClass( aLcl );
105cdf0e10cSrcweir 
106cdf0e10cSrcweir }
107cdf0e10cSrcweir 
~SwTOXInternational()108cdf0e10cSrcweir SwTOXInternational::~SwTOXInternational()
109cdf0e10cSrcweir {
110cdf0e10cSrcweir 	delete pCharClass;
111cdf0e10cSrcweir 	delete pIndexWrapper;
112cdf0e10cSrcweir }
113cdf0e10cSrcweir 
ToUpper(const String & rStr,xub_StrLen nPos) const114cdf0e10cSrcweir String SwTOXInternational::ToUpper( const String& rStr, xub_StrLen nPos ) const
115cdf0e10cSrcweir {
116cdf0e10cSrcweir 	return pCharClass->toUpper( rStr, nPos, 1 );
117cdf0e10cSrcweir }
IsNumeric(const String & rStr) const118cdf0e10cSrcweir inline sal_Bool SwTOXInternational::IsNumeric( const String& rStr ) const
119cdf0e10cSrcweir {
120cdf0e10cSrcweir 	return pCharClass->isNumeric( rStr );
121cdf0e10cSrcweir }
122cdf0e10cSrcweir 
Compare(const String & rTxt1,const String & rTxtReading1,const lang::Locale & rLocale1,const String & rTxt2,const String & rTxtReading2,const lang::Locale & rLocale2) const123cdf0e10cSrcweir sal_Int32 SwTOXInternational::Compare( const String& rTxt1, const String& rTxtReading1,
124cdf0e10cSrcweir                                        const lang::Locale& rLocale1,
125cdf0e10cSrcweir                                        const String& rTxt2, const String& rTxtReading2,
126cdf0e10cSrcweir                                        const lang::Locale& rLocale2 ) const
127cdf0e10cSrcweir {
128cdf0e10cSrcweir     return pIndexWrapper->CompareIndexEntry( rTxt1, rTxtReading1, rLocale1,
129cdf0e10cSrcweir                                              rTxt2, rTxtReading2, rLocale2 );
130cdf0e10cSrcweir }
131cdf0e10cSrcweir 
GetIndexKey(const String & rTxt,const String & rTxtReading,const lang::Locale & rLocale) const132cdf0e10cSrcweir String SwTOXInternational::GetIndexKey( const String& rTxt, const String& rTxtReading,
133cdf0e10cSrcweir                                         const lang::Locale& rLocale ) const
134cdf0e10cSrcweir {
135cdf0e10cSrcweir     return pIndexWrapper->GetIndexKey( rTxt, rTxtReading, rLocale );
136cdf0e10cSrcweir }
137cdf0e10cSrcweir 
GetFollowingText(sal_Bool bMorePages) const138cdf0e10cSrcweir String SwTOXInternational::GetFollowingText( sal_Bool bMorePages ) const
139cdf0e10cSrcweir {
140cdf0e10cSrcweir 	return pIndexWrapper->GetFollowingText( bMorePages );
141cdf0e10cSrcweir }
142cdf0e10cSrcweir 
143cdf0e10cSrcweir /*--------------------------------------------------------------------
144cdf0e10cSrcweir 	 Beschreibung:	SortierElement fuer Verzeichniseintraege
145cdf0e10cSrcweir  --------------------------------------------------------------------*/
146cdf0e10cSrcweir 
147cdf0e10cSrcweir 
SwTOXSortTabBase(TOXSortType nTyp,const SwCntntNode * pNd,const SwTxtTOXMark * pMark,const SwTOXInternational * pInter,const lang::Locale * pLocale)148cdf0e10cSrcweir SwTOXSortTabBase::SwTOXSortTabBase( TOXSortType nTyp, const SwCntntNode* pNd,
149cdf0e10cSrcweir 									const SwTxtTOXMark* pMark,
150cdf0e10cSrcweir                                     const SwTOXInternational* pInter,
151cdf0e10cSrcweir                                     const lang::Locale* pLocale )
152cdf0e10cSrcweir     : pTOXNd( 0 ), pTxtMark( pMark ), pTOXIntl( pInter ),
153cdf0e10cSrcweir     nPos( 0 ), nCntPos( 0 ), nType( static_cast<sal_uInt16>(nTyp) ), bValidTxt( sal_False )
154cdf0e10cSrcweir {
155cdf0e10cSrcweir     if ( pLocale )
156cdf0e10cSrcweir         aLocale = *pLocale;
157cdf0e10cSrcweir 
158cdf0e10cSrcweir     if( pNd )
159cdf0e10cSrcweir 	{
160cdf0e10cSrcweir 		xub_StrLen n = 0;
161cdf0e10cSrcweir 		if( pTxtMark )
162cdf0e10cSrcweir 			n = *pTxtMark->GetStart();
163cdf0e10cSrcweir 		SwTOXSource aTmp( pNd, n,
164cdf0e10cSrcweir 					pTxtMark ? pTxtMark->GetTOXMark().IsMainEntry() : sal_False );
165cdf0e10cSrcweir 		aTOXSources.Insert( aTmp, aTOXSources.Count() );
166cdf0e10cSrcweir 
167cdf0e10cSrcweir 		nPos = pNd->GetIndex();
168cdf0e10cSrcweir 
169cdf0e10cSrcweir 		switch( nTyp )
170cdf0e10cSrcweir 		{
171cdf0e10cSrcweir 		case TOX_SORT_CONTENT:
172cdf0e10cSrcweir 		case TOX_SORT_PARA:
173cdf0e10cSrcweir 		case TOX_SORT_TABLE:
174cdf0e10cSrcweir 			// falls sie in Sonderbereichen stehen, sollte man die
175cdf0e10cSrcweir 			// Position im Body besorgen
176cdf0e10cSrcweir 			if( nPos < pNd->GetNodes().GetEndOfExtras().GetIndex() )
177cdf0e10cSrcweir 			{
178cdf0e10cSrcweir 				// dann die "Anker" (Body) Position holen.
179cdf0e10cSrcweir 				Point aPt;
180cdf0e10cSrcweir 				const SwCntntFrm* pFrm = pNd->getLayoutFrm( pNd->GetDoc()->GetCurrentLayout(), &aPt, 0, sal_False );
181cdf0e10cSrcweir 				if( pFrm )
182cdf0e10cSrcweir 				{
183cdf0e10cSrcweir 					SwPosition aPos( *pNd );
184cdf0e10cSrcweir 					const SwDoc& rDoc = *pNd->GetDoc();
185cdf0e10cSrcweir #ifdef DBG_UTIL
186cdf0e10cSrcweir 					ASSERT( GetBodyTxtNode( rDoc, aPos, *pFrm ),
187cdf0e10cSrcweir 							"wo steht der Absatz" );
188cdf0e10cSrcweir #else
189cdf0e10cSrcweir 					GetBodyTxtNode( rDoc, aPos, *pFrm );
190cdf0e10cSrcweir #endif
191cdf0e10cSrcweir 					nPos = aPos.nNode.GetIndex();
192cdf0e10cSrcweir 					nCntPos = aPos.nContent.GetIndex();
193cdf0e10cSrcweir 				}
194cdf0e10cSrcweir 			}
195cdf0e10cSrcweir 			else
196cdf0e10cSrcweir 				nCntPos = n;
197cdf0e10cSrcweir 			break;
198cdf0e10cSrcweir         default: break;
199cdf0e10cSrcweir 		}
200cdf0e10cSrcweir 	}
201cdf0e10cSrcweir }
202cdf0e10cSrcweir 
203cdf0e10cSrcweir 
GetURL() const204cdf0e10cSrcweir String SwTOXSortTabBase::GetURL() const
205cdf0e10cSrcweir {
206cdf0e10cSrcweir 	return aEmptyStr;
207cdf0e10cSrcweir }
208cdf0e10cSrcweir 
FillText(SwTxtNode & rNd,const SwIndex & rInsPos,sal_uInt16) const209cdf0e10cSrcweir void SwTOXSortTabBase::FillText( SwTxtNode& rNd, const SwIndex& rInsPos,
210cdf0e10cSrcweir 									sal_uInt16 ) const
211cdf0e10cSrcweir {
212cdf0e10cSrcweir     String sMyTxt;
213cdf0e10cSrcweir     String sMyTxtReading;
214cdf0e10cSrcweir 
215cdf0e10cSrcweir     GetTxt( sMyTxt, sMyTxtReading );
216cdf0e10cSrcweir 
217cdf0e10cSrcweir     rNd.InsertText( sMyTxt, rInsPos );
218cdf0e10cSrcweir }
219cdf0e10cSrcweir 
operator ==(const SwTOXSortTabBase & rCmp)220cdf0e10cSrcweir sal_Bool SwTOXSortTabBase::operator==( const SwTOXSortTabBase& rCmp )
221cdf0e10cSrcweir {
222cdf0e10cSrcweir 	sal_Bool bRet = nPos == rCmp.nPos && nCntPos == rCmp.nCntPos &&
223cdf0e10cSrcweir 			(!aTOXSources[0].pNd || !rCmp.aTOXSources[0].pNd ||
224cdf0e10cSrcweir 			aTOXSources[0].pNd == rCmp.aTOXSources[0].pNd );
225cdf0e10cSrcweir 
226cdf0e10cSrcweir 	if( TOX_SORT_CONTENT == nType )
227cdf0e10cSrcweir 	{
228cdf0e10cSrcweir 		bRet = bRet && pTxtMark && rCmp.pTxtMark &&
229cdf0e10cSrcweir 				*pTxtMark->GetStart() == *rCmp.pTxtMark->GetStart();
230cdf0e10cSrcweir 
231cdf0e10cSrcweir 		if( bRet )
232cdf0e10cSrcweir 		{
233cdf0e10cSrcweir 			// beide Pointer vorhanden -> vergleiche Text
234cdf0e10cSrcweir 			// beide Pointer nicht vorhanden -> vergleiche AlternativText
235*69a74367SOliver-Rainer Wittmann             const xub_StrLen* pEnd = pTxtMark->End();
236*69a74367SOliver-Rainer Wittmann             const xub_StrLen* pEndCmp = rCmp.pTxtMark->End();
237cdf0e10cSrcweir 
238cdf0e10cSrcweir             String sMyTxt;
239cdf0e10cSrcweir             String sMyTxtReading;
240cdf0e10cSrcweir             GetTxt( sMyTxt, sMyTxtReading );
241cdf0e10cSrcweir 
242cdf0e10cSrcweir             String sOtherTxt;
243cdf0e10cSrcweir             String sOtherTxtReading;
244cdf0e10cSrcweir             rCmp.GetTxt( sOtherTxt, sOtherTxtReading );
245cdf0e10cSrcweir 
246cdf0e10cSrcweir 			bRet = ( ( pEnd && pEndCmp ) || ( !pEnd && !pEndCmp ) ) &&
247cdf0e10cSrcweir                     pTOXIntl->IsEqual( sMyTxt, sMyTxtReading, GetLocale(),
248cdf0e10cSrcweir                                        sOtherTxt, sOtherTxtReading, rCmp.GetLocale() );
249cdf0e10cSrcweir 		}
250cdf0e10cSrcweir 	}
251cdf0e10cSrcweir 	return bRet;
252cdf0e10cSrcweir }
253cdf0e10cSrcweir 
operator <(const SwTOXSortTabBase & rCmp)254cdf0e10cSrcweir sal_Bool SwTOXSortTabBase::operator<( const SwTOXSortTabBase& rCmp )
255cdf0e10cSrcweir {
256cdf0e10cSrcweir 	if( nPos < rCmp.nPos )
257cdf0e10cSrcweir 		return sal_True;
258cdf0e10cSrcweir 
259cdf0e10cSrcweir 	if( nPos == rCmp.nPos )
260cdf0e10cSrcweir 	{
261cdf0e10cSrcweir 		if( nCntPos < rCmp.nCntPos )
262cdf0e10cSrcweir 			return sal_True;
263cdf0e10cSrcweir 
264cdf0e10cSrcweir 		if( nCntPos == rCmp.nCntPos )
265cdf0e10cSrcweir 		{
266cdf0e10cSrcweir 			const SwNode* pFirst = aTOXSources[0].pNd;
267cdf0e10cSrcweir 			const SwNode* pNext = rCmp.aTOXSources[0].pNd;
268cdf0e10cSrcweir 
269cdf0e10cSrcweir 			if( pFirst && pFirst == pNext )
270cdf0e10cSrcweir 			{
271cdf0e10cSrcweir 				if( TOX_SORT_CONTENT == nType && pTxtMark && rCmp.pTxtMark )
272cdf0e10cSrcweir 				{
273cdf0e10cSrcweir 					if( *pTxtMark->GetStart() < *rCmp.pTxtMark->GetStart() )
274cdf0e10cSrcweir 						return sal_True;
275cdf0e10cSrcweir 
276cdf0e10cSrcweir 					if( *pTxtMark->GetStart() == *rCmp.pTxtMark->GetStart() )
277cdf0e10cSrcweir 					{
278*69a74367SOliver-Rainer Wittmann                         const xub_StrLen* pEnd = pTxtMark->End();
279*69a74367SOliver-Rainer Wittmann                         const xub_StrLen* pEndCmp = rCmp.pTxtMark->End();
280cdf0e10cSrcweir 
281cdf0e10cSrcweir                         String sMyTxt;
282cdf0e10cSrcweir                         String sMyTxtReading;
283cdf0e10cSrcweir                         GetTxt( sMyTxt, sMyTxtReading );
284cdf0e10cSrcweir 
285cdf0e10cSrcweir                         String sOtherTxt;
286cdf0e10cSrcweir                         String sOtherTxtReading;
287cdf0e10cSrcweir                         rCmp.GetTxt( sOtherTxt, sOtherTxtReading );
288cdf0e10cSrcweir 
289cdf0e10cSrcweir                         // beide Pointer vorhanden -> vergleiche Text
290cdf0e10cSrcweir 						// beide Pointer nicht vorhanden -> vergleiche AlternativText
291cdf0e10cSrcweir 						if( ( pEnd && pEndCmp ) || ( !pEnd && !pEndCmp ) )
292cdf0e10cSrcweir                             pTOXIntl->IsEqual( sMyTxt, sMyTxtReading, GetLocale(),
293cdf0e10cSrcweir                                                sOtherTxt, sOtherTxtReading, rCmp.GetLocale() );
294cdf0e10cSrcweir 
295cdf0e10cSrcweir 						if( pEnd && !pEndCmp )
296cdf0e10cSrcweir 							return sal_True;
297cdf0e10cSrcweir 					}
298cdf0e10cSrcweir 				}
299cdf0e10cSrcweir 			}
300cdf0e10cSrcweir 			else if( pFirst && pFirst->IsTxtNode() &&
301cdf0e10cSrcweir 					 pNext && pNext->IsTxtNode() )
302cdf0e10cSrcweir 					return ::IsFrameBehind( *(SwTxtNode*)pNext, nCntPos,
303cdf0e10cSrcweir 											*(SwTxtNode*)pFirst, nCntPos );
304cdf0e10cSrcweir 		}
305cdf0e10cSrcweir 	}
306cdf0e10cSrcweir 	return sal_False;
307cdf0e10cSrcweir }
308cdf0e10cSrcweir 
309cdf0e10cSrcweir /*--------------------------------------------------------------------
310cdf0e10cSrcweir 	 Beschreibung: sortierter Stichworteintrag
311cdf0e10cSrcweir  --------------------------------------------------------------------*/
312cdf0e10cSrcweir 
313cdf0e10cSrcweir 
SwTOXIndex(const SwTxtNode & rNd,const SwTxtTOXMark * pMark,sal_uInt16 nOptions,sal_uInt8 nKyLevel,const SwTOXInternational & rIntl,const lang::Locale & rLocale)314cdf0e10cSrcweir SwTOXIndex::SwTOXIndex( const SwTxtNode& rNd,
315cdf0e10cSrcweir                         const SwTxtTOXMark* pMark, sal_uInt16 nOptions,
316cdf0e10cSrcweir                         sal_uInt8 nKyLevel,
317cdf0e10cSrcweir                         const SwTOXInternational& rIntl,
318cdf0e10cSrcweir                         const lang::Locale& rLocale )
319cdf0e10cSrcweir     : SwTOXSortTabBase( TOX_SORT_INDEX, &rNd, pMark, &rIntl, &rLocale ),
320cdf0e10cSrcweir 	nKeyLevel(nKyLevel)
321cdf0e10cSrcweir {
322cdf0e10cSrcweir 	nPos = rNd.GetIndex();
323cdf0e10cSrcweir 	nOpt = nOptions;
324cdf0e10cSrcweir }
325cdf0e10cSrcweir 
326cdf0e10cSrcweir //
327cdf0e10cSrcweir // Stichworte vergleichen. Bezieht sich nur auf den Text
328cdf0e10cSrcweir //
329cdf0e10cSrcweir 
330cdf0e10cSrcweir 
operator ==(const SwTOXSortTabBase & rCmpBase)331cdf0e10cSrcweir sal_Bool SwTOXIndex::operator==( const SwTOXSortTabBase& rCmpBase )
332cdf0e10cSrcweir {
333cdf0e10cSrcweir 	SwTOXIndex& rCmp = (SwTOXIndex&)rCmpBase;
334cdf0e10cSrcweir 
335cdf0e10cSrcweir 	// In Abhaengigkeit von den Optionen Grosskleinschreibung beachten
336cdf0e10cSrcweir 	if(GetLevel() != rCmp.GetLevel() || nKeyLevel != rCmp.nKeyLevel)
337cdf0e10cSrcweir 		return sal_False;
338cdf0e10cSrcweir 
339cdf0e10cSrcweir 	ASSERT(pTxtMark, "pTxtMark == 0, Kein Stichwort");
340cdf0e10cSrcweir 
341cdf0e10cSrcweir     String sMyTxt;
342cdf0e10cSrcweir     String sMyTxtReading;
343cdf0e10cSrcweir     GetTxt( sMyTxt, sMyTxtReading );
344cdf0e10cSrcweir 
345cdf0e10cSrcweir     String sOtherTxt;
346cdf0e10cSrcweir     String sOtherTxtReading;
347cdf0e10cSrcweir     rCmp.GetTxt( sOtherTxt, sOtherTxtReading );
348cdf0e10cSrcweir 
349cdf0e10cSrcweir     sal_Bool bRet = pTOXIntl->IsEqual( sMyTxt, sMyTxtReading, GetLocale(),
350cdf0e10cSrcweir                                    sOtherTxt, sOtherTxtReading, rCmp.GetLocale() );
351cdf0e10cSrcweir 
352cdf0e10cSrcweir 	// Wenn nicht zusammengefasst wird muss die Pos aus gewertet werden
353cdf0e10cSrcweir     if(bRet && !(GetOptions() & nsSwTOIOptions::TOI_SAME_ENTRY))
354cdf0e10cSrcweir 		bRet = nPos == rCmp.nPos;
355cdf0e10cSrcweir 
356cdf0e10cSrcweir 	return bRet;
357cdf0e10cSrcweir }
358cdf0e10cSrcweir 
359cdf0e10cSrcweir //
360cdf0e10cSrcweir // kleiner haengt nur vom Text ab
361cdf0e10cSrcweir 
362cdf0e10cSrcweir 
363cdf0e10cSrcweir //
364cdf0e10cSrcweir 
operator <(const SwTOXSortTabBase & rCmpBase)365cdf0e10cSrcweir sal_Bool SwTOXIndex::operator<( const SwTOXSortTabBase& rCmpBase )
366cdf0e10cSrcweir {
367cdf0e10cSrcweir 	SwTOXIndex& rCmp = (SwTOXIndex&)rCmpBase;
368cdf0e10cSrcweir 
369cdf0e10cSrcweir 	ASSERT(pTxtMark, "pTxtMark == 0, Kein Stichwort");
370cdf0e10cSrcweir 
371cdf0e10cSrcweir     String sMyTxt;
372cdf0e10cSrcweir     String sMyTxtReading;
373cdf0e10cSrcweir     GetTxt( sMyTxt, sMyTxtReading );
374cdf0e10cSrcweir 
375cdf0e10cSrcweir     String sOtherTxt;
376cdf0e10cSrcweir     String sOtherTxtReading;
377cdf0e10cSrcweir     rCmp.GetTxt( sOtherTxt, sOtherTxtReading );
378cdf0e10cSrcweir 
379cdf0e10cSrcweir     sal_Bool bRet = GetLevel() == rCmp.GetLevel() &&
380cdf0e10cSrcweir                 pTOXIntl->IsLess( sMyTxt, sMyTxtReading, GetLocale(),
381cdf0e10cSrcweir                                   sOtherTxt, sOtherTxtReading, rCmp.GetLocale() );
382cdf0e10cSrcweir 
383cdf0e10cSrcweir 	// Wenn nicht zusammengefasst wird muss die Pos aus gewertet werden
384cdf0e10cSrcweir     if( !bRet && !(GetOptions() & nsSwTOIOptions::TOI_SAME_ENTRY) )
385cdf0e10cSrcweir     {
386cdf0e10cSrcweir         bRet = pTOXIntl->IsEqual( sMyTxt, sMyTxtReading, GetLocale(),
387cdf0e10cSrcweir                                    sOtherTxt, sOtherTxtReading, rCmp.GetLocale() ) &&
388cdf0e10cSrcweir                nPos < rCmp.nPos;
389cdf0e10cSrcweir     }
390cdf0e10cSrcweir 
391cdf0e10cSrcweir 	return bRet;
392cdf0e10cSrcweir }
393cdf0e10cSrcweir 
394cdf0e10cSrcweir //
395cdf0e10cSrcweir // Das Stichwort selbst
396cdf0e10cSrcweir 
397cdf0e10cSrcweir 
398cdf0e10cSrcweir //
399cdf0e10cSrcweir 
GetText_Impl(String & rTxt,String & rTxtReading) const400cdf0e10cSrcweir void SwTOXIndex::GetText_Impl( String& rTxt, String& rTxtReading ) const
401cdf0e10cSrcweir {
402cdf0e10cSrcweir 	ASSERT(pTxtMark, "pTxtMark == 0, Kein Stichwort");
403cdf0e10cSrcweir 	const SwTOXMark& rTOXMark = pTxtMark->GetTOXMark();
404cdf0e10cSrcweir 	switch(nKeyLevel)
405cdf0e10cSrcweir 	{
406cdf0e10cSrcweir 		case FORM_PRIMARY_KEY	 :
407cdf0e10cSrcweir         {
408cdf0e10cSrcweir 			rTxt = rTOXMark.GetPrimaryKey();
409cdf0e10cSrcweir             rTxtReading = rTOXMark.GetPrimaryKeyReading();
410cdf0e10cSrcweir         }
411cdf0e10cSrcweir 		break;
412cdf0e10cSrcweir 		case FORM_SECONDARY_KEY  :
413cdf0e10cSrcweir         {
414cdf0e10cSrcweir 			rTxt = rTOXMark.GetSecondaryKey();
415cdf0e10cSrcweir             rTxtReading = rTOXMark.GetSecondaryKeyReading();
416cdf0e10cSrcweir         }
417cdf0e10cSrcweir 		break;
418cdf0e10cSrcweir 		case FORM_ENTRY			 :
419cdf0e10cSrcweir         {
420cdf0e10cSrcweir 			rTxt = rTOXMark.GetText();
421cdf0e10cSrcweir             rTxtReading = rTOXMark.GetTextReading();
422cdf0e10cSrcweir         }
423cdf0e10cSrcweir 		break;
424cdf0e10cSrcweir 	}
425cdf0e10cSrcweir 	// if TOI_INITIAL_CAPS is set, first character is to be capitalized
426cdf0e10cSrcweir     if( nsSwTOIOptions::TOI_INITIAL_CAPS & nOpt && pTOXIntl )
427cdf0e10cSrcweir 	{
428cdf0e10cSrcweir 		String sUpper( pTOXIntl->ToUpper( rTxt, 0 ));
429cdf0e10cSrcweir 		rTxt.Erase( 0, 1 ).Insert( sUpper, 0 );
430cdf0e10cSrcweir 	}
431cdf0e10cSrcweir }
432cdf0e10cSrcweir 
FillText(SwTxtNode & rNd,const SwIndex & rInsPos,sal_uInt16) const433cdf0e10cSrcweir void SwTOXIndex::FillText( SwTxtNode& rNd, const SwIndex& rInsPos, sal_uInt16 ) const
434cdf0e10cSrcweir {
435*69a74367SOliver-Rainer Wittmann 	const xub_StrLen* pEnd = pTxtMark->End();
436cdf0e10cSrcweir 	String sTmp;
437cdf0e10cSrcweir     String sTmpReading;
438cdf0e10cSrcweir 	if( pEnd && !pTxtMark->GetTOXMark().IsAlternativeText() &&
439cdf0e10cSrcweir             0 == (GetOptions() & nsSwTOIOptions::TOI_KEY_AS_ENTRY))
440cdf0e10cSrcweir 	{
441cdf0e10cSrcweir 		sTmp = ((SwTxtNode*)aTOXSources[0].pNd)->GetExpandTxt(
442cdf0e10cSrcweir 							*pTxtMark->GetStart(),
443cdf0e10cSrcweir 							*pEnd - *pTxtMark->GetStart());
444cdf0e10cSrcweir         if(nsSwTOIOptions::TOI_INITIAL_CAPS&nOpt && pTOXIntl)
445cdf0e10cSrcweir 		{
446cdf0e10cSrcweir 			String sUpper( pTOXIntl->ToUpper( sTmp, 0 ));
447cdf0e10cSrcweir 			sTmp.Erase( 0, 1 ).Insert( sUpper, 0 );
448cdf0e10cSrcweir 		}
449cdf0e10cSrcweir 	}
450cdf0e10cSrcweir 	else
451cdf0e10cSrcweir         GetTxt( sTmp, sTmpReading );
452cdf0e10cSrcweir 
453cdf0e10cSrcweir     rNd.InsertText( sTmp, rInsPos );
454cdf0e10cSrcweir }
455cdf0e10cSrcweir 
456cdf0e10cSrcweir 
457cdf0e10cSrcweir 
GetLevel() const458cdf0e10cSrcweir sal_uInt16 SwTOXIndex::GetLevel() const
459cdf0e10cSrcweir {
460cdf0e10cSrcweir 	ASSERT(pTxtMark, "pTxtMark == 0, Kein Stichwort");
461cdf0e10cSrcweir 
462cdf0e10cSrcweir 	sal_uInt16 nForm = FORM_PRIMARY_KEY;
463cdf0e10cSrcweir 
464cdf0e10cSrcweir     if( 0 == (GetOptions() & nsSwTOIOptions::TOI_KEY_AS_ENTRY)&&
465cdf0e10cSrcweir 		pTxtMark->GetTOXMark().GetPrimaryKey().Len() )
466cdf0e10cSrcweir 	{
467cdf0e10cSrcweir 		nForm = FORM_SECONDARY_KEY;
468cdf0e10cSrcweir 		if( pTxtMark->GetTOXMark().GetSecondaryKey().Len() )
469cdf0e10cSrcweir 			nForm = FORM_ENTRY;
470cdf0e10cSrcweir 	}
471cdf0e10cSrcweir 	return nForm;
472cdf0e10cSrcweir }
473cdf0e10cSrcweir 
474cdf0e10cSrcweir /*--------------------------------------------------------------------
475cdf0e10cSrcweir 	 Beschreibung: Schluessel und Trennzeichen
476cdf0e10cSrcweir  --------------------------------------------------------------------*/
477cdf0e10cSrcweir 
478cdf0e10cSrcweir 
SwTOXCustom(const String & rStr,const String & rReading,sal_uInt16 nLevel,const SwTOXInternational & rIntl,const lang::Locale & rLocale)479cdf0e10cSrcweir SwTOXCustom::SwTOXCustom(const String& rStr, const String& rReading,
480cdf0e10cSrcweir                          sal_uInt16 nLevel,
481cdf0e10cSrcweir                          const SwTOXInternational& rIntl,
482cdf0e10cSrcweir                          const lang::Locale& rLocale )
483cdf0e10cSrcweir     : SwTOXSortTabBase( TOX_SORT_CUSTOM, 0, 0, &rIntl, &rLocale ),
484cdf0e10cSrcweir     aKey(rStr), sReading(rReading), nLev(nLevel)
485cdf0e10cSrcweir {
486cdf0e10cSrcweir }
487cdf0e10cSrcweir 
488cdf0e10cSrcweir 
operator ==(const SwTOXSortTabBase & rCmpBase)489cdf0e10cSrcweir sal_Bool SwTOXCustom::operator==(const SwTOXSortTabBase& rCmpBase)
490cdf0e10cSrcweir {
491cdf0e10cSrcweir     String sMyTxt;
492cdf0e10cSrcweir     String sMyTxtReading;
493cdf0e10cSrcweir     GetTxt( sMyTxt, sMyTxtReading );
494cdf0e10cSrcweir 
495cdf0e10cSrcweir     String sOtherTxt;
496cdf0e10cSrcweir     String sOtherTxtReading;
497cdf0e10cSrcweir     rCmpBase.GetTxt( sOtherTxt, sOtherTxtReading );
498cdf0e10cSrcweir 
499cdf0e10cSrcweir     return GetLevel() == rCmpBase.GetLevel() &&
500cdf0e10cSrcweir            pTOXIntl->IsEqual( sMyTxt, sMyTxtReading, GetLocale(),
501cdf0e10cSrcweir                               sOtherTxt, sOtherTxtReading, rCmpBase.GetLocale() );
502cdf0e10cSrcweir }
503cdf0e10cSrcweir 
504cdf0e10cSrcweir 
operator <(const SwTOXSortTabBase & rCmpBase)505cdf0e10cSrcweir sal_Bool SwTOXCustom::operator < (const SwTOXSortTabBase& rCmpBase)
506cdf0e10cSrcweir {
507cdf0e10cSrcweir     String sMyTxt;
508cdf0e10cSrcweir     String sMyTxtReading;
509cdf0e10cSrcweir     GetTxt( sMyTxt, sMyTxtReading );
510cdf0e10cSrcweir 
511cdf0e10cSrcweir     String sOtherTxt;
512cdf0e10cSrcweir     String sOtherTxtReading;
513cdf0e10cSrcweir     rCmpBase.GetTxt( sOtherTxt, sOtherTxtReading );
514cdf0e10cSrcweir 
515cdf0e10cSrcweir     return  GetLevel() <= rCmpBase.GetLevel() &&
516cdf0e10cSrcweir             pTOXIntl->IsLess( sMyTxt, sMyTxtReading, GetLocale(),
517cdf0e10cSrcweir                               sOtherTxt, sOtherTxtReading, rCmpBase.GetLocale() );
518cdf0e10cSrcweir }
519cdf0e10cSrcweir 
520cdf0e10cSrcweir 
GetLevel() const521cdf0e10cSrcweir sal_uInt16 SwTOXCustom::GetLevel() const
522cdf0e10cSrcweir {
523cdf0e10cSrcweir 	return nLev;
524cdf0e10cSrcweir }
525cdf0e10cSrcweir 
526cdf0e10cSrcweir 
GetText_Impl(String & rTxt,String & rTxtReading) const527cdf0e10cSrcweir void SwTOXCustom::GetText_Impl( String& rTxt, String &rTxtReading ) const
528cdf0e10cSrcweir {
529cdf0e10cSrcweir 	rTxt = aKey;
530cdf0e10cSrcweir     rTxtReading = sReading;
531cdf0e10cSrcweir     /// !!!!!!!!!!!!!!
532cdf0e10cSrcweir }
533cdf0e10cSrcweir 
534cdf0e10cSrcweir 
535cdf0e10cSrcweir /*--------------------------------------------------------------------
536cdf0e10cSrcweir 	 Beschreibung: sortierter Inhaltsverz. Eintrag
537cdf0e10cSrcweir  --------------------------------------------------------------------*/
538cdf0e10cSrcweir 
539cdf0e10cSrcweir 
SwTOXContent(const SwTxtNode & rNd,const SwTxtTOXMark * pMark,const SwTOXInternational & rIntl)540cdf0e10cSrcweir SwTOXContent::SwTOXContent( const SwTxtNode& rNd, const SwTxtTOXMark* pMark,
541cdf0e10cSrcweir 						const SwTOXInternational& rIntl)
542cdf0e10cSrcweir     : SwTOXSortTabBase( TOX_SORT_CONTENT, &rNd, pMark, &rIntl )
543cdf0e10cSrcweir {
544cdf0e10cSrcweir }
545cdf0e10cSrcweir 
546cdf0e10cSrcweir 
547cdf0e10cSrcweir //	Der Text des Inhalts
548cdf0e10cSrcweir //
549cdf0e10cSrcweir 
GetText_Impl(String & rTxt,String & rTxtReading) const550cdf0e10cSrcweir void SwTOXContent::GetText_Impl( String& rTxt, String& rTxtReading ) const
551cdf0e10cSrcweir {
552*69a74367SOliver-Rainer Wittmann 	const xub_StrLen* pEnd = pTxtMark->End();
553cdf0e10cSrcweir 	if( pEnd && !pTxtMark->GetTOXMark().IsAlternativeText() )
554cdf0e10cSrcweir     {
555cdf0e10cSrcweir 		rTxt = ((SwTxtNode*)aTOXSources[0].pNd)->GetExpandTxt(
556cdf0e10cSrcweir 									 *pTxtMark->GetStart(),
557cdf0e10cSrcweir 									 *pEnd - *pTxtMark->GetStart() );
558cdf0e10cSrcweir 
559cdf0e10cSrcweir         rTxtReading = pTxtMark->GetTOXMark().GetTextReading();
560cdf0e10cSrcweir     }
561cdf0e10cSrcweir 	else
562cdf0e10cSrcweir 		rTxt = pTxtMark->GetTOXMark().GetAlternativeText();
563cdf0e10cSrcweir }
564cdf0e10cSrcweir 
FillText(SwTxtNode & rNd,const SwIndex & rInsPos,sal_uInt16) const565cdf0e10cSrcweir void SwTOXContent::FillText( SwTxtNode& rNd, const SwIndex& rInsPos, sal_uInt16 ) const
566cdf0e10cSrcweir {
567*69a74367SOliver-Rainer Wittmann 	const xub_StrLen* pEnd = pTxtMark->End();
568cdf0e10cSrcweir 	if( pEnd && !pTxtMark->GetTOXMark().IsAlternativeText() )
569cdf0e10cSrcweir 		((SwTxtNode*)aTOXSources[0].pNd)->GetExpandTxt( rNd, &rInsPos,
570cdf0e10cSrcweir 									*pTxtMark->GetStart(),
571cdf0e10cSrcweir 									*pEnd - *pTxtMark->GetStart() );
572cdf0e10cSrcweir 	else
573cdf0e10cSrcweir     {
574cdf0e10cSrcweir         String sTmp, sTmpReading;
575cdf0e10cSrcweir         GetTxt( sTmp, sTmpReading );
576cdf0e10cSrcweir         rNd.InsertText( sTmp, rInsPos );
577cdf0e10cSrcweir     }
578cdf0e10cSrcweir }
579cdf0e10cSrcweir 
580cdf0e10cSrcweir //
581cdf0e10cSrcweir // Die Ebene fuer Anzeige
582cdf0e10cSrcweir //
583cdf0e10cSrcweir 
584cdf0e10cSrcweir 
GetLevel() const585cdf0e10cSrcweir sal_uInt16 SwTOXContent::GetLevel() const
586cdf0e10cSrcweir {
587cdf0e10cSrcweir 	return pTxtMark->GetTOXMark().GetLevel();
588cdf0e10cSrcweir }
589cdf0e10cSrcweir 
590cdf0e10cSrcweir /*--------------------------------------------------------------------
591cdf0e10cSrcweir 	 Beschreibung: Verzeichnis aus Absaetzen zusammengesammelt
592cdf0e10cSrcweir  --------------------------------------------------------------------*/
593cdf0e10cSrcweir 
594cdf0e10cSrcweir // bei Sortierung von OLE/Grafiken aufpassen !!!
595cdf0e10cSrcweir // Die Position darf nicht die im Dokument,
596cdf0e10cSrcweir // sondern muss die vom "Henkel" sein  !!
597cdf0e10cSrcweir 
598cdf0e10cSrcweir 
SwTOXPara(const SwCntntNode & rNd,SwTOXElement eT,sal_uInt16 nLevel)599cdf0e10cSrcweir SwTOXPara::SwTOXPara( const SwCntntNode& rNd, SwTOXElement eT, sal_uInt16 nLevel )
600cdf0e10cSrcweir 	: SwTOXSortTabBase( TOX_SORT_PARA, &rNd, 0, 0 ),
601cdf0e10cSrcweir 	eType( eT ),
602cdf0e10cSrcweir 	m_nLevel(nLevel),
603cdf0e10cSrcweir 	nStartIndex(0),
604cdf0e10cSrcweir 	nEndIndex(STRING_LEN)
605cdf0e10cSrcweir {
606cdf0e10cSrcweir }
607cdf0e10cSrcweir 
608cdf0e10cSrcweir 
GetText_Impl(String & rTxt,String &) const609cdf0e10cSrcweir void SwTOXPara::GetText_Impl( String& rTxt, String& ) const
610cdf0e10cSrcweir {
611cdf0e10cSrcweir 	const SwCntntNode* pNd = aTOXSources[0].pNd;
612cdf0e10cSrcweir 	switch( eType )
613cdf0e10cSrcweir 	{
614cdf0e10cSrcweir     case nsSwTOXElement::TOX_SEQUENCE:
615cdf0e10cSrcweir     case nsSwTOXElement::TOX_TEMPLATE:
616cdf0e10cSrcweir     case nsSwTOXElement::TOX_OUTLINELEVEL:
617cdf0e10cSrcweir 		{
618cdf0e10cSrcweir 			xub_StrLen nStt = nStartIndex;
619cdf0e10cSrcweir /* JP 22.01.98:
620cdf0e10cSrcweir 	Tabs ueberspringen - macht aber keinen Sinn, solange in der TOX-Form
621cdf0e10cSrcweir 	nicht die KapitelNummer eingestellt werden kann
622cdf0e10cSrcweir 			const String& rTmp = ((SwTxtNode*)pNd)->GetTxt();
623cdf0e10cSrcweir 			while( '\t' == rTmp.GetChar( nStt ) && nStt < rTmp.Len() )
624cdf0e10cSrcweir 				++nStt;
625cdf0e10cSrcweir */
626cdf0e10cSrcweir 			rTxt = ((SwTxtNode*)pNd)->GetExpandTxt(
627cdf0e10cSrcweir 					nStt,
628cdf0e10cSrcweir 					STRING_NOTFOUND == nEndIndex ? STRING_LEN : nEndIndex - nStt);
629cdf0e10cSrcweir 		}
630cdf0e10cSrcweir 		break;
631cdf0e10cSrcweir 
632cdf0e10cSrcweir     case nsSwTOXElement::TOX_OLE:
633cdf0e10cSrcweir     case nsSwTOXElement::TOX_GRAPHIC:
634cdf0e10cSrcweir     case nsSwTOXElement::TOX_FRAME:
635cdf0e10cSrcweir 		{
636cdf0e10cSrcweir 			// suche das FlyFormat, dort steht der Object/Grafik-Name
637cdf0e10cSrcweir 			SwFrmFmt* pFly = pNd->GetFlyFmt();
638cdf0e10cSrcweir 			if( pFly )
639cdf0e10cSrcweir 				rTxt = pFly->GetName();
640cdf0e10cSrcweir 			else
641cdf0e10cSrcweir 			{
642cdf0e10cSrcweir 				ASSERT( !this, "Grafik/Object ohne Namen" )
643cdf0e10cSrcweir                 sal_uInt16 nId = nsSwTOXElement::TOX_OLE == eType
644cdf0e10cSrcweir 								? STR_OBJECT_DEFNAME
645cdf0e10cSrcweir                                 : nsSwTOXElement::TOX_GRAPHIC == eType
646cdf0e10cSrcweir 									? STR_GRAPHIC_DEFNAME
647cdf0e10cSrcweir 									: STR_FRAME_DEFNAME;
648cdf0e10cSrcweir 				rTxt = SW_RESSTR( nId );
649cdf0e10cSrcweir 			}
650cdf0e10cSrcweir 		}
651cdf0e10cSrcweir 		break;
652cdf0e10cSrcweir     default: break;
653cdf0e10cSrcweir 	}
654cdf0e10cSrcweir }
655cdf0e10cSrcweir 
FillText(SwTxtNode & rNd,const SwIndex & rInsPos,sal_uInt16) const656cdf0e10cSrcweir void SwTOXPara::FillText( SwTxtNode& rNd, const SwIndex& rInsPos, sal_uInt16 ) const
657cdf0e10cSrcweir {
658cdf0e10cSrcweir     if( nsSwTOXElement::TOX_TEMPLATE == eType || nsSwTOXElement::TOX_SEQUENCE == eType  || nsSwTOXElement::TOX_OUTLINELEVEL == eType)
659cdf0e10cSrcweir 	{
660cdf0e10cSrcweir 		SwTxtNode* pSrc = (SwTxtNode*)aTOXSources[0].pNd;
661cdf0e10cSrcweir 		xub_StrLen nStt = nStartIndex;
662cdf0e10cSrcweir /* JP 22.01.98:
663cdf0e10cSrcweir 	Tabs ueberspringen - macht aber keinen Sinn, solange in der TOX-Form
664cdf0e10cSrcweir 	nicht die KapitelNummer eingestellt werden kann
665cdf0e10cSrcweir 		const String& rTxt = pSrc->GetTxt();
666cdf0e10cSrcweir 		while( '\t' == rTxt.GetChar( nStt ) && nStt < rTxt.Len() )
667cdf0e10cSrcweir 			++nStt;
668cdf0e10cSrcweir */
669cdf0e10cSrcweir 		pSrc->GetExpandTxt( rNd, &rInsPos, nStt,
670cdf0e10cSrcweir 				nEndIndex == STRING_LEN ? STRING_LEN : nEndIndex - nStt,
671cdf0e10cSrcweir                 sal_False, sal_False, sal_True );
672cdf0e10cSrcweir 	}
673cdf0e10cSrcweir 	else
674cdf0e10cSrcweir     {
675cdf0e10cSrcweir         String sTmp, sTmpReading;
676cdf0e10cSrcweir         GetTxt( sTmp, sTmpReading );
677cdf0e10cSrcweir 		sTmp.SearchAndReplaceAll('\t', ' ');
678cdf0e10cSrcweir         rNd.InsertText( sTmp, rInsPos );
679cdf0e10cSrcweir     }
680cdf0e10cSrcweir }
681cdf0e10cSrcweir 
682cdf0e10cSrcweir 
GetLevel() const683cdf0e10cSrcweir sal_uInt16 SwTOXPara::GetLevel() const
684cdf0e10cSrcweir {
685cdf0e10cSrcweir 	sal_uInt16 nRet = m_nLevel;
686cdf0e10cSrcweir 	const SwCntntNode*	pNd = aTOXSources[0].pNd;
687cdf0e10cSrcweir 
688cdf0e10cSrcweir     if( nsSwTOXElement::TOX_OUTLINELEVEL == eType && pNd->GetTxtNode() )
689cdf0e10cSrcweir 	{
690cdf0e10cSrcweir 		//sal_uInt16 nTmp = ((SwTxtNode*)pNd)->GetTxtColl()->GetOutlineLevel();//#outline level,zhaojianwei
691cdf0e10cSrcweir 		//if(nTmp < NO_NUMBERING)
692cdf0e10cSrcweir 		//	nRet = nTmp + 1;
693cdf0e10cSrcweir         const int nTmp = ((SwTxtNode*)pNd)->GetAttrOutlineLevel();//#outline level,zhaojianwei????
694cdf0e10cSrcweir 		if(nTmp != 0 )
695cdf0e10cSrcweir             nRet = static_cast<sal_uInt16>(nTmp);
696cdf0e10cSrcweir 	}
697cdf0e10cSrcweir 	return nRet;
698cdf0e10cSrcweir }
699cdf0e10cSrcweir 
700cdf0e10cSrcweir 
GetURL() const701cdf0e10cSrcweir String SwTOXPara::GetURL() const
702cdf0e10cSrcweir {
703cdf0e10cSrcweir 	String aTxt;
704cdf0e10cSrcweir 	const SwCntntNode* pNd = aTOXSources[0].pNd;
705cdf0e10cSrcweir 	switch( eType )
706cdf0e10cSrcweir 	{
707cdf0e10cSrcweir     case nsSwTOXElement::TOX_TEMPLATE:
708cdf0e10cSrcweir     case nsSwTOXElement::TOX_OUTLINELEVEL:
709cdf0e10cSrcweir 		{
710cdf0e10cSrcweir             const SwTxtNode * pTxtNd = static_cast<const SwTxtNode *>(pNd);
711cdf0e10cSrcweir 
712cdf0e10cSrcweir             // --> OD 2009-08-05 #i103265#
713cdf0e10cSrcweir //            //if( MAXLEVEL >= pTxtNd->GetTxtColl()->GetOutlineLevel())  //#outline level,zhaojianwei
714cdf0e10cSrcweir //            if ( pTxtNd->GetAttrOutlineLevel() > 0)  //<-end,zhaojianwei
715cdf0e10cSrcweir //            {
716cdf0e10cSrcweir //                aTxt = '#';
717cdf0e10cSrcweir //                const SwNumRule * pRule = pTxtNd->GetNumRule();
718cdf0e10cSrcweir //                if( pRule )
719cdf0e10cSrcweir //                {
720cdf0e10cSrcweir //                    // dann noch die rel. Nummer davor setzen
721cdf0e10cSrcweir //                    const sal_uInt16 nCurrLevel = static_cast<sal_uInt16>(pTxtNd->GetActualListLevel());
722cdf0e10cSrcweir //                    if(nCurrLevel <= MAXLEVEL)
723cdf0e10cSrcweir //                    {
724cdf0e10cSrcweir //                        // --> OD 2005-11-02 #i51089 - TUNING#
725cdf0e10cSrcweir //                        if ( pTxtNd->GetNum() )
726cdf0e10cSrcweir //                        {
727cdf0e10cSrcweir //                            SwNumberTree::tNumberVector aNumVector =
728cdf0e10cSrcweir //                                pTxtNd->GetNumberVector();
729cdf0e10cSrcweir 
730cdf0e10cSrcweir //                            for( sal_uInt16 n = 0; n <= nCurrLevel; ++n )
731cdf0e10cSrcweir //                            {
732cdf0e10cSrcweir //                                int nNum = aNumVector[ n ];
733cdf0e10cSrcweir //                                nNum -= ( pRule->Get( n ).GetStart() - 1 );
734cdf0e10cSrcweir //                                ( aTxt += String::CreateFromInt32( nNum )) += '.';
735cdf0e10cSrcweir //                            }
736cdf0e10cSrcweir //                        }
737cdf0e10cSrcweir //                        else
738cdf0e10cSrcweir //                        {
739cdf0e10cSrcweir //                            ASSERT( false,
740cdf0e10cSrcweir //                                    "<SwTOXPara::GetURL()> - text node with numbering rule, but without number. This is a serious defect -> inform OD" );
741cdf0e10cSrcweir //                        }
742cdf0e10cSrcweir //                    }
743cdf0e10cSrcweir //                }
744cdf0e10cSrcweir //                aTxt += pTxtNd->GetExpandTxt();
745cdf0e10cSrcweir //                ( aTxt += cMarkSeperator ).AppendAscii( pMarkToOutline );
746cdf0e10cSrcweir //            }
747cdf0e10cSrcweir             SwDoc* pDoc = const_cast<SwDoc*>( pTxtNd->GetDoc() );
748cdf0e10cSrcweir             ::sw::mark::IMark const * const pMark = pDoc->getIDocumentMarkAccess()->getMarkForTxtNode(
749cdf0e10cSrcweir                                 *(pTxtNd),
750cdf0e10cSrcweir                                 IDocumentMarkAccess::CROSSREF_HEADING_BOOKMARK);
751cdf0e10cSrcweir             aTxt = '#';
752cdf0e10cSrcweir             const String aMarkName( pMark->GetName() );
753cdf0e10cSrcweir             aTxt += aMarkName;
754cdf0e10cSrcweir             // <--
755cdf0e10cSrcweir 		}
756cdf0e10cSrcweir 		break;
757cdf0e10cSrcweir 
758cdf0e10cSrcweir     case nsSwTOXElement::TOX_OLE:
759cdf0e10cSrcweir     case nsSwTOXElement::TOX_GRAPHIC:
760cdf0e10cSrcweir     case nsSwTOXElement::TOX_FRAME:
761cdf0e10cSrcweir 		{
762cdf0e10cSrcweir 			// suche das FlyFormat, dort steht der Object/Grafik-Name
763cdf0e10cSrcweir 			SwFrmFmt* pFly = pNd->GetFlyFmt();
764cdf0e10cSrcweir 			if( pFly )
765cdf0e10cSrcweir 			{
766cdf0e10cSrcweir 				(( aTxt = '#' ) += pFly->GetName() ) += cMarkSeperator;
767cdf0e10cSrcweir 				const sal_Char* pStr;
768cdf0e10cSrcweir 				switch( eType )
769cdf0e10cSrcweir 				{
770cdf0e10cSrcweir                 case nsSwTOXElement::TOX_OLE:       pStr = pMarkToOLE; break;
771cdf0e10cSrcweir                 case nsSwTOXElement::TOX_GRAPHIC:   pStr = pMarkToGraphic; break;
772cdf0e10cSrcweir                 case nsSwTOXElement::TOX_FRAME:     pStr = pMarkToFrame; break;
773cdf0e10cSrcweir 				default:			pStr = 0;
774cdf0e10cSrcweir 				}
775cdf0e10cSrcweir 				if( pStr )
776cdf0e10cSrcweir 					aTxt.AppendAscii( pStr );
777cdf0e10cSrcweir 			}
778cdf0e10cSrcweir 		}
779cdf0e10cSrcweir 		break;
780cdf0e10cSrcweir     default: break;
781cdf0e10cSrcweir 	}
782cdf0e10cSrcweir 	return aTxt;
783cdf0e10cSrcweir }
784cdf0e10cSrcweir 
785cdf0e10cSrcweir 
786cdf0e10cSrcweir /*--------------------------------------------------------------------
787cdf0e10cSrcweir 	Beschreibung: Tabelle
788cdf0e10cSrcweir  --------------------------------------------------------------------*/
789cdf0e10cSrcweir 
790cdf0e10cSrcweir 
SwTOXTable(const SwCntntNode & rNd)791cdf0e10cSrcweir SwTOXTable::SwTOXTable( const SwCntntNode& rNd )
792cdf0e10cSrcweir 	: SwTOXSortTabBase( TOX_SORT_TABLE, &rNd, 0, 0 ),
793cdf0e10cSrcweir 	nLevel(FORM_ALPHA_DELIMITTER)
794cdf0e10cSrcweir {
795cdf0e10cSrcweir }
796cdf0e10cSrcweir 
797cdf0e10cSrcweir 
GetText_Impl(String & rTxt,String &) const798cdf0e10cSrcweir void SwTOXTable::GetText_Impl( String& rTxt, String& ) const
799cdf0e10cSrcweir {
800cdf0e10cSrcweir 	const SwNode* pNd = aTOXSources[0].pNd;
801cdf0e10cSrcweir 	if( pNd && 0 != ( pNd = pNd->FindTableNode() ) )
802cdf0e10cSrcweir 	{
803cdf0e10cSrcweir 		rTxt = ((SwTableNode*)pNd)->GetTable().GetFrmFmt()->GetName();
804cdf0e10cSrcweir 	}
805cdf0e10cSrcweir 	else
806cdf0e10cSrcweir 	{
807cdf0e10cSrcweir 		ASSERT( !this, "Wo ist meine Tabelle geblieben?" )
808cdf0e10cSrcweir 		rTxt = SW_RESSTR( STR_TABLE_DEFNAME );
809cdf0e10cSrcweir 	}
810cdf0e10cSrcweir }
811cdf0e10cSrcweir 
GetLevel() const812cdf0e10cSrcweir sal_uInt16 SwTOXTable::GetLevel() const
813cdf0e10cSrcweir {
814cdf0e10cSrcweir 	return nLevel;
815cdf0e10cSrcweir }
816cdf0e10cSrcweir 
817cdf0e10cSrcweir 
GetURL() const818cdf0e10cSrcweir String SwTOXTable::GetURL() const
819cdf0e10cSrcweir {
820cdf0e10cSrcweir 	String aTxt;
821cdf0e10cSrcweir 	const SwNode* pNd = aTOXSources[0].pNd;
822cdf0e10cSrcweir 	if( pNd && 0 != ( pNd = pNd->FindTableNode() ) )
823cdf0e10cSrcweir 	{
824cdf0e10cSrcweir 		aTxt = ((SwTableNode*)pNd)->GetTable().GetFrmFmt()->GetName();
825cdf0e10cSrcweir 		if( aTxt.Len() )
826cdf0e10cSrcweir 		{
827cdf0e10cSrcweir 			( aTxt.Insert( '#', 0 ) += cMarkSeperator ).
828cdf0e10cSrcweir 											AppendAscii( pMarkToTable );
829cdf0e10cSrcweir 		}
830cdf0e10cSrcweir 	}
831cdf0e10cSrcweir 	return aTxt;
832cdf0e10cSrcweir }
833cdf0e10cSrcweir /*-- 15.09.99 14:28:08---------------------------------------------------
834cdf0e10cSrcweir 
835cdf0e10cSrcweir   -----------------------------------------------------------------------*/
836cdf0e10cSrcweir 
SwTOXAuthority(const SwCntntNode & rNd,SwFmtFld & rField,const SwTOXInternational & rIntl)837cdf0e10cSrcweir SwTOXAuthority::SwTOXAuthority( const SwCntntNode& rNd,
838cdf0e10cSrcweir 				SwFmtFld& rField, const SwTOXInternational& rIntl ) :
839cdf0e10cSrcweir 	SwTOXSortTabBase( TOX_SORT_AUTHORITY, &rNd, 0, &rIntl ),
840cdf0e10cSrcweir 	m_rField(rField)
841cdf0e10cSrcweir {
842cdf0e10cSrcweir 	if(rField.GetTxtFld())
843cdf0e10cSrcweir 		nCntPos = *rField.GetTxtFld()->GetStart();
844cdf0e10cSrcweir }
845cdf0e10cSrcweir 
GetLevel() const846cdf0e10cSrcweir sal_uInt16 SwTOXAuthority::GetLevel() const
847cdf0e10cSrcweir {
848c0286415SOliver-Rainer Wittmann     String sText(((SwAuthorityField*)m_rField.GetField())->GetFieldText(AUTH_FIELD_AUTHORITY_TYPE));
849cdf0e10cSrcweir     //#i18655# the level '0' is the heading level therefor the values are incremented here
850cdf0e10cSrcweir     sal_uInt16 nRet = 1;
851c0286415SOliver-Rainer Wittmann     if( pTOXIntl->IsNumeric( sText ) )
852c0286415SOliver-Rainer Wittmann     {
853c0286415SOliver-Rainer Wittmann         nRet = (sal_uInt16)sText.ToInt32();
854c0286415SOliver-Rainer Wittmann         nRet++;
855c0286415SOliver-Rainer Wittmann     }
856cdf0e10cSrcweir     //illegal values are also set to 'ARTICLE' as non-numeric values are
857cdf0e10cSrcweir     if(nRet > AUTH_TYPE_END)
858cdf0e10cSrcweir         nRet = 1;
859c0286415SOliver-Rainer Wittmann     return nRet;
860cdf0e10cSrcweir }
861cdf0e10cSrcweir /*-- 15.09.99 14:28:08---------------------------------------------------
862cdf0e10cSrcweir 
863cdf0e10cSrcweir   -----------------------------------------------------------------------*/
lcl_GetText(SwFmtFld const & rField)864cdf0e10cSrcweir static String lcl_GetText(SwFmtFld const& rField)
865cdf0e10cSrcweir {
866c0286415SOliver-Rainer Wittmann     return rField.GetField()->ExpandField(true);
867cdf0e10cSrcweir }
868cdf0e10cSrcweir 
GetText_Impl(String & rTxt,String &) const869cdf0e10cSrcweir void SwTOXAuthority::GetText_Impl( String& rTxt, String& ) const
870cdf0e10cSrcweir {
871cdf0e10cSrcweir     rTxt = lcl_GetText(m_rField);
872cdf0e10cSrcweir }
873cdf0e10cSrcweir 
874cdf0e10cSrcweir /* -----------------21.09.99 12:50-------------------
875cdf0e10cSrcweir 
876cdf0e10cSrcweir  --------------------------------------------------*/
FillText(SwTxtNode & rNd,const SwIndex & rInsPos,sal_uInt16 nAuthField) const877cdf0e10cSrcweir void 	SwTOXAuthority::FillText( SwTxtNode& rNd,
878cdf0e10cSrcweir 						const SwIndex& rInsPos, sal_uInt16 nAuthField ) const
879cdf0e10cSrcweir {
880c0286415SOliver-Rainer Wittmann 	SwAuthorityField* pField = (SwAuthorityField*)m_rField.GetField();
881cdf0e10cSrcweir 	String sText;
882cdf0e10cSrcweir 	if(AUTH_FIELD_IDENTIFIER == nAuthField)
883cdf0e10cSrcweir 	{
884cdf0e10cSrcweir         sText = lcl_GetText(m_rField);
885cdf0e10cSrcweir         const SwAuthorityFieldType* pType = (const SwAuthorityFieldType*)pField->GetTyp();
886cdf0e10cSrcweir         sal_Unicode cChar = pType->GetPrefix();
887cdf0e10cSrcweir         if(cChar && cChar != ' ')
888cdf0e10cSrcweir             sText.Erase(0, 1);
889cdf0e10cSrcweir         cChar = pType->GetSuffix();
890cdf0e10cSrcweir         if(cChar && cChar != ' ')
891cdf0e10cSrcweir             sText.Erase(sText.Len() - 1, 1);
892cdf0e10cSrcweir 	}
893cdf0e10cSrcweir 	else if(AUTH_FIELD_AUTHORITY_TYPE == nAuthField)
894cdf0e10cSrcweir 	{
895cdf0e10cSrcweir 		sal_uInt16 nLevel = GetLevel();
896cdf0e10cSrcweir 		if(nLevel)
897cdf0e10cSrcweir 			sText = SwAuthorityFieldType::GetAuthTypeName((ToxAuthorityType) --nLevel);
898cdf0e10cSrcweir 	}
899cdf0e10cSrcweir 	else
900cdf0e10cSrcweir 		sText = (pField->GetFieldText((ToxAuthorityField) nAuthField));
901cdf0e10cSrcweir     rNd.InsertText( sText, rInsPos );
902cdf0e10cSrcweir }
903cdf0e10cSrcweir /* -----------------14.10.99 09:35-------------------
904cdf0e10cSrcweir 
905cdf0e10cSrcweir  --------------------------------------------------*/
operator ==(const SwTOXSortTabBase & rCmp)906cdf0e10cSrcweir sal_Bool 	SwTOXAuthority::operator==( const SwTOXSortTabBase& rCmp)
907cdf0e10cSrcweir {
908cdf0e10cSrcweir 	return nType == rCmp.nType &&
909c0286415SOliver-Rainer Wittmann 			((SwAuthorityField*)m_rField.GetField())->GetHandle() ==
910c0286415SOliver-Rainer Wittmann 				((SwAuthorityField*)((SwTOXAuthority&)rCmp).m_rField.GetField())->GetHandle();
911cdf0e10cSrcweir }
912cdf0e10cSrcweir /* -----------------21.10.99 09:52-------------------
913cdf0e10cSrcweir 
914cdf0e10cSrcweir  --------------------------------------------------*/
operator <(const SwTOXSortTabBase & rBase)915cdf0e10cSrcweir sal_Bool 	SwTOXAuthority::operator<( const SwTOXSortTabBase& rBase)
916cdf0e10cSrcweir {
917c0286415SOliver-Rainer Wittmann     sal_Bool bRet = sal_False;
918c0286415SOliver-Rainer Wittmann     SwAuthorityField* pField = (SwAuthorityField*)m_rField.GetField();
919c0286415SOliver-Rainer Wittmann     SwAuthorityFieldType* pType = (SwAuthorityFieldType*)
920c0286415SOliver-Rainer Wittmann                                                 pField->GetTyp();
921c0286415SOliver-Rainer Wittmann     if(pType->IsSortByDocument())
922c0286415SOliver-Rainer Wittmann         bRet = SwTOXSortTabBase::operator<(rBase);
923c0286415SOliver-Rainer Wittmann     else
924c0286415SOliver-Rainer Wittmann     {
925c0286415SOliver-Rainer Wittmann         SwAuthorityField* pCmpField =
926c0286415SOliver-Rainer Wittmann             (SwAuthorityField*)((SwTOXAuthority&)rBase).m_rField.GetField();
927cdf0e10cSrcweir 
928cdf0e10cSrcweir 
929c0286415SOliver-Rainer Wittmann         for(sal_uInt16 i = 0; i < pType->GetSortKeyCount(); i++)
930c0286415SOliver-Rainer Wittmann         {
931c0286415SOliver-Rainer Wittmann             const SwTOXSortKey*	pKey = pType->GetSortKey(i);
932cdf0e10cSrcweir             String sMyTxt = pField->GetFieldText(pKey->eField);
933cdf0e10cSrcweir             String sMyTxtReading;
934cdf0e10cSrcweir             String sOtherTxt = pCmpField->GetFieldText(pKey->eField);
935cdf0e10cSrcweir             String sOtherTxtReading;
936cdf0e10cSrcweir 
937cdf0e10cSrcweir             sal_Int32 nComp = pTOXIntl->Compare( sMyTxt, sMyTxtReading, GetLocale(),
938cdf0e10cSrcweir                                                  sOtherTxt, sOtherTxtReading, rBase.GetLocale() );
939cdf0e10cSrcweir 
940cdf0e10cSrcweir             if( nComp )
941c0286415SOliver-Rainer Wittmann             {
942c0286415SOliver-Rainer Wittmann                 bRet = (-1 == nComp) == pKey->bSortAscending;
943c0286415SOliver-Rainer Wittmann                 break;
944c0286415SOliver-Rainer Wittmann             }
945c0286415SOliver-Rainer Wittmann         }
946c0286415SOliver-Rainer Wittmann     }
947c0286415SOliver-Rainer Wittmann     return bRet;
948cdf0e10cSrcweir }
949