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 <tox.hxx>
24 
25 #include <com/sun/star/lang/Locale.hpp>
26 
27 class CharClass;
28 class SwContentNode;
29 class SwTextNode;
30 class SwTextTOXMark;
31 class SwIndex;
32 class SwFormatField;
33 class SwRootFrame;
35 
37 {
44 };
45 
47 {
49  sal_Int32 const nPos;
50  bool const bMainEntry;
51 
52  SwTOXSource( const SwContentNode* pNode, sal_Int32 n, bool bMain )
53  : pNd(pNode), nPos(n), bMainEntry(bMain)
54  {
55  }
56 };
57 
59 {
60  OUString sText;
61  OUString sReading;
62 
64 
65  TextAndReading(const OUString& rText, const OUString& rReading)
66  : sText(rText)
67  , sReading(rReading)
68  {}
69 };
70 
72 {
73  std::unique_ptr<IndexEntrySupplierWrapper> m_pIndexWrapper;
74  std::unique_ptr<CharClass> m_pCharClass;
76  OUString m_sSortAlgorithm;
78 
79  void Init();
80 
81 public:
83  const OUString& rSortAlgorithm );
86 
87  sal_Int32 Compare( const TextAndReading& rTaR1,
88  const css::lang::Locale& rLocale1,
89  const TextAndReading& rTaR2,
90  const css::lang::Locale& rLocale2 ) const;
91 
92  bool IsEqual( const TextAndReading& rTaR1,
93  const css::lang::Locale& rLocale1,
94  const TextAndReading& rTaR2,
95  const css::lang::Locale& rLocale2 ) const
96  {
97  return 0 == Compare( rTaR1, rLocale1, rTaR2, rLocale2 );
98  }
99 
100  bool IsLess( const TextAndReading& rTaR1,
101  const css::lang::Locale& rLocale1,
102  const TextAndReading& rTaR2,
103  const css::lang::Locale& rLocale2 ) const
104  {
105  return -1 == Compare( rTaR1, rLocale1, rTaR2, rLocale2 );
106  }
107 
108  OUString GetIndexKey( const TextAndReading& rTaR,
109  const css::lang::Locale& rLcl ) const;
110 
111  OUString GetFollowingText( bool bMorePages ) const;
112 
113  OUString ToUpper( const OUString& rStr, sal_Int32 nPos ) const;
114  inline bool IsNumeric( const OUString& rStr ) const;
115 };
116 
121 {
122  bool operator==(const SwTOXSortTabBase&) = delete;
123  bool operator<(const SwTOXSortTabBase&) = delete;
124 
125  std::vector<SwTOXSource> aTOXSources;
126  css::lang::Locale aLocale;
131  sal_Int32 nCntPos;
132  sal_uInt16 const nType;
134 
136  const SwContentNode* pTOXSrc,
137  const SwTextTOXMark* pTextMark,
138  const SwTOXInternational* pIntl,
139  const css::lang::Locale* pLocale = nullptr );
140  virtual ~SwTOXSortTabBase() {}
141 
142  sal_uInt16 GetType() const { return nType; }
143  static SwTOIOptions GetOptions() { return nOpt; }
144 
145  virtual void FillText(SwTextNode& rNd, const SwIndex& rInsPos,
146  sal_uInt16 nAuthField, SwRootFrame const* pLayout) const;
147  virtual sal_uInt16 GetLevel() const = 0;
148  virtual bool equivalent( const SwTOXSortTabBase& );
149  virtual bool sort_lt( const SwTOXSortTabBase& );
150 
151  virtual OUString GetURL() const;
152 
153  virtual bool IsFullPara() const;
154 
155  // must be called
156  inline void InitText(SwRootFrame const*const pLayout);
157  inline TextAndReading const & GetText() const;
158  inline const css::lang::Locale& GetLocale() const;
159 
160 private:
163 
164  virtual TextAndReading GetText_Impl(SwRootFrame const* pLayout) const = 0;
165 };
166 
167 inline void SwTOXSortTabBase::InitText(SwRootFrame const*const pLayout)
168 {
169  // 'this' is 'SwTOXSortTabBase const*', so the virtual
170  // mechanism will call the derived class' GetText_Impl
171  assert(!m_bValidText);
172  m_aSort = GetText_Impl(pLayout);
173  m_bValidText = true;
174 }
175 
177 {
178  assert(m_bValidText);
179  return m_aSort;
180 }
181 
182 inline const css::lang::Locale& SwTOXSortTabBase::GetLocale() const
183 {
184  return aLocale;
185 }
186 
191 {
193  const SwTOXInternational& rIntl,
194  const css::lang::Locale& rLocale );
195 
196  virtual void FillText(SwTextNode& rNd, const SwIndex& rInsPos,
197  sal_uInt16 nAuthField, SwRootFrame const* pLayout) const override;
198  virtual sal_uInt16 GetLevel() const override;
199  virtual bool equivalent( const SwTOXSortTabBase& ) override;
200  virtual bool sort_lt( const SwTOXSortTabBase& ) override;
201 
202 private:
203  virtual TextAndReading GetText_Impl(SwRootFrame const* pLayout) const override;
204 
206 };
207 
209 {
210  SwTOXCustom( const TextAndReading& rKey, sal_uInt16 nLevel,
211  const SwTOXInternational& rIntl,
212  const css::lang::Locale& rLocale );
213 
214  virtual sal_uInt16 GetLevel() const override;
215  virtual bool equivalent( const SwTOXSortTabBase& ) override;
216  virtual bool sort_lt( const SwTOXSortTabBase& ) override;
217 
218 private:
219  virtual TextAndReading GetText_Impl(SwRootFrame const* pLayout) const override;
220 
222  sal_uInt16 const nLev;
223 };
224 
229 {
230  SwTOXContent( const SwTextNode&, const SwTextTOXMark*,
231  const SwTOXInternational& rIntl );
232 
233  virtual void FillText(SwTextNode& rNd, const SwIndex& rInsPos,
234  sal_uInt16 nAuthField, SwRootFrame const* pLayout) const override;
235  virtual sal_uInt16 GetLevel() const override;
236 private:
237  virtual TextAndReading GetText_Impl(SwRootFrame const* pLayout) const override;
238 
239 };
240 
242 {
244  sal_uInt16 nLevel = FORM_ALPHA_DELIMITER,
245  const OUString& sSeqName = OUString());
246 
247  void SetStartIndex(sal_Int32 nSet) { nStartIndex = nSet; }
248  void SetEndIndex(sal_Int32 nSet) { nEndIndex = nSet; }
249 
250  virtual void FillText(SwTextNode& rNd, const SwIndex& rInsPos,
251  sal_uInt16 nAuthField, SwRootFrame const* pLayout) const override;
252  virtual sal_uInt16 GetLevel() const override;
253 
254  virtual OUString GetURL() const override;
255  virtual bool IsFullPara() const override;
256 private:
257  virtual TextAndReading GetText_Impl(SwRootFrame const* pLayout) const override;
258 
260  sal_uInt16 const m_nLevel;
261  sal_Int32 nStartIndex;
262  sal_Int32 nEndIndex;
263  OUString const m_sSequenceName;
264 };
265 
267 {
268  SwTOXTable( const SwContentNode& rNd );
269 
270  void SetLevel(sal_uInt16 nSet){nLevel = nSet;}
271 
272  virtual sal_uInt16 GetLevel() const override;
273 
274  virtual OUString GetURL() const override;
275 private:
276  virtual TextAndReading GetText_Impl(SwRootFrame const* pLayout) const override;
277 
278  sal_uInt16 nLevel;
279 };
280 
282 {
283 private:
285  virtual void FillText(SwTextNode& rNd, const SwIndex& rInsPos,
286  sal_uInt16 nAuthField, SwRootFrame const* pLayout) const override;
287  virtual TextAndReading GetText_Impl(SwRootFrame const* pLayout) const override;
288 
289 public:
290  SwTOXAuthority( const SwContentNode& rNd, SwFormatField& rField, const SwTOXInternational& rIntl );
291 
293 
294  virtual bool equivalent( const SwTOXSortTabBase& ) override;
295  virtual bool sort_lt( const SwTOXSortTabBase& ) override;
296  virtual sal_uInt16 GetLevel() const override;
297 };
298 
299 #endif // INCLUDED_SW_SOURCE_CORE_INC_TXMSRT_HXX
300 
301 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
virtual sal_uInt16 GetLevel() const override
Definition: txmsrt.cxx:446
static SwTOIOptions nOpt
Definition: txmsrt.hxx:133
const css::lang::Locale & GetLocale() const
Definition: txmsrt.hxx:182
OUString GetIndexKey(const TextAndReading &rTaR, const css::lang::Locale &rLcl) const
Definition: txmsrt.cxx:121
virtual sal_uInt16 GetLevel() const override
Definition: txmsrt.cxx:406
virtual TextAndReading GetText_Impl(SwRootFrame const *pLayout) const override
Definition: txmsrt.cxx:465
SwTOIOptions
Definition: tox.hxx:350
OUString sReading
Definition: txmsrt.hxx:61
sal_uInt16 const m_nLevel
Definition: txmsrt.hxx:260
virtual OUString GetURL() const
Definition: txmsrt.cxx:187
SwTOXSource(const SwContentNode *pNode, sal_Int32 n, bool bMain)
Definition: txmsrt.hxx:52
virtual OUString GetURL() const override
Definition: txmsrt.cxx:751
sal_uInt16 GetType() const
Definition: txmsrt.hxx:142
sal_uIntPtr sal_uLong
virtual sal_uInt16 GetLevel() const =0
std::unique_ptr< IndexEntrySupplierWrapper > m_pIndexWrapper
Definition: txmsrt.hxx:73
sal_Int32 nStartIndex
Definition: txmsrt.hxx:261
virtual bool sort_lt(const SwTOXSortTabBase &) override
Definition: txmsrt.cxx:314
SwTOXIndex(const SwTextNode &, const SwTextTOXMark *, SwTOIOptions nOptions, sal_uInt8 nKeyLevel, const SwTOXInternational &rIntl, const css::lang::Locale &rLocale)
Definition: txmsrt.cxx:278
virtual bool equivalent(const SwTOXSortTabBase &) override
Definition: txmsrt.cxx:292
virtual void FillText(SwTextNode &rNd, const SwIndex &rInsPos, sal_uInt16 nAuthField, SwRootFrame const *pLayout) const override
Definition: txmsrt.cxx:803
virtual TextAndReading GetText_Impl(SwRootFrame const *pLayout) const override
Definition: txmsrt.cxx:451
The root element of a Writer document layout.
Definition: rootfrm.hxx:79
OUString GetFollowingText(bool bMorePages) const
Definition: txmsrt.cxx:127
sal_uInt16 nLevel
Definition: txmsrt.hxx:278
virtual sal_uInt16 GetLevel() const override
Definition: txmsrt.cxx:504
For sorting by position.
Definition: txmsrt.hxx:228
static LanguageType nLang
Definition: srtdlg.cxx:60
SwTOXAuthority(const SwContentNode &rNd, SwFormatField &rField, const SwTOXInternational &rIntl)
Definition: txmsrt.cxx:768
virtual bool IsFullPara() const
Definition: txmsrt.cxx:192
virtual ~SwTOXSortTabBase()
Definition: txmsrt.hxx:140
virtual sal_uInt16 GetLevel() const override
Definition: txmsrt.cxx:746
sal_Int32 nEndIndex
Definition: txmsrt.hxx:262
virtual void FillText(SwTextNode &rNd, const SwIndex &rInsPos, sal_uInt16 nAuthField, SwRootFrame const *pLayout) const override
Definition: txmsrt.cxx:486
TOXSortType
Definition: txmsrt.hxx:36
virtual bool equivalent(const SwTOXSortTabBase &)
Definition: txmsrt.cxx:203
bool IsNumeric(const OUString &rStr) const
Definition: txmsrt.cxx:107
bool IsEqual(const TextAndReading &rTaR1, const css::lang::Locale &rLocale1, const TextAndReading &rTaR2, const css::lang::Locale &rLocale2) const
Definition: txmsrt.hxx:92
virtual bool equivalent(const SwTOXSortTabBase &) override
Definition: txmsrt.cxx:432
virtual bool equivalent(const SwTOXSortTabBase &) override
Definition: txmsrt.cxx:831
const SwTextNode * pTOXNd
Definition: txmsrt.hxx:127
virtual TextAndReading GetText_Impl(SwRootFrame const *pLayout) const override
Definition: txmsrt.cxx:798
TextAndReading m_aSort
Definition: txmsrt.hxx:162
OUString ToUpper(const OUString &rStr, sal_Int32 nPos) const
Definition: txmsrt.cxx:102
For sorting by text.
Definition: txmsrt.hxx:190
virtual TextAndReading GetText_Impl(SwRootFrame const *pLayout) const override
Definition: txmsrt.cxx:534
virtual OUString GetURL() const override
Definition: txmsrt.cxx:655
sal_Int32 nCntPos
Definition: txmsrt.hxx:131
bool const bMainEntry
Definition: txmsrt.hxx:50
OUString m_sSortAlgorithm
Definition: txmsrt.hxx:76
SwTOXInternational(LanguageType nLang, SwTOIOptions nOptions, const OUString &rSortAlgorithm)
Definition: txmsrt.cxx:56
sal_Int32 const nPos
Definition: txmsrt.hxx:49
SwTOXElement
Definition: tox.hxx:328
SwTOXElement const eType
Definition: txmsrt.hxx:259
sal_uInt16 const nType
Definition: txmsrt.hxx:132
void SetEndIndex(sal_Int32 nSet)
Definition: txmsrt.hxx:248
virtual TextAndReading GetText_Impl(SwRootFrame const *pLayout) const override
Definition: txmsrt.cxx:729
OUString const m_sSequenceName
Definition: txmsrt.hxx:263
const SwContentNode * pNd
Definition: txmsrt.hxx:48
Marks a character position inside a document model node.
Definition: index.hxx:37
SwTOXTable(const SwContentNode &rNd)
Definition: txmsrt.cxx:723
const SwTOXInternational * pTOXIntl
Definition: txmsrt.hxx:129
virtual void FillText(SwTextNode &rNd, const SwIndex &rInsPos, sal_uInt16 nAuthField, SwRootFrame const *pLayout) const override
Definition: txmsrt.cxx:589
const SwTextTOXMark * pTextMark
Definition: txmsrt.hxx:128
void SetStartIndex(sal_Int32 nSet)
Definition: txmsrt.hxx:247
virtual bool sort_lt(const SwTOXSortTabBase &) override
Definition: txmsrt.cxx:439
virtual TextAndReading GetText_Impl(SwRootFrame const *pLayout) const override
Definition: txmsrt.cxx:340
sal_uInt8 const nKeyLevel
Definition: txmsrt.hxx:205
sal_uLong nPos
Definition: txmsrt.hxx:130
virtual sal_uInt16 GetLevel() const override
Definition: txmsrt.cxx:777
TextAndReading const m_aKey
Definition: txmsrt.hxx:221
SwTOXPara(SwContentNode &, SwTOXElement, sal_uInt16 nLevel=FORM_ALPHA_DELIMITER, const OUString &sSeqName=OUString())
Definition: txmsrt.cxx:512
SwTextNode is a paragraph in the document model.
Definition: ndtxt.hxx:79
OUString sText
Definition: txmsrt.hxx:60
SwTOXCustom(const TextAndReading &rKey, sal_uInt16 nLevel, const SwTOXInternational &rIntl, const css::lang::Locale &rLocale)
Definition: txmsrt.cxx:423
TextAndReading(const OUString &rText, const OUString &rReading)
Definition: txmsrt.hxx:65
SwFormatField & GetFieldFormat()
Definition: txmsrt.hxx:292
bool IsLess(const TextAndReading &rTaR1, const css::lang::Locale &rLocale1, const TextAndReading &rTaR2, const css::lang::Locale &rLocale2) const
Definition: txmsrt.hxx:100
unsigned char sal_uInt8
css::lang::Locale aLocale
Definition: txmsrt.hxx:126
LanguageType const m_eLang
Definition: txmsrt.hxx:75
SwTOIOptions const m_nOptions
Definition: txmsrt.hxx:77
#define FORM_ALPHA_DELIMITER
Definition: tox.hxx:170
bool operator<(const SwTOXSortTabBase &)=delete
virtual bool IsFullPara() const override
Definition: txmsrt.cxx:709
virtual sal_uInt16 GetLevel() const override
Definition: txmsrt.cxx:641
static SwTOIOptions GetOptions()
Definition: txmsrt.hxx:143
bool operator==(const SwTOXSortTabBase &)=delete
SwFormatField & m_rField
Definition: txmsrt.hxx:284
virtual void FillText(SwTextNode &rNd, const SwIndex &rInsPos, sal_uInt16 nAuthField, SwRootFrame const *pLayout) const
Definition: txmsrt.cxx:197
std::unique_ptr< CharClass > m_pCharClass
Definition: txmsrt.hxx:74
TextAndReading const & GetText() const
Definition: txmsrt.hxx:176
void InitText(SwRootFrame const *const pLayout)
Definition: txmsrt.hxx:167
virtual bool sort_lt(const SwTOXSortTabBase &)
Definition: txmsrt.cxx:229
sal_uInt16 const nLev
Definition: txmsrt.hxx:222
Class for sorting directories.
Definition: txmsrt.hxx:120
SwTOXContent(const SwTextNode &, const SwTextTOXMark *, const SwTOXInternational &rIntl)
Definition: txmsrt.cxx:457
std::vector< SwTOXSource > aTOXSources
Definition: txmsrt.hxx:125
void SetLevel(sal_uInt16 nSet)
Definition: txmsrt.hxx:270
sal_Int32 Compare(const TextAndReading &rTaR1, const css::lang::Locale &rLocale1, const TextAndReading &rTaR2, const css::lang::Locale &rLocale2) const
Definition: txmsrt.cxx:112
virtual bool sort_lt(const SwTOXSortTabBase &) override
Definition: txmsrt.cxx:838
virtual void FillText(SwTextNode &rNd, const SwIndex &rInsPos, sal_uInt16 nAuthField, SwRootFrame const *pLayout) const override
Definition: txmsrt.cxx:376
virtual TextAndReading GetText_Impl(SwRootFrame const *pLayout) const =0
SwTOXSortTabBase(TOXSortType nType, const SwContentNode *pTOXSrc, const SwTextTOXMark *pTextMark, const SwTOXInternational *pIntl, const css::lang::Locale *pLocale=nullptr)
Definition: txmsrt.cxx:133