LibreOffice Module sw (master) 1
txmsrt.hxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 */
19#ifndef INCLUDED_SW_SOURCE_CORE_INC_TXMSRT_HXX
20#define INCLUDED_SW_SOURCE_CORE_INC_TXMSRT_HXX
21
22#include <i18nlangtag/lang.h>
24#include <nodeoffset.hxx>
25#include <tox.hxx>
26
27#include <com/sun/star/lang/Locale.hpp>
28#include <optional>
29#include <utility>
30
31class SwContentNode;
32class SwTextNode;
33class SwTextTOXMark;
34class SwContentIndex;
35class SwFormatField;
36class SwRootFrame;
38
40{
47};
48
50{
52 sal_Int32 nPos;
54
55 SwTOXSource( const SwContentNode* pNode, sal_Int32 n, bool bMain )
56 : pNd(pNode), nPos(n), bMainEntry(bMain)
57 {
58 }
59};
60
62{
63 OUString sText;
64 OUString sReading;
65
67
68 TextAndReading(OUString aText, OUString aReading)
69 : sText(std::move(aText))
70 , sReading(std::move(aReading))
71 {}
72};
73
75{
76 std::unique_ptr<IndexEntrySupplierWrapper> m_pIndexWrapper;
77 std::optional<CharClass> m_oCharClass;
81
82 void Init();
83
84public:
86 OUString aSortAlgorithm );
89
90 sal_Int32 Compare( const TextAndReading& rTaR1,
91 const css::lang::Locale& rLocale1,
92 const TextAndReading& rTaR2,
93 const css::lang::Locale& rLocale2 ) const;
94
95 bool IsEqual( const TextAndReading& rTaR1,
96 const css::lang::Locale& rLocale1,
97 const TextAndReading& rTaR2,
98 const css::lang::Locale& rLocale2 ) const
99 {
100 return 0 == Compare( rTaR1, rLocale1, rTaR2, rLocale2 );
101 }
102
103 bool IsLess( const TextAndReading& rTaR1,
104 const css::lang::Locale& rLocale1,
105 const TextAndReading& rTaR2,
106 const css::lang::Locale& rLocale2 ) const
107 {
108 return -1 == Compare( rTaR1, rLocale1, rTaR2, rLocale2 );
109 }
110
111 OUString GetIndexKey( const TextAndReading& rTaR,
112 const css::lang::Locale& rLcl ) const;
113
114 OUString GetFollowingText( bool bMorePages ) const;
115
116 OUString ToUpper( const OUString& rStr, sal_Int32 nPos ) const;
117 bool IsNumeric( const OUString& rStr ) const;
118};
119
124{
125 bool operator==(const SwTOXSortTabBase&) const = delete;
126 bool operator<(const SwTOXSortTabBase&) const = delete;
127
128 std::vector<SwTOXSource> aTOXSources;
129 css::lang::Locale aLocale;
134 sal_Int32 nCntPos;
135 sal_uInt16 nType;
137
139 const SwContentNode* pTOXSrc,
141 const SwTOXInternational* pIntl,
142 const css::lang::Locale* pLocale = nullptr );
143 virtual ~SwTOXSortTabBase() {}
144
145 sal_uInt16 GetType() const { return nType; }
146 static SwTOIOptions GetOptions() { return nOpt; }
147
148 virtual void FillText(SwTextNode& rNd, const SwContentIndex& rInsPos,
149 sal_uInt16 nAuthField, SwRootFrame const* pLayout) const;
150 virtual sal_uInt16 GetLevel() const = 0;
151 virtual bool equivalent( const SwTOXSortTabBase& );
152 virtual bool sort_lt( const SwTOXSortTabBase& );
153
154 virtual std::pair<OUString, bool> GetURL(SwRootFrame const*const pLayout) const;
155
156 virtual bool IsFullPara() const;
157
158 // must be called
159 inline void InitText(SwRootFrame const*const pLayout);
160 inline TextAndReading const & GetText() const;
161 inline const css::lang::Locale& GetLocale() const;
162
163private:
166
167 virtual TextAndReading GetText_Impl(SwRootFrame const* pLayout) const = 0;
168};
169
170inline void SwTOXSortTabBase::InitText(SwRootFrame const*const pLayout)
171{
172 // 'this' is 'SwTOXSortTabBase const*', so the virtual
173 // mechanism will call the derived class' GetText_Impl
174 assert(!m_bValidText);
175 m_aSort = GetText_Impl(pLayout);
176 m_bValidText = true;
177}
178
180{
181 assert(m_bValidText);
182 return m_aSort;
183}
184
185inline const css::lang::Locale& SwTOXSortTabBase::GetLocale() const
186{
187 return aLocale;
188}
189
193struct SwTOXIndex final : public SwTOXSortTabBase
194{
196 const SwTOXInternational& rIntl,
197 const css::lang::Locale& rLocale );
198
199 virtual void FillText(SwTextNode& rNd, const SwContentIndex& rInsPos,
200 sal_uInt16 nAuthField, SwRootFrame const* pLayout) const override;
201 virtual sal_uInt16 GetLevel() const override;
202 virtual bool equivalent( const SwTOXSortTabBase& ) override;
203 virtual bool sort_lt( const SwTOXSortTabBase& ) override;
204
205private:
206 virtual TextAndReading GetText_Impl(SwRootFrame const* pLayout) const override;
207
209};
210
211struct SwTOXCustom final : public SwTOXSortTabBase
212{
213 SwTOXCustom( TextAndReading aKey, sal_uInt16 nLevel,
214 const SwTOXInternational& rIntl,
215 const css::lang::Locale& rLocale );
216
217 virtual sal_uInt16 GetLevel() const override;
218 virtual bool equivalent( const SwTOXSortTabBase& ) override;
219 virtual bool sort_lt( const SwTOXSortTabBase& ) override;
220
221private:
222 virtual TextAndReading GetText_Impl(SwRootFrame const* pLayout) const override;
223
225 sal_uInt16 nLev;
226};
227
231struct SwTOXContent final : public SwTOXSortTabBase
232{
233 SwTOXContent( const SwTextNode&, const SwTextTOXMark*,
234 const SwTOXInternational& rIntl );
235
236 virtual void FillText(SwTextNode& rNd, const SwContentIndex& rInsPos,
237 sal_uInt16 nAuthField, SwRootFrame const* pLayout) const override;
238 virtual sal_uInt16 GetLevel() const override;
239private:
240 virtual TextAndReading GetText_Impl(SwRootFrame const* pLayout) const override;
241
242};
243
244struct SwTOXPara final : public SwTOXSortTabBase
245{
247 sal_uInt16 nLevel = FORM_ALPHA_DELIMITER,
248 OUString sSeqName = OUString());
249
250 void SetStartIndex(sal_Int32 nSet) { nStartIndex = nSet; }
251 void SetEndIndex(sal_Int32 nSet) { nEndIndex = nSet; }
252
253 virtual void FillText(SwTextNode& rNd, const SwContentIndex& rInsPos,
254 sal_uInt16 nAuthField, SwRootFrame const* pLayout) const override;
255 virtual sal_uInt16 GetLevel() const override;
256
257 virtual std::pair<OUString, bool> GetURL(SwRootFrame const*const pLayout) const override;
258 virtual bool IsFullPara() const override;
259private:
260 virtual TextAndReading GetText_Impl(SwRootFrame const* pLayout) const override;
261
263 sal_uInt16 m_nLevel;
264 sal_Int32 nStartIndex;
265 sal_Int32 nEndIndex;
267};
268
269struct SwTOXTable final : public SwTOXSortTabBase
270{
271 SwTOXTable( const SwContentNode& rNd );
272
273 void SetLevel(sal_uInt16 nSet){nLevel = nSet;}
274
275 virtual sal_uInt16 GetLevel() const override;
276
277 virtual std::pair<OUString, bool> GetURL(SwRootFrame const*const pLayout) const override;
278
279private:
280 virtual TextAndReading GetText_Impl(SwRootFrame const* pLayout) const override;
281
282 sal_uInt16 nLevel;
283};
284
286struct SwTOXAuthority final : public SwTOXSortTabBase
287{
288private:
290 virtual void FillText(SwTextNode& rNd, const SwContentIndex& rInsPos,
291 sal_uInt16 nAuthField, SwRootFrame const* pLayout) const override;
292 virtual TextAndReading GetText_Impl(SwRootFrame const* pLayout) const override;
293
294public:
295 SwTOXAuthority( const SwContentNode& rNd, SwFormatField& rField, const SwTOXInternational& rIntl );
296
298
299 virtual bool equivalent( const SwTOXSortTabBase& ) override;
300 virtual bool sort_lt( const SwTOXSortTabBase& ) override;
301 virtual sal_uInt16 GetLevel() const override;
302 OUString GetText(sal_uInt16 nAuthField, const SwRootFrame* pLayout) const;
303
305 static OUString GetSourceURL(const OUString& rText);
306};
307
308#endif // INCLUDED_SW_SOURCE_CORE_INC_TXMSRT_HXX
309
310/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Marks a character position inside a document model content node (SwContentNode)
The root element of a Writer document layout.
Definition: rootfrm.hxx:85
OUString ToUpper(const OUString &rStr, sal_Int32 nPos) const
Definition: txmsrt.cxx:104
bool IsNumeric(const OUString &rStr) const
Definition: txmsrt.cxx:109
OUString GetIndexKey(const TextAndReading &rTaR, const css::lang::Locale &rLcl) const
Definition: txmsrt.cxx:123
std::optional< CharClass > m_oCharClass
Definition: txmsrt.hxx:77
LanguageType m_eLang
Definition: txmsrt.hxx:78
std::unique_ptr< IndexEntrySupplierWrapper > m_pIndexWrapper
Definition: txmsrt.hxx:76
bool IsLess(const TextAndReading &rTaR1, const css::lang::Locale &rLocale1, const TextAndReading &rTaR2, const css::lang::Locale &rLocale2) const
Definition: txmsrt.hxx:103
SwTOIOptions m_nOptions
Definition: txmsrt.hxx:80
sal_Int32 Compare(const TextAndReading &rTaR1, const css::lang::Locale &rLocale1, const TextAndReading &rTaR2, const css::lang::Locale &rLocale2) const
Definition: txmsrt.cxx:114
OUString GetFollowingText(bool bMorePages) const
Definition: txmsrt.cxx:129
SwTOXInternational(LanguageType nLang, SwTOIOptions nOptions, OUString aSortAlgorithm)
Definition: txmsrt.cxx:58
bool IsEqual(const TextAndReading &rTaR1, const css::lang::Locale &rLocale1, const TextAndReading &rTaR2, const css::lang::Locale &rLocale2) const
Definition: txmsrt.hxx:95
OUString m_sSortAlgorithm
Definition: txmsrt.hxx:79
SwTextNode is a paragraph in the document model.
Definition: ndtxt.hxx:112
sal_Int64 n
static LanguageType nLang
Definition: srtdlg.cxx:51
Represents one row in the bibliography table.
Definition: txmsrt.hxx:287
SwFormatField & m_rField
Definition: txmsrt.hxx:289
virtual bool equivalent(const SwTOXSortTabBase &) override
Definition: txmsrt.cxx:918
SwFormatField & GetFieldFormat()
Definition: txmsrt.hxx:297
virtual void FillText(SwTextNode &rNd, const SwContentIndex &rInsPos, sal_uInt16 nAuthField, SwRootFrame const *pLayout) const override
Definition: txmsrt.cxx:876
virtual TextAndReading GetText_Impl(SwRootFrame const *pLayout) const override
Definition: txmsrt.cxx:820
virtual bool sort_lt(const SwTOXSortTabBase &) override
Definition: txmsrt.cxx:958
SwTOXAuthority(const SwContentNode &rNd, SwFormatField &rField, const SwTOXInternational &rIntl)
Definition: txmsrt.cxx:790
virtual sal_uInt16 GetLevel() const override
Definition: txmsrt.cxx:799
static OUString GetSourceURL(const OUString &rText)
Gets the URL of the underlying SwAuthEntry, ignoring its page number.
Definition: txmsrt.cxx:851
For sorting by position.
Definition: txmsrt.hxx:232
virtual void FillText(SwTextNode &rNd, const SwContentIndex &rInsPos, sal_uInt16 nAuthField, SwRootFrame const *pLayout) const override
Definition: txmsrt.cxx:508
SwTOXContent(const SwTextNode &, const SwTextTOXMark *, const SwTOXInternational &rIntl)
Definition: txmsrt.cxx:479
virtual sal_uInt16 GetLevel() const override
Definition: txmsrt.cxx:526
virtual TextAndReading GetText_Impl(SwRootFrame const *pLayout) const override
Definition: txmsrt.cxx:487
virtual TextAndReading GetText_Impl(SwRootFrame const *pLayout) const override
Definition: txmsrt.cxx:473
SwTOXCustom(TextAndReading aKey, sal_uInt16 nLevel, const SwTOXInternational &rIntl, const css::lang::Locale &rLocale)
Definition: txmsrt.cxx:445
sal_uInt16 nLev
Definition: txmsrt.hxx:225
virtual bool equivalent(const SwTOXSortTabBase &) override
Definition: txmsrt.cxx:454
virtual sal_uInt16 GetLevel() const override
Definition: txmsrt.cxx:468
TextAndReading m_aKey
Definition: txmsrt.hxx:224
virtual bool sort_lt(const SwTOXSortTabBase &) override
Definition: txmsrt.cxx:461
For sorting by text.
Definition: txmsrt.hxx:194
virtual bool equivalent(const SwTOXSortTabBase &) override
Definition: txmsrt.cxx:316
SwTOXIndex(const SwTextNode &, const SwTextTOXMark *, SwTOIOptions nOptions, sal_uInt8 nKeyLevel, const SwTOXInternational &rIntl, const css::lang::Locale &rLocale)
Definition: txmsrt.cxx:302
virtual TextAndReading GetText_Impl(SwRootFrame const *pLayout) const override
Definition: txmsrt.cxx:362
virtual sal_uInt16 GetLevel() const override
Definition: txmsrt.cxx:428
virtual bool sort_lt(const SwTOXSortTabBase &) override
Definition: txmsrt.cxx:338
sal_uInt8 nKeyLevel
Definition: txmsrt.hxx:208
virtual void FillText(SwTextNode &rNd, const SwContentIndex &rInsPos, sal_uInt16 nAuthField, SwRootFrame const *pLayout) const override
Definition: txmsrt.cxx:398
void SetEndIndex(sal_Int32 nSet)
Definition: txmsrt.hxx:251
SwTOXPara(SwContentNode &, SwTOXElement, sal_uInt16 nLevel=FORM_ALPHA_DELIMITER, OUString sSeqName=OUString())
Definition: txmsrt.cxx:534
sal_Int32 nStartIndex
Definition: txmsrt.hxx:264
sal_uInt16 m_nLevel
Definition: txmsrt.hxx:263
virtual std::pair< OUString, bool > GetURL(SwRootFrame const *const pLayout) const override
Definition: txmsrt.cxx:677
void SetStartIndex(sal_Int32 nSet)
Definition: txmsrt.hxx:250
OUString m_sSequenceName
Definition: txmsrt.hxx:266
virtual TextAndReading GetText_Impl(SwRootFrame const *pLayout) const override
Definition: txmsrt.cxx:556
virtual void FillText(SwTextNode &rNd, const SwContentIndex &rInsPos, sal_uInt16 nAuthField, SwRootFrame const *pLayout) const override
Definition: txmsrt.cxx:611
SwTOXElement eType
Definition: txmsrt.hxx:262
virtual bool IsFullPara() const override
Definition: txmsrt.cxx:731
sal_Int32 nEndIndex
Definition: txmsrt.hxx:265
virtual sal_uInt16 GetLevel() const override
Definition: txmsrt.cxx:663
Class for sorting directories.
Definition: txmsrt.hxx:124
virtual sal_uInt16 GetLevel() const =0
SwTOXSortTabBase(TOXSortType nType, const SwContentNode *pTOXSrc, const SwTextTOXMark *pTextMark, const SwTOXInternational *pIntl, const css::lang::Locale *pLocale=nullptr)
Definition: txmsrt.cxx:135
std::vector< SwTOXSource > aTOXSources
Definition: txmsrt.hxx:128
static SwTOIOptions GetOptions()
Definition: txmsrt.hxx:146
const css::lang::Locale & GetLocale() const
Definition: txmsrt.hxx:185
virtual std::pair< OUString, bool > GetURL(SwRootFrame const *const pLayout) const
Definition: txmsrt.cxx:189
virtual void FillText(SwTextNode &rNd, const SwContentIndex &rInsPos, sal_uInt16 nAuthField, SwRootFrame const *pLayout) const
Definition: txmsrt.cxx:221
static SwTOIOptions nOpt
Definition: txmsrt.hxx:136
virtual bool sort_lt(const SwTOXSortTabBase &)
Definition: txmsrt.cxx:253
virtual ~SwTOXSortTabBase()
Definition: txmsrt.hxx:143
virtual TextAndReading GetText_Impl(SwRootFrame const *pLayout) const =0
sal_Int32 nCntPos
Definition: txmsrt.hxx:134
css::lang::Locale aLocale
Definition: txmsrt.hxx:129
TextAndReading const & GetText() const
Definition: txmsrt.hxx:179
TextAndReading m_aSort
Definition: txmsrt.hxx:165
virtual bool IsFullPara() const
Definition: txmsrt.cxx:216
sal_uInt16 GetType() const
Definition: txmsrt.hxx:145
const SwTextTOXMark * pTextMark
Definition: txmsrt.hxx:131
sal_uInt16 nType
Definition: txmsrt.hxx:135
virtual bool equivalent(const SwTOXSortTabBase &)
Definition: txmsrt.cxx:227
const SwTextNode * pTOXNd
Definition: txmsrt.hxx:130
void InitText(SwRootFrame const *const pLayout)
Definition: txmsrt.hxx:170
const SwTOXInternational * pTOXIntl
Definition: txmsrt.hxx:132
bool operator==(const SwTOXSortTabBase &) const =delete
bool operator<(const SwTOXSortTabBase &) const =delete
SwNodeOffset nPos
Definition: txmsrt.hxx:133
SwTOXSource(const SwContentNode *pNode, sal_Int32 n, bool bMain)
Definition: txmsrt.hxx:55
bool bMainEntry
Definition: txmsrt.hxx:53
const SwContentNode * pNd
Definition: txmsrt.hxx:51
sal_Int32 nPos
Definition: txmsrt.hxx:52
virtual TextAndReading GetText_Impl(SwRootFrame const *pLayout) const override
Definition: txmsrt.cxx:751
virtual std::pair< OUString, bool > GetURL(SwRootFrame const *const pLayout) const override
Definition: txmsrt.cxx:773
sal_uInt16 nLevel
Definition: txmsrt.hxx:282
void SetLevel(sal_uInt16 nSet)
Definition: txmsrt.hxx:273
virtual sal_uInt16 GetLevel() const override
Definition: txmsrt.cxx:768
SwTOXTable(const SwContentNode &rNd)
Definition: txmsrt.cxx:745
OUString sReading
Definition: txmsrt.hxx:64
TextAndReading(OUString aText, OUString aReading)
Definition: txmsrt.hxx:68
OUString sText
Definition: txmsrt.hxx:63
SwTOXElement
Definition: tox.hxx:366
SwTOIOptions
Definition: tox.hxx:387
#define FORM_ALPHA_DELIMITER
Definition: tox.hxx:207
TOXSortType
Definition: txmsrt.hxx:40
@ TOX_SORT_CUSTOM
Definition: txmsrt.hxx:42
@ TOX_SORT_AUTHORITY
Definition: txmsrt.hxx:46
@ TOX_SORT_PARA
Definition: txmsrt.hxx:44
@ TOX_SORT_INDEX
Definition: txmsrt.hxx:41
@ TOX_SORT_TABLE
Definition: txmsrt.hxx:45
@ TOX_SORT_CONTENT
Definition: txmsrt.hxx:43
unsigned char sal_uInt8