merge the formfield patch from ooo-build
[ooovba.git] / sw / source / core / tox / txmsrt.cxx
blob5a128fbf8a5782f934e418dd4bad214321870d4e
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: txmsrt.cxx,v $
10 * $Revision: 1.31 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_sw.hxx"
35 #include <tools/resid.hxx>
36 #include <unotools/charclass.hxx>
37 #include <com/sun/star/i18n/CollatorOptions.hpp>
38 #include <svx/unolingu.hxx>
39 #include <txtfld.hxx>
40 #include <doc.hxx>
41 #include <docary.hxx>
42 #include <cntfrm.hxx>
43 #include <node.hxx>
44 #include <frmatr.hxx>
45 #include <pam.hxx>
46 #include <txttxmrk.hxx>
47 #include <frmfmt.hxx>
48 #include <fmtfld.hxx>
49 #include <txmsrt.hxx>
50 #include <ndtxt.hxx>
51 #include <txtatr.hxx>
52 #include <swtable.hxx>
53 #include <expfld.hxx>
54 #include <authfld.hxx>
55 #include <toxwrap.hxx>
57 #ifndef _COMCORE_HRC
58 #include <comcore.hrc>
59 #endif
60 #include <numrule.hxx>
62 extern BOOL IsFrameBehind( const SwTxtNode& rMyNd, xub_StrLen nMySttPos,
63 const SwTxtNode& rBehindNd, xub_StrLen nSttPos );
65 using namespace ::com::sun::star;
66 using namespace ::com::sun::star::uno;
67 using ::rtl::OUString;
68 /*--------------------------------------------------------------------
69 Beschreibung: Strings initialisieren
70 --------------------------------------------------------------------*/
72 USHORT SwTOXSortTabBase::nOpt = 0;
74 SV_IMPL_VARARR( SwTOXSources, SwTOXSource )
77 SwTOXInternational::SwTOXInternational( LanguageType nLang, USHORT nOpt,
78 const String& rSortAlgorithm ) :
79 eLang( nLang ),
80 sSortAlgorithm(rSortAlgorithm),
81 nOptions( nOpt )
83 Init();
86 SwTOXInternational::SwTOXInternational( const SwTOXInternational& rIntl ) :
87 eLang( rIntl.eLang ),
88 sSortAlgorithm(rIntl.sSortAlgorithm),
89 nOptions( rIntl.nOptions )
91 Init();
94 void SwTOXInternational::Init()
96 pIndexWrapper = new IndexEntrySupplierWrapper();
98 const lang::Locale aLcl( SvxCreateLocale( eLang ) );
99 pIndexWrapper->SetLocale( aLcl );
101 if(!sSortAlgorithm.Len())
103 Sequence < OUString > aSeq( pIndexWrapper->GetAlgorithmList( aLcl ));
104 if(aSeq.getLength())
105 sSortAlgorithm = aSeq.getConstArray()[0];
108 if ( nOptions & nsSwTOIOptions::TOI_CASE_SENSITIVE )
109 pIndexWrapper->LoadAlgorithm( aLcl, sSortAlgorithm, 0 );
110 else
111 pIndexWrapper->LoadAlgorithm( aLcl, sSortAlgorithm, SW_COLLATOR_IGNORES );
113 pCharClass = new CharClass( aLcl );
117 SwTOXInternational::~SwTOXInternational()
119 delete pCharClass;
120 delete pIndexWrapper;
123 String SwTOXInternational::ToUpper( const String& rStr, xub_StrLen nPos ) const
125 return pCharClass->toUpper( rStr, nPos, 1 );
127 inline BOOL SwTOXInternational::IsNumeric( const String& rStr ) const
129 return pCharClass->isNumeric( rStr );
132 sal_Int32 SwTOXInternational::Compare( const String& rTxt1, const String& rTxtReading1,
133 const lang::Locale& rLocale1,
134 const String& rTxt2, const String& rTxtReading2,
135 const lang::Locale& rLocale2 ) const
137 return pIndexWrapper->CompareIndexEntry( rTxt1, rTxtReading1, rLocale1,
138 rTxt2, rTxtReading2, rLocale2 );
141 String SwTOXInternational::GetIndexKey( const String& rTxt, const String& rTxtReading,
142 const lang::Locale& rLocale ) const
144 return pIndexWrapper->GetIndexKey( rTxt, rTxtReading, rLocale );
147 String SwTOXInternational::GetFollowingText( BOOL bMorePages ) const
149 return pIndexWrapper->GetFollowingText( bMorePages );
152 /*--------------------------------------------------------------------
153 Beschreibung: SortierElement fuer Verzeichniseintraege
154 --------------------------------------------------------------------*/
157 SwTOXSortTabBase::SwTOXSortTabBase( TOXSortType nTyp, const SwCntntNode* pNd,
158 const SwTxtTOXMark* pMark,
159 const SwTOXInternational* pInter,
160 const lang::Locale* pLocale )
161 : pTOXNd( 0 ), pTxtMark( pMark ), pTOXIntl( pInter ),
162 nPos( 0 ), nCntPos( 0 ), nType( static_cast<USHORT>(nTyp) ), bValidTxt( FALSE )
164 if ( pLocale )
165 aLocale = *pLocale;
167 if( pNd )
169 xub_StrLen n = 0;
170 if( pTxtMark )
171 n = *pTxtMark->GetStart();
172 SwTOXSource aTmp( pNd, n,
173 pTxtMark ? pTxtMark->GetTOXMark().IsMainEntry() : FALSE );
174 aTOXSources.Insert( aTmp, aTOXSources.Count() );
176 nPos = pNd->GetIndex();
178 switch( nTyp )
180 case TOX_SORT_CONTENT:
181 case TOX_SORT_PARA:
182 case TOX_SORT_TABLE:
183 // falls sie in Sonderbereichen stehen, sollte man die
184 // Position im Body besorgen
185 if( nPos < pNd->GetNodes().GetEndOfExtras().GetIndex() )
187 // dann die "Anker" (Body) Position holen.
188 Point aPt;
189 const SwCntntFrm* pFrm = pNd->GetFrm( &aPt, 0, FALSE );
190 if( pFrm )
192 SwPosition aPos( *pNd );
193 const SwDoc& rDoc = *pNd->GetDoc();
194 #ifndef PRODUCT
195 ASSERT( GetBodyTxtNode( rDoc, aPos, *pFrm ),
196 "wo steht der Absatz" );
197 #else
198 GetBodyTxtNode( rDoc, aPos, *pFrm );
199 #endif
200 nPos = aPos.nNode.GetIndex();
201 nCntPos = aPos.nContent.GetIndex();
204 else
205 nCntPos = n;
206 break;
207 default: break;
213 String SwTOXSortTabBase::GetURL() const
215 return aEmptyStr;
218 void SwTOXSortTabBase::FillText( SwTxtNode& rNd, const SwIndex& rInsPos,
219 USHORT ) const
221 String sMyTxt;
222 String sMyTxtReading;
224 GetTxt( sMyTxt, sMyTxtReading );
226 rNd.InsertText( sMyTxt, rInsPos );
229 BOOL SwTOXSortTabBase::operator==( const SwTOXSortTabBase& rCmp )
231 BOOL bRet = nPos == rCmp.nPos && nCntPos == rCmp.nCntPos &&
232 (!aTOXSources[0].pNd || !rCmp.aTOXSources[0].pNd ||
233 aTOXSources[0].pNd == rCmp.aTOXSources[0].pNd );
235 if( TOX_SORT_CONTENT == nType )
237 bRet = bRet && pTxtMark && rCmp.pTxtMark &&
238 *pTxtMark->GetStart() == *rCmp.pTxtMark->GetStart();
240 if( bRet )
242 // beide Pointer vorhanden -> vergleiche Text
243 // beide Pointer nicht vorhanden -> vergleiche AlternativText
244 const xub_StrLen *pEnd = pTxtMark->GetEnd(),
245 *pEndCmp = rCmp.pTxtMark->GetEnd();
247 String sMyTxt;
248 String sMyTxtReading;
249 GetTxt( sMyTxt, sMyTxtReading );
251 String sOtherTxt;
252 String sOtherTxtReading;
253 rCmp.GetTxt( sOtherTxt, sOtherTxtReading );
255 bRet = ( ( pEnd && pEndCmp ) || ( !pEnd && !pEndCmp ) ) &&
256 pTOXIntl->IsEqual( sMyTxt, sMyTxtReading, GetLocale(),
257 sOtherTxt, sOtherTxtReading, rCmp.GetLocale() );
260 return bRet;
263 BOOL SwTOXSortTabBase::operator<( const SwTOXSortTabBase& rCmp )
265 if( nPos < rCmp.nPos )
266 return TRUE;
268 if( nPos == rCmp.nPos )
270 if( nCntPos < rCmp.nCntPos )
271 return TRUE;
273 if( nCntPos == rCmp.nCntPos )
275 const SwNode* pFirst = aTOXSources[0].pNd;
276 const SwNode* pNext = rCmp.aTOXSources[0].pNd;
278 if( pFirst && pFirst == pNext )
280 if( TOX_SORT_CONTENT == nType && pTxtMark && rCmp.pTxtMark )
282 if( *pTxtMark->GetStart() < *rCmp.pTxtMark->GetStart() )
283 return TRUE;
285 if( *pTxtMark->GetStart() == *rCmp.pTxtMark->GetStart() )
287 const xub_StrLen *pEnd = pTxtMark->GetEnd(),
288 *pEndCmp = rCmp.pTxtMark->GetEnd();
290 String sMyTxt;
291 String sMyTxtReading;
292 GetTxt( sMyTxt, sMyTxtReading );
294 String sOtherTxt;
295 String sOtherTxtReading;
296 rCmp.GetTxt( sOtherTxt, sOtherTxtReading );
298 // beide Pointer vorhanden -> vergleiche Text
299 // beide Pointer nicht vorhanden -> vergleiche AlternativText
300 if( ( pEnd && pEndCmp ) || ( !pEnd && !pEndCmp ) )
301 pTOXIntl->IsEqual( sMyTxt, sMyTxtReading, GetLocale(),
302 sOtherTxt, sOtherTxtReading, rCmp.GetLocale() );
304 if( pEnd && !pEndCmp )
305 return TRUE;
309 else if( pFirst && pFirst->IsTxtNode() &&
310 pNext && pNext->IsTxtNode() )
311 return ::IsFrameBehind( *(SwTxtNode*)pNext, nCntPos,
312 *(SwTxtNode*)pFirst, nCntPos );
315 return FALSE;
318 /*--------------------------------------------------------------------
319 Beschreibung: sortierter Stichworteintrag
320 --------------------------------------------------------------------*/
323 SwTOXIndex::SwTOXIndex( const SwTxtNode& rNd,
324 const SwTxtTOXMark* pMark, USHORT nOptions,
325 BYTE nKyLevel,
326 const SwTOXInternational& rIntl,
327 const lang::Locale& rLocale )
328 : SwTOXSortTabBase( TOX_SORT_INDEX, &rNd, pMark, &rIntl, &rLocale ),
329 nKeyLevel(nKyLevel)
331 nPos = rNd.GetIndex();
332 nOpt = nOptions;
336 // Stichworte vergleichen. Bezieht sich nur auf den Text
340 BOOL SwTOXIndex::operator==( const SwTOXSortTabBase& rCmpBase )
342 SwTOXIndex& rCmp = (SwTOXIndex&)rCmpBase;
344 // In Abhaengigkeit von den Optionen Grosskleinschreibung beachten
345 if(GetLevel() != rCmp.GetLevel() || nKeyLevel != rCmp.nKeyLevel)
346 return FALSE;
348 ASSERT(pTxtMark, "pTxtMark == 0, Kein Stichwort");
350 String sMyTxt;
351 String sMyTxtReading;
352 GetTxt( sMyTxt, sMyTxtReading );
354 String sOtherTxt;
355 String sOtherTxtReading;
356 rCmp.GetTxt( sOtherTxt, sOtherTxtReading );
358 BOOL bRet = pTOXIntl->IsEqual( sMyTxt, sMyTxtReading, GetLocale(),
359 sOtherTxt, sOtherTxtReading, rCmp.GetLocale() );
361 // Wenn nicht zusammengefasst wird muss die Pos aus gewertet werden
362 if(bRet && !(GetOptions() & nsSwTOIOptions::TOI_SAME_ENTRY))
363 bRet = nPos == rCmp.nPos;
365 return bRet;
369 // kleiner haengt nur vom Text ab
374 BOOL SwTOXIndex::operator<( const SwTOXSortTabBase& rCmpBase )
376 SwTOXIndex& rCmp = (SwTOXIndex&)rCmpBase;
378 ASSERT(pTxtMark, "pTxtMark == 0, Kein Stichwort");
380 String sMyTxt;
381 String sMyTxtReading;
382 GetTxt( sMyTxt, sMyTxtReading );
384 String sOtherTxt;
385 String sOtherTxtReading;
386 rCmp.GetTxt( sOtherTxt, sOtherTxtReading );
388 BOOL bRet = GetLevel() == rCmp.GetLevel() &&
389 pTOXIntl->IsLess( sMyTxt, sMyTxtReading, GetLocale(),
390 sOtherTxt, sOtherTxtReading, rCmp.GetLocale() );
392 // Wenn nicht zusammengefasst wird muss die Pos aus gewertet werden
393 if( !bRet && !(GetOptions() & nsSwTOIOptions::TOI_SAME_ENTRY) )
395 bRet = pTOXIntl->IsEqual( sMyTxt, sMyTxtReading, GetLocale(),
396 sOtherTxt, sOtherTxtReading, rCmp.GetLocale() ) &&
397 nPos < rCmp.nPos;
400 return bRet;
404 // Das Stichwort selbst
409 void SwTOXIndex::_GetText( String& rTxt, String& rTxtReading )
411 ASSERT(pTxtMark, "pTxtMark == 0, Kein Stichwort");
412 const SwTOXMark& rTOXMark = pTxtMark->GetTOXMark();
413 switch(nKeyLevel)
415 case FORM_PRIMARY_KEY :
417 rTxt = rTOXMark.GetPrimaryKey();
418 rTxtReading = rTOXMark.GetPrimaryKeyReading();
420 break;
421 case FORM_SECONDARY_KEY :
423 rTxt = rTOXMark.GetSecondaryKey();
424 rTxtReading = rTOXMark.GetSecondaryKeyReading();
426 break;
427 case FORM_ENTRY :
429 rTxt = rTOXMark.GetText();
430 rTxtReading = rTOXMark.GetTextReading();
432 break;
434 // if TOI_INITIAL_CAPS is set, first character is to be capitalized
435 if( nsSwTOIOptions::TOI_INITIAL_CAPS & nOpt && pTOXIntl )
437 String sUpper( pTOXIntl->ToUpper( rTxt, 0 ));
438 rTxt.Erase( 0, 1 ).Insert( sUpper, 0 );
442 void SwTOXIndex::FillText( SwTxtNode& rNd, const SwIndex& rInsPos, USHORT ) const
444 const xub_StrLen* pEnd = pTxtMark->GetEnd();
445 String sTmp;
446 String sTmpReading;
447 if( pEnd && !pTxtMark->GetTOXMark().IsAlternativeText() &&
448 0 == (GetOptions() & nsSwTOIOptions::TOI_KEY_AS_ENTRY))
450 sTmp = ((SwTxtNode*)aTOXSources[0].pNd)->GetExpandTxt(
451 *pTxtMark->GetStart(),
452 *pEnd - *pTxtMark->GetStart());
453 if(nsSwTOIOptions::TOI_INITIAL_CAPS&nOpt && pTOXIntl)
455 String sUpper( pTOXIntl->ToUpper( sTmp, 0 ));
456 sTmp.Erase( 0, 1 ).Insert( sUpper, 0 );
459 else
460 GetTxt( sTmp, sTmpReading );
462 rNd.InsertText( sTmp, rInsPos );
467 USHORT SwTOXIndex::GetLevel() const
469 ASSERT(pTxtMark, "pTxtMark == 0, Kein Stichwort");
471 USHORT nForm = FORM_PRIMARY_KEY;
473 if( 0 == (GetOptions() & nsSwTOIOptions::TOI_KEY_AS_ENTRY)&&
474 pTxtMark->GetTOXMark().GetPrimaryKey().Len() )
476 nForm = FORM_SECONDARY_KEY;
477 if( pTxtMark->GetTOXMark().GetSecondaryKey().Len() )
478 nForm = FORM_ENTRY;
480 return nForm;
483 /*--------------------------------------------------------------------
484 Beschreibung: Schluessel und Trennzeichen
485 --------------------------------------------------------------------*/
488 SwTOXCustom::SwTOXCustom(const String& rStr, const String& rReading,
489 USHORT nLevel,
490 const SwTOXInternational& rIntl,
491 const lang::Locale& rLocale )
492 : SwTOXSortTabBase( TOX_SORT_CUSTOM, 0, 0, &rIntl, &rLocale ),
493 aKey(rStr), sReading(rReading), nLev(nLevel)
498 BOOL SwTOXCustom::operator==(const SwTOXSortTabBase& rCmpBase)
500 String sMyTxt;
501 String sMyTxtReading;
502 GetTxt( sMyTxt, sMyTxtReading );
504 String sOtherTxt;
505 String sOtherTxtReading;
506 rCmpBase.GetTxt( sOtherTxt, sOtherTxtReading );
508 return GetLevel() == rCmpBase.GetLevel() &&
509 pTOXIntl->IsEqual( sMyTxt, sMyTxtReading, GetLocale(),
510 sOtherTxt, sOtherTxtReading, rCmpBase.GetLocale() );
514 BOOL SwTOXCustom::operator < (const SwTOXSortTabBase& rCmpBase)
516 String sMyTxt;
517 String sMyTxtReading;
518 GetTxt( sMyTxt, sMyTxtReading );
520 String sOtherTxt;
521 String sOtherTxtReading;
522 rCmpBase.GetTxt( sOtherTxt, sOtherTxtReading );
524 return GetLevel() <= rCmpBase.GetLevel() &&
525 pTOXIntl->IsLess( sMyTxt, sMyTxtReading, GetLocale(),
526 sOtherTxt, sOtherTxtReading, rCmpBase.GetLocale() );
530 USHORT SwTOXCustom::GetLevel() const
532 return nLev;
536 void SwTOXCustom::_GetText( String& rTxt, String &rTxtReading )
538 rTxt = aKey;
539 rTxtReading = sReading;
540 /// !!!!!!!!!!!!!!
544 /*--------------------------------------------------------------------
545 Beschreibung: sortierter Inhaltsverz. Eintrag
546 --------------------------------------------------------------------*/
549 SwTOXContent::SwTOXContent( const SwTxtNode& rNd, const SwTxtTOXMark* pMark,
550 const SwTOXInternational& rIntl)
551 : SwTOXSortTabBase( TOX_SORT_CONTENT, &rNd, pMark, &rIntl )
556 // Der Text des Inhalts
559 void SwTOXContent::_GetText( String& rTxt, String& rTxtReading )
561 const xub_StrLen* pEnd = pTxtMark->GetEnd();
562 if( pEnd && !pTxtMark->GetTOXMark().IsAlternativeText() )
564 rTxt = ((SwTxtNode*)aTOXSources[0].pNd)->GetExpandTxt(
565 *pTxtMark->GetStart(),
566 *pEnd - *pTxtMark->GetStart() );
568 rTxtReading = pTxtMark->GetTOXMark().GetTextReading();
570 else
571 rTxt = pTxtMark->GetTOXMark().GetAlternativeText();
574 void SwTOXContent::FillText( SwTxtNode& rNd, const SwIndex& rInsPos, USHORT ) const
576 const xub_StrLen* pEnd = pTxtMark->GetEnd();
577 if( pEnd && !pTxtMark->GetTOXMark().IsAlternativeText() )
578 ((SwTxtNode*)aTOXSources[0].pNd)->GetExpandTxt( rNd, &rInsPos,
579 *pTxtMark->GetStart(),
580 *pEnd - *pTxtMark->GetStart() );
581 else
583 String sTmp, sTmpReading;
584 GetTxt( sTmp, sTmpReading );
585 rNd.InsertText( sTmp, rInsPos );
590 // Die Ebene fuer Anzeige
594 USHORT SwTOXContent::GetLevel() const
596 return pTxtMark->GetTOXMark().GetLevel();
599 /*--------------------------------------------------------------------
600 Beschreibung: Verzeichnis aus Absaetzen zusammengesammelt
601 --------------------------------------------------------------------*/
603 // bei Sortierung von OLE/Grafiken aufpassen !!!
604 // Die Position darf nicht die im Dokument,
605 // sondern muss die vom "Henkel" sein !!
608 SwTOXPara::SwTOXPara( const SwCntntNode& rNd, SwTOXElement eT, USHORT nLevel )
609 : SwTOXSortTabBase( TOX_SORT_PARA, &rNd, 0, 0 ),
610 eType( eT ),
611 m_nLevel(nLevel),
612 nStartIndex(0),
613 nEndIndex(STRING_LEN)
618 void SwTOXPara::_GetText( String& rTxt, String& )
620 const SwCntntNode* pNd = aTOXSources[0].pNd;
621 switch( eType )
623 case nsSwTOXElement::TOX_SEQUENCE:
624 case nsSwTOXElement::TOX_TEMPLATE:
625 case nsSwTOXElement::TOX_OUTLINELEVEL:
627 xub_StrLen nStt = nStartIndex;
628 /* JP 22.01.98:
629 Tabs ueberspringen - macht aber keinen Sinn, solange in der TOX-Form
630 nicht die KapitelNummer eingestellt werden kann
631 const String& rTmp = ((SwTxtNode*)pNd)->GetTxt();
632 while( '\t' == rTmp.GetChar( nStt ) && nStt < rTmp.Len() )
633 ++nStt;
635 rTxt = ((SwTxtNode*)pNd)->GetExpandTxt(
636 nStt,
637 STRING_NOTFOUND == nEndIndex ? STRING_LEN : nEndIndex - nStt);
639 break;
641 case nsSwTOXElement::TOX_OLE:
642 case nsSwTOXElement::TOX_GRAPHIC:
643 case nsSwTOXElement::TOX_FRAME:
645 // suche das FlyFormat, dort steht der Object/Grafik-Name
646 SwFrmFmt* pFly = pNd->GetFlyFmt();
647 if( pFly )
648 rTxt = pFly->GetName();
649 else
651 ASSERT( !this, "Grafik/Object ohne Namen" )
652 USHORT nId = nsSwTOXElement::TOX_OLE == eType
653 ? STR_OBJECT_DEFNAME
654 : nsSwTOXElement::TOX_GRAPHIC == eType
655 ? STR_GRAPHIC_DEFNAME
656 : STR_FRAME_DEFNAME;
657 rTxt = SW_RESSTR( nId );
660 break;
661 default: break;
665 void SwTOXPara::FillText( SwTxtNode& rNd, const SwIndex& rInsPos, USHORT ) const
667 if( nsSwTOXElement::TOX_TEMPLATE == eType || nsSwTOXElement::TOX_SEQUENCE == eType || nsSwTOXElement::TOX_OUTLINELEVEL == eType)
669 SwTxtNode* pSrc = (SwTxtNode*)aTOXSources[0].pNd;
670 xub_StrLen nStt = nStartIndex;
671 /* JP 22.01.98:
672 Tabs ueberspringen - macht aber keinen Sinn, solange in der TOX-Form
673 nicht die KapitelNummer eingestellt werden kann
674 const String& rTxt = pSrc->GetTxt();
675 while( '\t' == rTxt.GetChar( nStt ) && nStt < rTxt.Len() )
676 ++nStt;
678 pSrc->GetExpandTxt( rNd, &rInsPos, nStt,
679 nEndIndex == STRING_LEN ? STRING_LEN : nEndIndex - nStt,
680 FALSE, FALSE, TRUE );
682 else
684 String sTmp, sTmpReading;
685 GetTxt( sTmp, sTmpReading );
686 sTmp.SearchAndReplaceAll('\t', ' ');
687 rNd.InsertText( sTmp, rInsPos );
692 USHORT SwTOXPara::GetLevel() const
694 USHORT nRet = m_nLevel;
695 const SwCntntNode* pNd = aTOXSources[0].pNd;
697 if( nsSwTOXElement::TOX_OUTLINELEVEL == eType && pNd->GetTxtNode() )
699 //USHORT nTmp = ((SwTxtNode*)pNd)->GetTxtColl()->GetOutlineLevel();//#outline level,zhaojianwei
700 //if(nTmp < NO_NUMBERING)
701 // nRet = nTmp + 1;
702 const int nTmp = ((SwTxtNode*)pNd)->GetAttrOutlineLevel();//#outline level,zhaojianwei????
703 if(nTmp != 0 )
704 nRet = static_cast<USHORT>(nTmp);
706 return nRet;
710 String SwTOXPara::GetURL() const
712 String aTxt;
713 const SwCntntNode* pNd = aTOXSources[0].pNd;
714 switch( eType )
716 case nsSwTOXElement::TOX_TEMPLATE:
717 case nsSwTOXElement::TOX_OUTLINELEVEL:
719 const SwTxtNode * pTxtNd = static_cast<const SwTxtNode *>(pNd);
721 // --> OD 2009-08-05 #i103265#
722 // //if( MAXLEVEL >= pTxtNd->GetTxtColl()->GetOutlineLevel()) //#outline level,zhaojianwei
723 // if ( pTxtNd->GetAttrOutlineLevel() > 0) //<-end,zhaojianwei
724 // {
725 // aTxt = '#';
726 // const SwNumRule * pRule = pTxtNd->GetNumRule();
727 // if( pRule )
728 // {
729 // // dann noch die rel. Nummer davor setzen
730 // const USHORT nCurrLevel = static_cast<USHORT>(pTxtNd->GetActualListLevel());
731 // if(nCurrLevel <= MAXLEVEL)
732 // {
733 // // --> OD 2005-11-02 #i51089 - TUNING#
734 // if ( pTxtNd->GetNum() )
735 // {
736 // SwNumberTree::tNumberVector aNumVector =
737 // pTxtNd->GetNumberVector();
739 // for( USHORT n = 0; n <= nCurrLevel; ++n )
740 // {
741 // int nNum = aNumVector[ n ];
742 // nNum -= ( pRule->Get( n ).GetStart() - 1 );
743 // ( aTxt += String::CreateFromInt32( nNum )) += '.';
744 // }
745 // }
746 // else
747 // {
748 // ASSERT( false,
749 // "<SwTOXPara::GetURL()> - text node with numbering rule, but without number. This is a serious defect -> inform OD" );
750 // }
751 // }
752 // }
753 // aTxt += pTxtNd->GetExpandTxt();
754 // ( aTxt += cMarkSeperator ).AppendAscii( pMarkToOutline );
755 // }
756 SwDoc* pDoc = const_cast<SwDoc*>( pTxtNd->GetDoc() );
757 ::sw::mark::IMark const * const pMark = pDoc->getIDocumentMarkAccess()->getMarkForTxtNode(
758 *(pTxtNd),
759 IDocumentMarkAccess::CROSSREF_HEADING_BOOKMARK);
760 aTxt = '#';
761 const String aMarkName( pMark->GetName() );
762 aTxt += aMarkName;
763 // <--
765 break;
767 case nsSwTOXElement::TOX_OLE:
768 case nsSwTOXElement::TOX_GRAPHIC:
769 case nsSwTOXElement::TOX_FRAME:
771 // suche das FlyFormat, dort steht der Object/Grafik-Name
772 SwFrmFmt* pFly = pNd->GetFlyFmt();
773 if( pFly )
775 (( aTxt = '#' ) += pFly->GetName() ) += cMarkSeperator;
776 const sal_Char* pStr;
777 switch( eType )
779 case nsSwTOXElement::TOX_OLE: pStr = pMarkToOLE; break;
780 case nsSwTOXElement::TOX_GRAPHIC: pStr = pMarkToGraphic; break;
781 case nsSwTOXElement::TOX_FRAME: pStr = pMarkToFrame; break;
782 default: pStr = 0;
784 if( pStr )
785 aTxt.AppendAscii( pStr );
788 break;
789 default: break;
791 return aTxt;
795 /*--------------------------------------------------------------------
796 Beschreibung: Tabelle
797 --------------------------------------------------------------------*/
800 SwTOXTable::SwTOXTable( const SwCntntNode& rNd )
801 : SwTOXSortTabBase( TOX_SORT_TABLE, &rNd, 0, 0 ),
802 nLevel(FORM_ALPHA_DELIMITTER)
807 void SwTOXTable::_GetText( String& rTxt, String& )
809 const SwNode* pNd = aTOXSources[0].pNd;
810 if( pNd && 0 != ( pNd = pNd->FindTableNode() ) )
812 rTxt = ((SwTableNode*)pNd)->GetTable().GetFrmFmt()->GetName();
814 else
816 ASSERT( !this, "Wo ist meine Tabelle geblieben?" )
817 rTxt = SW_RESSTR( STR_TABLE_DEFNAME );
821 USHORT SwTOXTable::GetLevel() const
823 return nLevel;
827 String SwTOXTable::GetURL() const
829 String aTxt;
830 const SwNode* pNd = aTOXSources[0].pNd;
831 if( pNd && 0 != ( pNd = pNd->FindTableNode() ) )
833 aTxt = ((SwTableNode*)pNd)->GetTable().GetFrmFmt()->GetName();
834 if( aTxt.Len() )
836 ( aTxt.Insert( '#', 0 ) += cMarkSeperator ).
837 AppendAscii( pMarkToTable );
840 return aTxt;
842 /*-- 15.09.99 14:28:08---------------------------------------------------
844 -----------------------------------------------------------------------*/
846 SwTOXAuthority::SwTOXAuthority( const SwCntntNode& rNd,
847 SwFmtFld& rField, const SwTOXInternational& rIntl ) :
848 SwTOXSortTabBase( TOX_SORT_AUTHORITY, &rNd, 0, &rIntl ),
849 m_rField(rField)
851 if(rField.GetTxtFld())
852 nCntPos = *rField.GetTxtFld()->GetStart();
855 USHORT SwTOXAuthority::GetLevel() const
857 String sText(((SwAuthorityField*)m_rField.GetFld())->
858 GetFieldText(AUTH_FIELD_AUTHORITY_TYPE));
859 //#i18655# the level '0' is the heading level therefor the values are incremented here
860 USHORT nRet = 1;
861 if( pTOXIntl->IsNumeric( sText ) )
863 nRet = (USHORT)sText.ToInt32();
864 nRet++;
866 //illegal values are also set to 'ARTICLE' as non-numeric values are
867 if(nRet > AUTH_TYPE_END)
868 nRet = 1;
869 return nRet;
871 /*-- 15.09.99 14:28:08---------------------------------------------------
873 -----------------------------------------------------------------------*/
874 void SwTOXAuthority::_GetText( String& rTxt, String& )
877 rTxt = m_rField.GetFld()->Expand();
880 /* -----------------21.09.99 12:50-------------------
882 --------------------------------------------------*/
883 void SwTOXAuthority::FillText( SwTxtNode& rNd,
884 const SwIndex& rInsPos, USHORT nAuthField ) const
886 SwAuthorityField* pField = (SwAuthorityField*)m_rField.GetFld();
887 String sText;
888 if(AUTH_FIELD_IDENTIFIER == nAuthField)
890 sText = pField->Expand();
891 const SwAuthorityFieldType* pType = (const SwAuthorityFieldType*)pField->GetTyp();
892 sal_Unicode cChar = pType->GetPrefix();
893 if(cChar && cChar != ' ')
894 sText.Erase(0, 1);
895 cChar = pType->GetSuffix();
896 if(cChar && cChar != ' ')
897 sText.Erase(sText.Len() - 1, 1);
899 else if(AUTH_FIELD_AUTHORITY_TYPE == nAuthField)
901 USHORT nLevel = GetLevel();
902 if(nLevel)
903 sText = SwAuthorityFieldType::GetAuthTypeName((ToxAuthorityType) --nLevel);
905 else
906 sText = (pField->GetFieldText((ToxAuthorityField) nAuthField));
907 rNd.InsertText( sText, rInsPos );
909 /* -----------------14.10.99 09:35-------------------
911 --------------------------------------------------*/
912 BOOL SwTOXAuthority::operator==( const SwTOXSortTabBase& rCmp)
914 return nType == rCmp.nType &&
915 ((SwAuthorityField*)m_rField.GetFld())->GetHandle() ==
916 ((SwAuthorityField*)((SwTOXAuthority&)rCmp).m_rField.GetFld())->GetHandle();
918 /* -----------------21.10.99 09:52-------------------
920 --------------------------------------------------*/
921 BOOL SwTOXAuthority::operator<( const SwTOXSortTabBase& rBase)
923 BOOL bRet = FALSE;
924 SwAuthorityField* pField = (SwAuthorityField*)m_rField.GetFld();
925 SwAuthorityFieldType* pType = (SwAuthorityFieldType*)
926 pField->GetTyp();
927 if(pType->IsSortByDocument())
928 bRet = SwTOXSortTabBase::operator<(rBase);
929 else
931 SwAuthorityField* pCmpField = (SwAuthorityField*)
932 ((SwTOXAuthority&)rBase).m_rField.GetFld();
935 for(USHORT i = 0; i < pType->GetSortKeyCount(); i++)
937 const SwTOXSortKey* pKey = pType->GetSortKey(i);
938 String sMyTxt = pField->GetFieldText(pKey->eField);
939 String sMyTxtReading;
940 String sOtherTxt = pCmpField->GetFieldText(pKey->eField);
941 String sOtherTxtReading;
943 sal_Int32 nComp = pTOXIntl->Compare( sMyTxt, sMyTxtReading, GetLocale(),
944 sOtherTxt, sOtherTxtReading, rBase.GetLocale() );
946 if( nComp )
948 bRet = (-1 == nComp) == pKey->bSortAscending;
949 break;
953 return bRet;