merge the formfield patch from ooo-build
[ooovba.git] / sw / source / core / inc / txmsrt.hxx
blob0427138f982070a510b3471820d4587ed0391daa
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: txmsrt.hxx,v $
10 * $Revision: 1.11 $
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 ************************************************************************/
30 #ifndef _TXMSRT_HXX
31 #define _TXMSRT_HXX
33 #include <i18npool/lang.h>
34 #include <tox.hxx>
36 #include <com/sun/star/lang/Locale.hpp>
39 class CharClass;
40 class SwCntntNode;
41 class SwTxtNode;
42 class SwTxtTOXMark;
43 class SwIndex;
44 class SwFmtFld;
45 class IndexEntrySupplierWrapper;
47 enum TOXSortType
49 TOX_SORT_INDEX,
50 TOX_SORT_CUSTOM,
51 TOX_SORT_CONTENT,
52 TOX_SORT_PARA,
53 TOX_SORT_TABLE,
54 TOX_SORT_AUTHORITY
57 struct SwTOXSource
59 const SwCntntNode* pNd;
60 xub_StrLen nPos;
61 BOOL bMainEntry;
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;
75 LanguageType eLang;
76 String sSortAlgorithm;
77 USHORT nOptions;
79 void Init();
81 public:
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;
130 ULONG nPos;
131 xub_StrLen nCntPos;
132 USHORT nType;
133 static USHORT nOpt;
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;
155 private:
156 BOOL bValidTxt;
157 String sSortTxt;
158 String sSortTxtReading;
160 virtual void _GetText( String&, String& ) = 0;
163 inline void SwTOXSortTabBase::GetTxt( String& rSortTxt,
164 String& rSortTxtReading ) const
166 if( !bValidTxt )
168 SwTOXSortTabBase* pThis = (SwTOXSortTabBase*)this;
169 pThis->_GetText( pThis->sSortTxt, pThis->sSortTxtReading );
170 pThis->bValidTxt = TRUE;
173 rSortTxt = sSortTxt;
174 rSortTxtReading = sSortTxtReading;
177 inline const ::com::sun::star::lang::Locale& SwTOXSortTabBase::GetLocale() const
179 return aLocale;
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& );
199 private:
200 virtual void _GetText( String&, String& );
202 BYTE nKeyLevel;
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& );
216 private:
217 virtual void _GetText( String&, String& );
219 String aKey;
220 String sReading;
221 USHORT nLev;
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;
236 private:
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;
253 private:
254 virtual void _GetText( String&, String& );
256 SwTOXElement eType;
257 USHORT m_nLevel;
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;
272 private:
273 virtual void _GetText( String&, String& );
275 USHORT nLevel;
278 struct SwTOXAuthority : public SwTOXSortTabBase
280 private:
281 SwFmtFld& m_rField;
282 virtual void FillText( SwTxtNode& rNd, const SwIndex& rInsPos, USHORT nAuthField = 0 ) const;
283 virtual void _GetText( String&, String& );
285 public:
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