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 $
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>
46 #include <txttxmrk.hxx>
52 #include <swtable.hxx>
54 #include <authfld.hxx>
55 #include <toxwrap.hxx>
58 #include <comcore.hrc>
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
) :
80 sSortAlgorithm(rSortAlgorithm
),
86 SwTOXInternational::SwTOXInternational( const SwTOXInternational
& rIntl
) :
88 sSortAlgorithm(rIntl
.sSortAlgorithm
),
89 nOptions( rIntl
.nOptions
)
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
));
105 sSortAlgorithm
= aSeq
.getConstArray()[0];
108 if ( nOptions
& nsSwTOIOptions::TOI_CASE_SENSITIVE
)
109 pIndexWrapper
->LoadAlgorithm( aLcl
, sSortAlgorithm
, 0 );
111 pIndexWrapper
->LoadAlgorithm( aLcl
, sSortAlgorithm
, SW_COLLATOR_IGNORES
);
113 pCharClass
= new CharClass( aLcl
);
117 SwTOXInternational::~SwTOXInternational()
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
)
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();
180 case TOX_SORT_CONTENT
:
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.
189 const SwCntntFrm
* pFrm
= pNd
->GetFrm( &aPt
, 0, FALSE
);
192 SwPosition
aPos( *pNd
);
193 const SwDoc
& rDoc
= *pNd
->GetDoc();
195 ASSERT( GetBodyTxtNode( rDoc
, aPos
, *pFrm
),
196 "wo steht der Absatz" );
198 GetBodyTxtNode( rDoc
, aPos
, *pFrm
);
200 nPos
= aPos
.nNode
.GetIndex();
201 nCntPos
= aPos
.nContent
.GetIndex();
213 String
SwTOXSortTabBase::GetURL() const
218 void SwTOXSortTabBase::FillText( SwTxtNode
& rNd
, const SwIndex
& rInsPos
,
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();
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();
248 String sMyTxtReading
;
249 GetTxt( sMyTxt
, sMyTxtReading
);
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() );
263 BOOL
SwTOXSortTabBase::operator<( const SwTOXSortTabBase
& rCmp
)
265 if( nPos
< rCmp
.nPos
)
268 if( nPos
== rCmp
.nPos
)
270 if( nCntPos
< rCmp
.nCntPos
)
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() )
285 if( *pTxtMark
->GetStart() == *rCmp
.pTxtMark
->GetStart() )
287 const xub_StrLen
*pEnd
= pTxtMark
->GetEnd(),
288 *pEndCmp
= rCmp
.pTxtMark
->GetEnd();
291 String sMyTxtReading
;
292 GetTxt( sMyTxt
, sMyTxtReading
);
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
)
309 else if( pFirst
&& pFirst
->IsTxtNode() &&
310 pNext
&& pNext
->IsTxtNode() )
311 return ::IsFrameBehind( *(SwTxtNode
*)pNext
, nCntPos
,
312 *(SwTxtNode
*)pFirst
, nCntPos
);
318 /*--------------------------------------------------------------------
319 Beschreibung: sortierter Stichworteintrag
320 --------------------------------------------------------------------*/
323 SwTOXIndex::SwTOXIndex( const SwTxtNode
& rNd
,
324 const SwTxtTOXMark
* pMark
, USHORT nOptions
,
326 const SwTOXInternational
& rIntl
,
327 const lang::Locale
& rLocale
)
328 : SwTOXSortTabBase( TOX_SORT_INDEX
, &rNd
, pMark
, &rIntl
, &rLocale
),
331 nPos
= rNd
.GetIndex();
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
)
348 ASSERT(pTxtMark
, "pTxtMark == 0, Kein Stichwort");
351 String sMyTxtReading
;
352 GetTxt( sMyTxt
, sMyTxtReading
);
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
;
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");
381 String sMyTxtReading
;
382 GetTxt( sMyTxt
, sMyTxtReading
);
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() ) &&
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();
415 case FORM_PRIMARY_KEY
:
417 rTxt
= rTOXMark
.GetPrimaryKey();
418 rTxtReading
= rTOXMark
.GetPrimaryKeyReading();
421 case FORM_SECONDARY_KEY
:
423 rTxt
= rTOXMark
.GetSecondaryKey();
424 rTxtReading
= rTOXMark
.GetSecondaryKeyReading();
429 rTxt
= rTOXMark
.GetText();
430 rTxtReading
= rTOXMark
.GetTextReading();
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();
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 );
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() )
483 /*--------------------------------------------------------------------
484 Beschreibung: Schluessel und Trennzeichen
485 --------------------------------------------------------------------*/
488 SwTOXCustom::SwTOXCustom(const String
& rStr
, const String
& rReading
,
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
)
501 String sMyTxtReading
;
502 GetTxt( sMyTxt
, sMyTxtReading
);
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
)
517 String sMyTxtReading
;
518 GetTxt( sMyTxt
, sMyTxtReading
);
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
536 void SwTOXCustom::_GetText( String
& rTxt
, String
&rTxtReading
)
539 rTxtReading
= sReading
;
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();
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() );
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 ),
613 nEndIndex(STRING_LEN
)
618 void SwTOXPara::_GetText( String
& rTxt
, String
& )
620 const SwCntntNode
* pNd
= aTOXSources
[0].pNd
;
623 case nsSwTOXElement::TOX_SEQUENCE
:
624 case nsSwTOXElement::TOX_TEMPLATE
:
625 case nsSwTOXElement::TOX_OUTLINELEVEL
:
627 xub_StrLen nStt
= nStartIndex
;
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() )
635 rTxt
= ((SwTxtNode
*)pNd
)->GetExpandTxt(
637 STRING_NOTFOUND
== nEndIndex
? STRING_LEN
: nEndIndex
- nStt
);
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();
648 rTxt
= pFly
->GetName();
651 ASSERT( !this, "Grafik/Object ohne Namen" )
652 USHORT nId
= nsSwTOXElement::TOX_OLE
== eType
654 : nsSwTOXElement::TOX_GRAPHIC
== eType
655 ? STR_GRAPHIC_DEFNAME
657 rTxt
= SW_RESSTR( nId
);
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
;
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() )
678 pSrc
->GetExpandTxt( rNd
, &rInsPos
, nStt
,
679 nEndIndex
== STRING_LEN
? STRING_LEN
: nEndIndex
- nStt
,
680 FALSE
, FALSE
, TRUE
);
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)
702 const int nTmp
= ((SwTxtNode
*)pNd
)->GetAttrOutlineLevel();//#outline level,zhaojianwei????
704 nRet
= static_cast<USHORT
>(nTmp
);
710 String
SwTOXPara::GetURL() const
713 const SwCntntNode
* pNd
= aTOXSources
[0].pNd
;
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
726 // const SwNumRule * pRule = pTxtNd->GetNumRule();
729 // // dann noch die rel. Nummer davor setzen
730 // const USHORT nCurrLevel = static_cast<USHORT>(pTxtNd->GetActualListLevel());
731 // if(nCurrLevel <= MAXLEVEL)
733 // // --> OD 2005-11-02 #i51089 - TUNING#
734 // if ( pTxtNd->GetNum() )
736 // SwNumberTree::tNumberVector aNumVector =
737 // pTxtNd->GetNumberVector();
739 // for( USHORT n = 0; n <= nCurrLevel; ++n )
741 // int nNum = aNumVector[ n ];
742 // nNum -= ( pRule->Get( n ).GetStart() - 1 );
743 // ( aTxt += String::CreateFromInt32( nNum )) += '.';
749 // "<SwTOXPara::GetURL()> - text node with numbering rule, but without number. This is a serious defect -> inform OD" );
753 // aTxt += pTxtNd->GetExpandTxt();
754 // ( aTxt += cMarkSeperator ).AppendAscii( pMarkToOutline );
756 SwDoc
* pDoc
= const_cast<SwDoc
*>( pTxtNd
->GetDoc() );
757 ::sw::mark::IMark
const * const pMark
= pDoc
->getIDocumentMarkAccess()->getMarkForTxtNode(
759 IDocumentMarkAccess::CROSSREF_HEADING_BOOKMARK
);
761 const String
aMarkName( pMark
->GetName() );
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();
775 (( aTxt
= '#' ) += pFly
->GetName() ) += cMarkSeperator
;
776 const sal_Char
* pStr
;
779 case nsSwTOXElement::TOX_OLE
: pStr
= pMarkToOLE
; break;
780 case nsSwTOXElement::TOX_GRAPHIC
: pStr
= pMarkToGraphic
; break;
781 case nsSwTOXElement::TOX_FRAME
: pStr
= pMarkToFrame
; break;
785 aTxt
.AppendAscii( pStr
);
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();
816 ASSERT( !this, "Wo ist meine Tabelle geblieben?" )
817 rTxt
= SW_RESSTR( STR_TABLE_DEFNAME
);
821 USHORT
SwTOXTable::GetLevel() const
827 String
SwTOXTable::GetURL() const
830 const SwNode
* pNd
= aTOXSources
[0].pNd
;
831 if( pNd
&& 0 != ( pNd
= pNd
->FindTableNode() ) )
833 aTxt
= ((SwTableNode
*)pNd
)->GetTable().GetFrmFmt()->GetName();
836 ( aTxt
.Insert( '#', 0 ) += cMarkSeperator
).
837 AppendAscii( pMarkToTable
);
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
),
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
861 if( pTOXIntl
->IsNumeric( sText
) )
863 nRet
= (USHORT
)sText
.ToInt32();
866 //illegal values are also set to 'ARTICLE' as non-numeric values are
867 if(nRet
> AUTH_TYPE_END
)
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();
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
!= ' ')
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();
903 sText
= SwAuthorityFieldType::GetAuthTypeName((ToxAuthorityType
) --nLevel
);
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
)
924 SwAuthorityField
* pField
= (SwAuthorityField
*)m_rField
.GetFld();
925 SwAuthorityFieldType
* pType
= (SwAuthorityFieldType
*)
927 if(pType
->IsSortByDocument())
928 bRet
= SwTOXSortTabBase::operator<(rBase
);
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() );
948 bRet
= (-1 == nComp
) == pKey
->bSortAscending
;