1*1d2dbeb0SAndrew Rist /**************************************************************
2cdf0e10cSrcweir *
3*1d2dbeb0SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one
4*1d2dbeb0SAndrew Rist * or more contributor license agreements. See the NOTICE file
5*1d2dbeb0SAndrew Rist * distributed with this work for additional information
6*1d2dbeb0SAndrew Rist * regarding copyright ownership. The ASF licenses this file
7*1d2dbeb0SAndrew Rist * to you under the Apache License, Version 2.0 (the
8*1d2dbeb0SAndrew Rist * "License"); you may not use this file except in compliance
9*1d2dbeb0SAndrew Rist * with the License. You may obtain a copy of the License at
10*1d2dbeb0SAndrew Rist *
11*1d2dbeb0SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0
12*1d2dbeb0SAndrew Rist *
13*1d2dbeb0SAndrew Rist * Unless required by applicable law or agreed to in writing,
14*1d2dbeb0SAndrew Rist * software distributed under the License is distributed on an
15*1d2dbeb0SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*1d2dbeb0SAndrew Rist * KIND, either express or implied. See the License for the
17*1d2dbeb0SAndrew Rist * specific language governing permissions and limitations
18*1d2dbeb0SAndrew Rist * under the License.
19*1d2dbeb0SAndrew Rist *
20*1d2dbeb0SAndrew Rist *************************************************************/
21*1d2dbeb0SAndrew Rist
22*1d2dbeb0SAndrew Rist
23cdf0e10cSrcweir #ifndef SW_TXMSRT_HXX
24cdf0e10cSrcweir #define SW_TXMSRT_HXX
25cdf0e10cSrcweir
26cdf0e10cSrcweir #include <i18npool/lang.h>
27cdf0e10cSrcweir #include <tox.hxx>
28cdf0e10cSrcweir
29cdf0e10cSrcweir #include <com/sun/star/lang/Locale.hpp>
30cdf0e10cSrcweir
31cdf0e10cSrcweir
32cdf0e10cSrcweir class CharClass;
33cdf0e10cSrcweir class SwCntntNode;
34cdf0e10cSrcweir class SwTxtNode;
35cdf0e10cSrcweir class SwTxtTOXMark;
36cdf0e10cSrcweir class SwIndex;
37cdf0e10cSrcweir class SwFmtFld;
38cdf0e10cSrcweir class IndexEntrySupplierWrapper;
39cdf0e10cSrcweir
40cdf0e10cSrcweir enum TOXSortType
41cdf0e10cSrcweir {
42cdf0e10cSrcweir TOX_SORT_INDEX,
43cdf0e10cSrcweir TOX_SORT_CUSTOM,
44cdf0e10cSrcweir TOX_SORT_CONTENT,
45cdf0e10cSrcweir TOX_SORT_PARA,
46cdf0e10cSrcweir TOX_SORT_TABLE,
47cdf0e10cSrcweir TOX_SORT_AUTHORITY
48cdf0e10cSrcweir };
49cdf0e10cSrcweir
50cdf0e10cSrcweir struct SwTOXSource
51cdf0e10cSrcweir {
52cdf0e10cSrcweir const SwCntntNode* pNd;
53cdf0e10cSrcweir xub_StrLen nPos;
54cdf0e10cSrcweir sal_Bool bMainEntry;
55cdf0e10cSrcweir
SwTOXSourceSwTOXSource56cdf0e10cSrcweir SwTOXSource() : pNd(0), nPos(0), bMainEntry(sal_False) {}
SwTOXSourceSwTOXSource57cdf0e10cSrcweir SwTOXSource( const SwCntntNode* pNode, xub_StrLen n, sal_Bool bMain )
58cdf0e10cSrcweir : pNd(pNode), nPos(n), bMainEntry(bMain)
59cdf0e10cSrcweir {}
60cdf0e10cSrcweir };
61cdf0e10cSrcweir
62cdf0e10cSrcweir SV_DECL_VARARR( SwTOXSources, SwTOXSource, 0, 10 )
63cdf0e10cSrcweir
64cdf0e10cSrcweir class SwTOXInternational
65cdf0e10cSrcweir {
66cdf0e10cSrcweir IndexEntrySupplierWrapper* pIndexWrapper;
67cdf0e10cSrcweir CharClass* pCharClass;
68cdf0e10cSrcweir LanguageType eLang;
69cdf0e10cSrcweir String sSortAlgorithm;
70cdf0e10cSrcweir sal_uInt16 nOptions;
71cdf0e10cSrcweir
72cdf0e10cSrcweir void Init();
73cdf0e10cSrcweir
74cdf0e10cSrcweir public:
75cdf0e10cSrcweir SwTOXInternational( LanguageType nLang, sal_uInt16 nOptions,
76cdf0e10cSrcweir const String& rSortAlgorithm );
77cdf0e10cSrcweir SwTOXInternational( const SwTOXInternational& );
78cdf0e10cSrcweir ~SwTOXInternational();
79cdf0e10cSrcweir
80cdf0e10cSrcweir sal_Int32 Compare( const String& rTxt1, const String& rTxtReading1,
81cdf0e10cSrcweir const ::com::sun::star::lang::Locale& rLocale1,
82cdf0e10cSrcweir const String& rTxt2, const String& rTxtReading2,
83cdf0e10cSrcweir const ::com::sun::star::lang::Locale& rLocale2 ) const;
84cdf0e10cSrcweir
IsEqual(const String & rTxt1,const String & rTxtReading1,const::com::sun::star::lang::Locale & rLocale1,const String & rTxt2,const String & rTxtReading2,const::com::sun::star::lang::Locale & rLocale2) const85cdf0e10cSrcweir inline sal_Bool IsEqual( const String& rTxt1, const String& rTxtReading1,
86cdf0e10cSrcweir const ::com::sun::star::lang::Locale& rLocale1,
87cdf0e10cSrcweir const String& rTxt2, const String& rTxtReading2,
88cdf0e10cSrcweir const ::com::sun::star::lang::Locale& rLocale2 ) const
89cdf0e10cSrcweir {
90cdf0e10cSrcweir return 0 == Compare( rTxt1, rTxtReading1, rLocale1,
91cdf0e10cSrcweir rTxt2, rTxtReading2, rLocale2 );
92cdf0e10cSrcweir }
93cdf0e10cSrcweir
IsLess(const String & rTxt1,const String & rTxtReading1,const::com::sun::star::lang::Locale & rLocale1,const String & rTxt2,const String & rTxtReading2,const::com::sun::star::lang::Locale & rLocale2) const94cdf0e10cSrcweir inline sal_Bool IsLess( const String& rTxt1, const String& rTxtReading1,
95cdf0e10cSrcweir const ::com::sun::star::lang::Locale& rLocale1,
96cdf0e10cSrcweir const String& rTxt2, const String& rTxtReading2,
97cdf0e10cSrcweir const ::com::sun::star::lang::Locale& rLocale2 ) const
98cdf0e10cSrcweir {
99cdf0e10cSrcweir return -1 == Compare( rTxt1, rTxtReading1, rLocale1,
100cdf0e10cSrcweir rTxt2, rTxtReading2, rLocale2 );
101cdf0e10cSrcweir }
102cdf0e10cSrcweir
103cdf0e10cSrcweir String GetIndexKey( const String& rTxt, const String& rTxtReading,
104cdf0e10cSrcweir const ::com::sun::star::lang::Locale& rLcl ) const;
105cdf0e10cSrcweir
106cdf0e10cSrcweir String GetFollowingText( sal_Bool bMorePages ) const;
107cdf0e10cSrcweir
108cdf0e10cSrcweir String ToUpper( const String& rStr, xub_StrLen nPos ) const;
109cdf0e10cSrcweir inline sal_Bool IsNumeric( const String& rStr ) const;
110cdf0e10cSrcweir };
111cdf0e10cSrcweir
112cdf0e10cSrcweir /*--------------------------------------------------------------------
113cdf0e10cSrcweir Beschreibung: Klassen fuer die Sortierung der Verzeichnisse
114cdf0e10cSrcweir --------------------------------------------------------------------*/
115cdf0e10cSrcweir
116cdf0e10cSrcweir struct SwTOXSortTabBase
117cdf0e10cSrcweir {
118cdf0e10cSrcweir SwTOXSources aTOXSources;
119cdf0e10cSrcweir ::com::sun::star::lang::Locale aLocale;
120cdf0e10cSrcweir const SwTxtNode* pTOXNd;
121cdf0e10cSrcweir const SwTxtTOXMark* pTxtMark;
122cdf0e10cSrcweir const SwTOXInternational* pTOXIntl;
123cdf0e10cSrcweir sal_uLong nPos;
124cdf0e10cSrcweir xub_StrLen nCntPos;
125cdf0e10cSrcweir sal_uInt16 nType;
126cdf0e10cSrcweir static sal_uInt16 nOpt;
127cdf0e10cSrcweir
128cdf0e10cSrcweir SwTOXSortTabBase( TOXSortType nType,
129cdf0e10cSrcweir const SwCntntNode* pTOXSrc,
130cdf0e10cSrcweir const SwTxtTOXMark* pTxtMark,
131cdf0e10cSrcweir const SwTOXInternational* pIntl,
132cdf0e10cSrcweir const ::com::sun::star::lang::Locale* pLocale = NULL );
~SwTOXSortTabBaseSwTOXSortTabBase133cdf0e10cSrcweir virtual ~SwTOXSortTabBase() {}
134cdf0e10cSrcweir
GetTypeSwTOXSortTabBase135cdf0e10cSrcweir sal_uInt16 GetType() const { return nType; }
GetOptionsSwTOXSortTabBase136cdf0e10cSrcweir sal_uInt16 GetOptions() const { return nOpt; }
137cdf0e10cSrcweir
138cdf0e10cSrcweir virtual void FillText( SwTxtNode& rNd, const SwIndex& rInsPos, sal_uInt16 nAuthField = 0) const;
139cdf0e10cSrcweir virtual sal_uInt16 GetLevel() const = 0;
140cdf0e10cSrcweir virtual sal_Bool operator==( const SwTOXSortTabBase& );
141cdf0e10cSrcweir virtual sal_Bool operator<( const SwTOXSortTabBase& );
142cdf0e10cSrcweir
143cdf0e10cSrcweir virtual String GetURL() const;
144cdf0e10cSrcweir
145cdf0e10cSrcweir inline void GetTxt( String&, String& ) const;
146cdf0e10cSrcweir inline const ::com::sun::star::lang::Locale& GetLocale() const;
147cdf0e10cSrcweir
148cdf0e10cSrcweir private:
149cdf0e10cSrcweir sal_Bool bValidTxt;
150cdf0e10cSrcweir String sSortTxt;
151cdf0e10cSrcweir String sSortTxtReading;
152cdf0e10cSrcweir
153cdf0e10cSrcweir virtual void GetText_Impl( String&, String& ) const = 0;
154cdf0e10cSrcweir };
155cdf0e10cSrcweir
GetTxt(String & rSortTxt,String & rSortTxtReading) const156cdf0e10cSrcweir inline void SwTOXSortTabBase::GetTxt( String& rSortTxt,
157cdf0e10cSrcweir String& rSortTxtReading ) const
158cdf0e10cSrcweir {
159cdf0e10cSrcweir if( !bValidTxt )
160cdf0e10cSrcweir {
161cdf0e10cSrcweir SwTOXSortTabBase* pThis = (SwTOXSortTabBase*)this;
162cdf0e10cSrcweir pThis->GetText_Impl( pThis->sSortTxt, pThis->sSortTxtReading );
163cdf0e10cSrcweir pThis->bValidTxt = sal_True;
164cdf0e10cSrcweir }
165cdf0e10cSrcweir
166cdf0e10cSrcweir rSortTxt = sSortTxt;
167cdf0e10cSrcweir rSortTxtReading = sSortTxtReading;
168cdf0e10cSrcweir }
169cdf0e10cSrcweir
GetLocale() const170cdf0e10cSrcweir inline const ::com::sun::star::lang::Locale& SwTOXSortTabBase::GetLocale() const
171cdf0e10cSrcweir {
172cdf0e10cSrcweir return aLocale;
173cdf0e10cSrcweir }
174cdf0e10cSrcweir
175cdf0e10cSrcweir /*--------------------------------------------------------------------
176cdf0e10cSrcweir Beschreibung: fuer Sortierung nach Text
177cdf0e10cSrcweir --------------------------------------------------------------------*/
178cdf0e10cSrcweir
179cdf0e10cSrcweir struct SwTOXIndex : public SwTOXSortTabBase
180cdf0e10cSrcweir {
181cdf0e10cSrcweir SwTOXIndex( const SwTxtNode&, const SwTxtTOXMark*, sal_uInt16 nOptions, sal_uInt8 nKeyLevel,
182cdf0e10cSrcweir const SwTOXInternational& rIntl,
183cdf0e10cSrcweir const ::com::sun::star::lang::Locale& rLocale );
~SwTOXIndexSwTOXIndex184cdf0e10cSrcweir virtual ~SwTOXIndex() {}
185cdf0e10cSrcweir
186cdf0e10cSrcweir
187cdf0e10cSrcweir virtual void FillText( SwTxtNode& rNd, const SwIndex& rInsPos, sal_uInt16 nAuthField = 0 ) const;
188cdf0e10cSrcweir virtual sal_uInt16 GetLevel() const;
189cdf0e10cSrcweir virtual sal_Bool operator==( const SwTOXSortTabBase& );
190cdf0e10cSrcweir virtual sal_Bool operator<( const SwTOXSortTabBase& );
191cdf0e10cSrcweir
192cdf0e10cSrcweir private:
193cdf0e10cSrcweir virtual void GetText_Impl( String&, String& ) const;
194cdf0e10cSrcweir
195cdf0e10cSrcweir sal_uInt8 nKeyLevel;
196cdf0e10cSrcweir };
197cdf0e10cSrcweir
198cdf0e10cSrcweir struct SwTOXCustom : public SwTOXSortTabBase
199cdf0e10cSrcweir {
200cdf0e10cSrcweir SwTOXCustom( const String& rKey, const String& rReading, sal_uInt16 nLevel,
201cdf0e10cSrcweir const SwTOXInternational& rIntl,
202cdf0e10cSrcweir const ::com::sun::star::lang::Locale& rLocale );
~SwTOXCustomSwTOXCustom203cdf0e10cSrcweir virtual ~SwTOXCustom() {}
204cdf0e10cSrcweir
205cdf0e10cSrcweir virtual sal_uInt16 GetLevel() const;
206cdf0e10cSrcweir virtual sal_Bool operator==( const SwTOXSortTabBase& );
207cdf0e10cSrcweir virtual sal_Bool operator<( const SwTOXSortTabBase& );
208cdf0e10cSrcweir
209cdf0e10cSrcweir private:
210cdf0e10cSrcweir virtual void GetText_Impl( String&, String& ) const;
211cdf0e10cSrcweir
212cdf0e10cSrcweir String aKey;
213cdf0e10cSrcweir String sReading;
214cdf0e10cSrcweir sal_uInt16 nLev;
215cdf0e10cSrcweir };
216cdf0e10cSrcweir
217cdf0e10cSrcweir /*--------------------------------------------------------------------
218cdf0e10cSrcweir Beschreibung: fuer Sortierung nach Position
219cdf0e10cSrcweir --------------------------------------------------------------------*/
220cdf0e10cSrcweir
221cdf0e10cSrcweir struct SwTOXContent : public SwTOXSortTabBase
222cdf0e10cSrcweir {
223cdf0e10cSrcweir SwTOXContent( const SwTxtNode&, const SwTxtTOXMark*,
224cdf0e10cSrcweir const SwTOXInternational& rIntl );
~SwTOXContentSwTOXContent225cdf0e10cSrcweir virtual ~SwTOXContent() {}
226cdf0e10cSrcweir
227cdf0e10cSrcweir virtual void FillText( SwTxtNode& rNd, const SwIndex& rInsPos, sal_uInt16 nAuthField = 0 ) const;
228cdf0e10cSrcweir virtual sal_uInt16 GetLevel() const;
229cdf0e10cSrcweir private:
230cdf0e10cSrcweir virtual void GetText_Impl( String&, String& ) const;
231cdf0e10cSrcweir
232cdf0e10cSrcweir };
233cdf0e10cSrcweir
234cdf0e10cSrcweir struct SwTOXPara : public SwTOXSortTabBase
235cdf0e10cSrcweir {
236cdf0e10cSrcweir SwTOXPara( const SwCntntNode&, SwTOXElement, sal_uInt16 nLevel = FORM_ALPHA_DELIMITTER );
~SwTOXParaSwTOXPara237cdf0e10cSrcweir virtual ~SwTOXPara() {}
238cdf0e10cSrcweir
SetStartIndexSwTOXPara239cdf0e10cSrcweir void SetStartIndex( xub_StrLen nSet) { nStartIndex = nSet;}
SetEndIndexSwTOXPara240cdf0e10cSrcweir void SetEndIndex( xub_StrLen nSet ) { nEndIndex = nSet;}
241cdf0e10cSrcweir
242cdf0e10cSrcweir virtual void FillText( SwTxtNode& rNd, const SwIndex& rInsPos, sal_uInt16 nAuthField = 0 ) const;
243cdf0e10cSrcweir virtual sal_uInt16 GetLevel() const;
244cdf0e10cSrcweir
245cdf0e10cSrcweir virtual String GetURL() const;
246cdf0e10cSrcweir private:
247cdf0e10cSrcweir virtual void GetText_Impl( String&, String& ) const;
248cdf0e10cSrcweir
249cdf0e10cSrcweir SwTOXElement eType;
250cdf0e10cSrcweir sal_uInt16 m_nLevel;
251cdf0e10cSrcweir xub_StrLen nStartIndex;
252cdf0e10cSrcweir xub_StrLen nEndIndex;
253cdf0e10cSrcweir };
254cdf0e10cSrcweir
255cdf0e10cSrcweir struct SwTOXTable : public SwTOXSortTabBase
256cdf0e10cSrcweir {
257cdf0e10cSrcweir SwTOXTable( const SwCntntNode& rNd );
~SwTOXTableSwTOXTable258cdf0e10cSrcweir virtual ~SwTOXTable() {}
259cdf0e10cSrcweir
SetLevelSwTOXTable260cdf0e10cSrcweir void SetLevel(sal_uInt16 nSet){nLevel = nSet;}
261cdf0e10cSrcweir
262cdf0e10cSrcweir virtual sal_uInt16 GetLevel() const;
263cdf0e10cSrcweir
264cdf0e10cSrcweir virtual String GetURL() const;
265cdf0e10cSrcweir private:
266cdf0e10cSrcweir virtual void GetText_Impl( String&, String& ) const;
267cdf0e10cSrcweir
268cdf0e10cSrcweir sal_uInt16 nLevel;
269cdf0e10cSrcweir };
270cdf0e10cSrcweir
271cdf0e10cSrcweir struct SwTOXAuthority : public SwTOXSortTabBase
272cdf0e10cSrcweir {
273cdf0e10cSrcweir private:
274cdf0e10cSrcweir SwFmtFld& m_rField;
275cdf0e10cSrcweir virtual void FillText( SwTxtNode& rNd, const SwIndex& rInsPos, sal_uInt16 nAuthField = 0 ) const;
276cdf0e10cSrcweir virtual void GetText_Impl( String&, String& ) const;
277cdf0e10cSrcweir
278cdf0e10cSrcweir public:
279cdf0e10cSrcweir SwTOXAuthority( const SwCntntNode& rNd, SwFmtFld& rField, const SwTOXInternational& rIntl );
~SwTOXAuthoritySwTOXAuthority280cdf0e10cSrcweir virtual ~SwTOXAuthority() {}
281cdf0e10cSrcweir
GetFldFmtSwTOXAuthority282cdf0e10cSrcweir SwFmtFld& GetFldFmt() {return m_rField;}
283cdf0e10cSrcweir
284cdf0e10cSrcweir virtual sal_Bool operator==( const SwTOXSortTabBase& );
285cdf0e10cSrcweir virtual sal_Bool operator<( const SwTOXSortTabBase& );
286cdf0e10cSrcweir virtual sal_uInt16 GetLevel() const;
287cdf0e10cSrcweir };
288cdf0e10cSrcweir
289cdf0e10cSrcweir
290cdf0e10cSrcweir #endif // SW_TXMSRT_HXX
291