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>
23#include <nodeoffset.hxx>
24#include <tox.hxx>
25
26#include <com/sun/star/lang/Locale.hpp>
27#include <utility>
28
29class CharClass;
30class SwContentNode;
31class SwTextNode;
32class SwTextTOXMark;
33class SwContentIndex;
34class SwFormatField;
35class SwRootFrame;
37
39{
46};
47
49{
51 sal_Int32 nPos;
53
54 SwTOXSource( const SwContentNode* pNode, sal_Int32 n, bool bMain )
55 : pNd(pNode), nPos(n), bMainEntry(bMain)
56 {
57 }
58};
59
61{
62 OUString sText;
63 OUString sReading;
64
66
67 TextAndReading(OUString aText, OUString aReading)
68 : sText(std::move(aText))
69 , sReading(std::move(aReading))
70 {}
71};
72
74{
75 std::unique_ptr<IndexEntrySupplierWrapper> m_pIndexWrapper;
76 std::unique_ptr<CharClass> m_pCharClass;
80
81 void Init();
82
83public:
85 OUString aSortAlgorithm );
88
89 sal_Int32 Compare( const TextAndReading& rTaR1,
90 const css::lang::Locale& rLocale1,
91 const TextAndReading& rTaR2,
92 const css::lang::Locale& rLocale2 ) const;
93
94 bool IsEqual( const TextAndReading& rTaR1,
95 const css::lang::Locale& rLocale1,
96 const TextAndReading& rTaR2,
97 const css::lang::Locale& rLocale2 ) const
98 {
99 return 0 == Compare( rTaR1, rLocale1, rTaR2, rLocale2 );
100 }
101
102 bool IsLess( const TextAndReading& rTaR1,
103 const css::lang::Locale& rLocale1,
104 const TextAndReading& rTaR2,
105 const css::lang::Locale& rLocale2 ) const
106 {
107 return -1 == Compare( rTaR1, rLocale1, rTaR2, rLocale2 );
108 }
109
110 OUString GetIndexKey( const TextAndReading& rTaR,
111 const css::lang::Locale& rLcl ) const;
112
113 OUString GetFollowingText( bool bMorePages ) const;
114
115 OUString ToUpper( const OUString& rStr, sal_Int32 nPos ) const;
116 bool IsNumeric( const OUString& rStr ) const;
117};
118
123{
124 bool operator==(const SwTOXSortTabBase&) const = delete;
125 bool operator<(const SwTOXSortTabBase&) const = delete;
126
127 std::vector<SwTOXSource> aTOXSources;
128 css::lang::Locale aLocale;
133 sal_Int32 nCntPos;
134 sal_uInt16 nType;
136
138 const SwContentNode* pTOXSrc,
140 const SwTOXInternational* pIntl,
141 const css::lang::Locale* pLocale = nullptr );
142 virtual ~SwTOXSortTabBase() {}
143
144 sal_uInt16 GetType() const { return nType; }
145 static SwTOIOptions GetOptions() { return nOpt; }
146
147 virtual void FillText(SwTextNode& rNd, const SwContentIndex& rInsPos,
148 sal_uInt16 nAuthField, SwRootFrame const* pLayout) const;
149 virtual sal_uInt16 GetLevel() const = 0;
150 virtual bool equivalent( const SwTOXSortTabBase& );
151 virtual bool sort_lt( const SwTOXSortTabBase& );
152
153 virtual std::pair<OUString, bool> GetURL(SwRootFrame const*const pLayout) const;
154
155 virtual bool IsFullPara() const;
156
157 // must be called
158 inline void InitText(SwRootFrame const*const pLayout);
159 inline TextAndReading const & GetText() const;
160 inline const css::lang::Locale& GetLocale() const;
161
162private:
165
166 virtual TextAndReading GetText_Impl(SwRootFrame const* pLayout) const = 0;
167};
168
169inline void SwTOXSortTabBase::InitText(SwRootFrame const*const pLayout)
170{
171 // 'this' is 'SwTOXSortTabBase const*', so the virtual
172 // mechanism will call the derived class' GetText_Impl
173 assert(!m_bValidText);
174 m_aSort = GetText_Impl(pLayout);
175 m_bValidText = true;
176}
177
179{
180 assert(m_bValidText);
181 return m_aSort;
182}
183
184inline const css::lang::Locale& SwTOXSortTabBase::GetLocale() const
185{
186 return aLocale;
187}
188
192struct SwTOXIndex final : public SwTOXSortTabBase
193{
195 const SwTOXInternational& rIntl,
196 const css::lang::Locale& rLocale );
197
198 virtual void FillText(SwTextNode& rNd, const SwContentIndex& rInsPos,
199 sal_uInt16 nAuthField, SwRootFrame const* pLayout) const override;
200 virtual sal_uInt16 GetLevel() const override;
201 virtual bool equivalent( const SwTOXSortTabBase& ) override;
202 virtual bool sort_lt( const SwTOXSortTabBase& ) override;
203
204private:
205 virtual TextAndReading GetText_Impl(SwRootFrame const* pLayout) const override;
206
208};
209
210struct SwTOXCustom final : public SwTOXSortTabBase
211{
212 SwTOXCustom( TextAndReading aKey, sal_uInt16 nLevel,
213 const SwTOXInternational& rIntl,
214 const css::lang::Locale& rLocale );
215
216 virtual sal_uInt16 GetLevel() const override;
217 virtual bool equivalent( const SwTOXSortTabBase& ) override;
218 virtual bool sort_lt( const SwTOXSortTabBase& ) override;
219
220private:
221 virtual TextAndReading GetText_Impl(SwRootFrame const* pLayout) const override;
222
224 sal_uInt16 nLev;
225};
226
230struct SwTOXContent final : public SwTOXSortTabBase
231{
232 SwTOXContent( const SwTextNode&, const SwTextTOXMark*,
233 const SwTOXInternational& rIntl );
234
235 virtual void FillText(SwTextNode& rNd, const SwContentIndex& rInsPos,
236 sal_uInt16 nAuthField, SwRootFrame const* pLayout) const override;
237 virtual sal_uInt16 GetLevel() const override;
238private:
239 virtual TextAndReading GetText_Impl(SwRootFrame const* pLayout) const override;
240
241};
242
243struct SwTOXPara final : public SwTOXSortTabBase
244{
246 sal_uInt16 nLevel = FORM_ALPHA_DELIMITER,
247 OUString sSeqName = OUString());
248
249 void SetStartIndex(sal_Int32 nSet) { nStartIndex = nSet; }
250 void SetEndIndex(sal_Int32 nSet) { nEndIndex = nSet; }
251
252 virtual void FillText(SwTextNode& rNd, const SwContentIndex& rInsPos,
253 sal_uInt16 nAuthField, SwRootFrame const* pLayout) const override;
254 virtual sal_uInt16 GetLevel() const override;
255
256 virtual std::pair<OUString, bool> GetURL(SwRootFrame const*const pLayout) const override;
257 virtual bool IsFullPara() const override;
258private:
259 virtual TextAndReading GetText_Impl(SwRootFrame const* pLayout) const override;
260
262 sal_uInt16 m_nLevel;
263 sal_Int32 nStartIndex;
264 sal_Int32 nEndIndex;
266};
267
268struct SwTOXTable final : public SwTOXSortTabBase
269{
270 SwTOXTable( const SwContentNode& rNd );
271
272 void SetLevel(sal_uInt16 nSet){nLevel = nSet;}
273
274 virtual sal_uInt16 GetLevel() const override;
275
276 virtual std::pair<OUString, bool> GetURL(SwRootFrame const*const pLayout) const override;
277
278private:
279 virtual TextAndReading GetText_Impl(SwRootFrame const* pLayout) const override;
280
281 sal_uInt16 nLevel;
282};
283
285struct SwTOXAuthority final : public SwTOXSortTabBase
286{
287private:
289 virtual void FillText(SwTextNode& rNd, const SwContentIndex& rInsPos,
290 sal_uInt16 nAuthField, SwRootFrame const* pLayout) const override;
291 virtual TextAndReading GetText_Impl(SwRootFrame const* pLayout) const override;
292
293public:
294 SwTOXAuthority( const SwContentNode& rNd, SwFormatField& rField, const SwTOXInternational& rIntl );
295
297
298 virtual bool equivalent( const SwTOXSortTabBase& ) override;
299 virtual bool sort_lt( const SwTOXSortTabBase& ) override;
300 virtual sal_uInt16 GetLevel() const override;
301 OUString GetText(sal_uInt16 nAuthField, const SwRootFrame* pLayout) const;
302
304 static OUString GetSourceURL(const OUString& rText);
305};
306
307#endif // INCLUDED_SW_SOURCE_CORE_INC_TXMSRT_HXX
308
309/* 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:83
std::unique_ptr< CharClass > m_pCharClass
Definition: txmsrt.hxx:76
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
LanguageType m_eLang
Definition: txmsrt.hxx:77
std::unique_ptr< IndexEntrySupplierWrapper > m_pIndexWrapper
Definition: txmsrt.hxx:75
bool IsLess(const TextAndReading &rTaR1, const css::lang::Locale &rLocale1, const TextAndReading &rTaR2, const css::lang::Locale &rLocale2) const
Definition: txmsrt.hxx:102
SwTOIOptions m_nOptions
Definition: txmsrt.hxx:79
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:94
OUString m_sSortAlgorithm
Definition: txmsrt.hxx:78
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:286
SwFormatField & m_rField
Definition: txmsrt.hxx:288
virtual bool equivalent(const SwTOXSortTabBase &) override
Definition: txmsrt.cxx:918
SwFormatField & GetFieldFormat()
Definition: txmsrt.hxx:296
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:231
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:224
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:223
virtual bool sort_lt(const SwTOXSortTabBase &) override
Definition: txmsrt.cxx:461
For sorting by text.
Definition: txmsrt.hxx:193
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:207
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:250
SwTOXPara(SwContentNode &, SwTOXElement, sal_uInt16 nLevel=FORM_ALPHA_DELIMITER, OUString sSeqName=OUString())
Definition: txmsrt.cxx:534
sal_Int32 nStartIndex
Definition: txmsrt.hxx:263
sal_uInt16 m_nLevel
Definition: txmsrt.hxx:262
virtual std::pair< OUString, bool > GetURL(SwRootFrame const *const pLayout) const override
Definition: txmsrt.cxx:677
void SetStartIndex(sal_Int32 nSet)
Definition: txmsrt.hxx:249
OUString m_sSequenceName
Definition: txmsrt.hxx:265
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:261
virtual bool IsFullPara() const override
Definition: txmsrt.cxx:731
sal_Int32 nEndIndex
Definition: txmsrt.hxx:264
virtual sal_uInt16 GetLevel() const override
Definition: txmsrt.cxx:663
Class for sorting directories.
Definition: txmsrt.hxx:123
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:127
static SwTOIOptions GetOptions()
Definition: txmsrt.hxx:145
const css::lang::Locale & GetLocale() const
Definition: txmsrt.hxx:184
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:135
virtual bool sort_lt(const SwTOXSortTabBase &)
Definition: txmsrt.cxx:253
virtual ~SwTOXSortTabBase()
Definition: txmsrt.hxx:142
virtual TextAndReading GetText_Impl(SwRootFrame const *pLayout) const =0
sal_Int32 nCntPos
Definition: txmsrt.hxx:133
css::lang::Locale aLocale
Definition: txmsrt.hxx:128
TextAndReading const & GetText() const
Definition: txmsrt.hxx:178
TextAndReading m_aSort
Definition: txmsrt.hxx:164
virtual bool IsFullPara() const
Definition: txmsrt.cxx:216
sal_uInt16 GetType() const
Definition: txmsrt.hxx:144
const SwTextTOXMark * pTextMark
Definition: txmsrt.hxx:130
sal_uInt16 nType
Definition: txmsrt.hxx:134
virtual bool equivalent(const SwTOXSortTabBase &)
Definition: txmsrt.cxx:227
const SwTextNode * pTOXNd
Definition: txmsrt.hxx:129
void InitText(SwRootFrame const *const pLayout)
Definition: txmsrt.hxx:169
const SwTOXInternational * pTOXIntl
Definition: txmsrt.hxx:131
bool operator==(const SwTOXSortTabBase &) const =delete
bool operator<(const SwTOXSortTabBase &) const =delete
SwNodeOffset nPos
Definition: txmsrt.hxx:132
SwTOXSource(const SwContentNode *pNode, sal_Int32 n, bool bMain)
Definition: txmsrt.hxx:54
bool bMainEntry
Definition: txmsrt.hxx:52
const SwContentNode * pNd
Definition: txmsrt.hxx:50
sal_Int32 nPos
Definition: txmsrt.hxx:51
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:281
void SetLevel(sal_uInt16 nSet)
Definition: txmsrt.hxx:272
virtual sal_uInt16 GetLevel() const override
Definition: txmsrt.cxx:768
SwTOXTable(const SwContentNode &rNd)
Definition: txmsrt.cxx:745
OUString sReading
Definition: txmsrt.hxx:63
TextAndReading(OUString aText, OUString aReading)
Definition: txmsrt.hxx:67
OUString sText
Definition: txmsrt.hxx:62
SwTOXElement
Definition: tox.hxx:366
SwTOIOptions
Definition: tox.hxx:387
#define FORM_ALPHA_DELIMITER
Definition: tox.hxx:207
TOXSortType
Definition: txmsrt.hxx:39
@ TOX_SORT_CUSTOM
Definition: txmsrt.hxx:41
@ TOX_SORT_AUTHORITY
Definition: txmsrt.hxx:45
@ TOX_SORT_PARA
Definition: txmsrt.hxx:43
@ TOX_SORT_INDEX
Definition: txmsrt.hxx:40
@ TOX_SORT_TABLE
Definition: txmsrt.hxx:44
@ TOX_SORT_CONTENT
Definition: txmsrt.hxx:42
unsigned char sal_uInt8