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.hxx,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 ************************************************************************/
33 #include <i18npool/lang.h>
36 #include <com/sun/star/lang/Locale.hpp>
45 class IndexEntrySupplierWrapper
;
59 const SwCntntNode
* pNd
;
63 SwTOXSource() : pNd(0), nPos(0), bMainEntry(FALSE
) {}
64 SwTOXSource( const SwCntntNode
* pNode
, xub_StrLen n
, BOOL bMain
)
65 : pNd(pNode
), nPos(n
), bMainEntry(bMain
)
69 SV_DECL_VARARR( SwTOXSources
, SwTOXSource
, 0, 10 )
71 class SwTOXInternational
73 IndexEntrySupplierWrapper
* pIndexWrapper
;
74 CharClass
* pCharClass
;
76 String sSortAlgorithm
;
82 SwTOXInternational( LanguageType nLang
, USHORT nOptions
,
83 const String
& rSortAlgorithm
);
84 SwTOXInternational( const SwTOXInternational
& );
85 ~SwTOXInternational();
87 sal_Int32
Compare( const String
& rTxt1
, const String
& rTxtReading1
,
88 const ::com::sun::star::lang::Locale
& rLocale1
,
89 const String
& rTxt2
, const String
& rTxtReading2
,
90 const ::com::sun::star::lang::Locale
& rLocale2
) const;
92 inline BOOL
IsEqual( const String
& rTxt1
, const String
& rTxtReading1
,
93 const ::com::sun::star::lang::Locale
& rLocale1
,
94 const String
& rTxt2
, const String
& rTxtReading2
,
95 const ::com::sun::star::lang::Locale
& rLocale2
) const
97 return 0 == Compare( rTxt1
, rTxtReading1
, rLocale1
,
98 rTxt2
, rTxtReading2
, rLocale2
);
101 inline BOOL
IsLess( const String
& rTxt1
, const String
& rTxtReading1
,
102 const ::com::sun::star::lang::Locale
& rLocale1
,
103 const String
& rTxt2
, const String
& rTxtReading2
,
104 const ::com::sun::star::lang::Locale
& rLocale2
) const
106 return -1 == Compare( rTxt1
, rTxtReading1
, rLocale1
,
107 rTxt2
, rTxtReading2
, rLocale2
);
110 String
GetIndexKey( const String
& rTxt
, const String
& rTxtReading
,
111 const ::com::sun::star::lang::Locale
& rLcl
) const;
113 String
GetFollowingText( BOOL bMorePages
) const;
115 String
ToUpper( const String
& rStr
, xub_StrLen nPos
) const;
116 inline BOOL
IsNumeric( const String
& rStr
) const;
119 /*--------------------------------------------------------------------
120 Beschreibung: Klassen fuer die Sortierung der Verzeichnisse
121 --------------------------------------------------------------------*/
123 struct SwTOXSortTabBase
125 SwTOXSources aTOXSources
;
126 ::com::sun::star::lang::Locale aLocale
;
127 const SwTxtNode
* pTOXNd
;
128 const SwTxtTOXMark
* pTxtMark
;
129 const SwTOXInternational
* pTOXIntl
;
135 SwTOXSortTabBase( TOXSortType nType
,
136 const SwCntntNode
* pTOXSrc
,
137 const SwTxtTOXMark
* pTxtMark
,
138 const SwTOXInternational
* pIntl
,
139 const ::com::sun::star::lang::Locale
* pLocale
= NULL
);
140 virtual ~SwTOXSortTabBase() {}
142 USHORT
GetType() const { return nType
; }
143 USHORT
GetOptions() const { return nOpt
; }
145 virtual void FillText( SwTxtNode
& rNd
, const SwIndex
& rInsPos
, USHORT nAuthField
= 0) const;
146 virtual USHORT
GetLevel() const = 0;
147 virtual BOOL
operator==( const SwTOXSortTabBase
& );
148 virtual BOOL
operator<( const SwTOXSortTabBase
& );
150 virtual String
GetURL() const;
152 inline void GetTxt( String
&, String
& ) const;
153 inline const ::com::sun::star::lang::Locale
& GetLocale() const;
158 String sSortTxtReading
;
160 virtual void _GetText( String
&, String
& ) = 0;
163 inline void SwTOXSortTabBase::GetTxt( String
& rSortTxt
,
164 String
& rSortTxtReading
) const
168 SwTOXSortTabBase
* pThis
= (SwTOXSortTabBase
*)this;
169 pThis
->_GetText( pThis
->sSortTxt
, pThis
->sSortTxtReading
);
170 pThis
->bValidTxt
= TRUE
;
174 rSortTxtReading
= sSortTxtReading
;
177 inline const ::com::sun::star::lang::Locale
& SwTOXSortTabBase::GetLocale() const
182 /*--------------------------------------------------------------------
183 Beschreibung: fuer Sortierung nach Text
184 --------------------------------------------------------------------*/
186 struct SwTOXIndex
: public SwTOXSortTabBase
188 SwTOXIndex( const SwTxtNode
&, const SwTxtTOXMark
*, USHORT nOptions
, BYTE nKeyLevel
,
189 const SwTOXInternational
& rIntl
,
190 const ::com::sun::star::lang::Locale
& rLocale
);
191 virtual ~SwTOXIndex() {}
194 virtual void FillText( SwTxtNode
& rNd
, const SwIndex
& rInsPos
, USHORT nAuthField
= 0 ) const;
195 virtual USHORT
GetLevel() const;
196 virtual BOOL
operator==( const SwTOXSortTabBase
& );
197 virtual BOOL
operator<( const SwTOXSortTabBase
& );
200 virtual void _GetText( String
&, String
& );
205 struct SwTOXCustom
: public SwTOXSortTabBase
207 SwTOXCustom( const String
& rKey
, const String
& rReading
, USHORT nLevel
,
208 const SwTOXInternational
& rIntl
,
209 const ::com::sun::star::lang::Locale
& rLocale
);
210 virtual ~SwTOXCustom() {}
212 virtual USHORT
GetLevel() const;
213 virtual BOOL
operator==( const SwTOXSortTabBase
& );
214 virtual BOOL
operator<( const SwTOXSortTabBase
& );
217 virtual void _GetText( String
&, String
& );
224 /*--------------------------------------------------------------------
225 Beschreibung: fuer Sortierung nach Position
226 --------------------------------------------------------------------*/
228 struct SwTOXContent
: public SwTOXSortTabBase
230 SwTOXContent( const SwTxtNode
&, const SwTxtTOXMark
*,
231 const SwTOXInternational
& rIntl
);
232 virtual ~SwTOXContent() {}
234 virtual void FillText( SwTxtNode
& rNd
, const SwIndex
& rInsPos
, USHORT nAuthField
= 0 ) const;
235 virtual USHORT
GetLevel() const;
237 virtual void _GetText( String
&, String
& );
241 struct SwTOXPara
: public SwTOXSortTabBase
243 SwTOXPara( const SwCntntNode
&, SwTOXElement
, USHORT nLevel
= FORM_ALPHA_DELIMITTER
);
244 virtual ~SwTOXPara() {}
246 void SetStartIndex( xub_StrLen nSet
) { nStartIndex
= nSet
;}
247 void SetEndIndex( xub_StrLen nSet
) { nEndIndex
= nSet
;}
249 virtual void FillText( SwTxtNode
& rNd
, const SwIndex
& rInsPos
, USHORT nAuthField
= 0 ) const;
250 virtual USHORT
GetLevel() const;
252 virtual String
GetURL() const;
254 virtual void _GetText( String
&, String
& );
258 xub_StrLen nStartIndex
;
259 xub_StrLen nEndIndex
;
262 struct SwTOXTable
: public SwTOXSortTabBase
264 SwTOXTable( const SwCntntNode
& rNd
);
265 virtual ~SwTOXTable() {}
267 void SetLevel(USHORT nSet
){nLevel
= nSet
;}
269 virtual USHORT
GetLevel() const;
271 virtual String
GetURL() const;
273 virtual void _GetText( String
&, String
& );
278 struct SwTOXAuthority
: public SwTOXSortTabBase
282 virtual void FillText( SwTxtNode
& rNd
, const SwIndex
& rInsPos
, USHORT nAuthField
= 0 ) const;
283 virtual void _GetText( String
&, String
& );
286 SwTOXAuthority( const SwCntntNode
& rNd
, SwFmtFld
& rField
, const SwTOXInternational
& rIntl
);
287 virtual ~SwTOXAuthority() {}
289 SwFmtFld
& GetFldFmt() {return m_rField
;}
291 virtual BOOL
operator==( const SwTOXSortTabBase
& );
292 virtual BOOL
operator<( const SwTOXSortTabBase
& );
293 virtual USHORT
GetLevel() const;
297 #endif // _TXMSRT_HXX