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 
28 class CharClass;
29 class SwContentNode;
30 class SwTextNode;
31 class SwTextTOXMark;
32 class SwIndex;
33 class SwFormatField;
34 class SwRootFrame;
36 
38 {
45 };
46 
48 {
50  sal_Int32 nPos;
51  bool bMainEntry;
52 
53  SwTOXSource( const SwContentNode* pNode, sal_Int32 n, bool bMain )
54  : pNd(pNode), nPos(n), bMainEntry(bMain)
55  {
56  }
57 };
58 
60 {
61  OUString sText;
62  OUString sReading;
63 
65 
66  TextAndReading(const OUString& rText, const OUString& rReading)
67  : sText(rText)
68  , sReading(rReading)
69  {}
70 };
71 
73 {
74  std::unique_ptr<IndexEntrySupplierWrapper> m_pIndexWrapper;
75  std::unique_ptr<CharClass> m_pCharClass;
77  OUString m_sSortAlgorithm;
79 
80  void Init();
81 
82 public:
84  const OUString& rSortAlgorithm );
87 
88  sal_Int32 Compare( const TextAndReading& rTaR1,
89  const css::lang::Locale& rLocale1,
90  const TextAndReading& rTaR2,
91  const css::lang::Locale& rLocale2 ) const;
92 
93  bool IsEqual( const TextAndReading& rTaR1,
94  const css::lang::Locale& rLocale1,
95  const TextAndReading& rTaR2,
96  const css::lang::Locale& rLocale2 ) const
97  {
98  return 0 == Compare( rTaR1, rLocale1, rTaR2, rLocale2 );
99  }
100 
101  bool IsLess( const TextAndReading& rTaR1,
102  const css::lang::Locale& rLocale1,
103  const TextAndReading& rTaR2,
104  const css::lang::Locale& rLocale2 ) const
105  {
106  return -1 == Compare( rTaR1, rLocale1, rTaR2, rLocale2 );
107  }
108 
109  OUString GetIndexKey( const TextAndReading& rTaR,
110  const css::lang::Locale& rLcl ) const;
111 
112  OUString GetFollowingText( bool bMorePages ) const;
113 
114  OUString ToUpper( const OUString& rStr, sal_Int32 nPos ) const;
115  inline bool IsNumeric( const OUString& rStr ) const;
116 };
117 
122 {
123  bool operator==(const SwTOXSortTabBase&) const = delete;
124  bool operator<(const SwTOXSortTabBase&) const = delete;
125 
126  std::vector<SwTOXSource> aTOXSources;
127  css::lang::Locale aLocale;
132  sal_Int32 nCntPos;
133  sal_uInt16 nType;
135 
137  const SwContentNode* pTOXSrc,
138  const SwTextTOXMark* pTextMark,
139  const SwTOXInternational* pIntl,
140  const css::lang::Locale* pLocale = nullptr );
141  virtual ~SwTOXSortTabBase() {}
142 
143  sal_uInt16 GetType() const { return nType; }
144  static SwTOIOptions GetOptions() { return nOpt; }
145 
146  virtual void FillText(SwTextNode& rNd, const SwIndex& rInsPos,
147  sal_uInt16 nAuthField, SwRootFrame const* pLayout) const;
148  virtual sal_uInt16 GetLevel() const = 0;
149  virtual bool equivalent( const SwTOXSortTabBase& );
150  virtual bool sort_lt( const SwTOXSortTabBase& );
151 
152  virtual std::pair<OUString, bool> GetURL(SwRootFrame const*const pLayout) const;
153 
154  virtual bool IsFullPara() const;
155 
156  // must be called
157  inline void InitText(SwRootFrame const*const pLayout);
158  inline TextAndReading const & GetText() const;
159  inline const css::lang::Locale& GetLocale() const;
160 
161 private:
164 
165  virtual TextAndReading GetText_Impl(SwRootFrame const* pLayout) const = 0;
166 };
167 
168 inline void SwTOXSortTabBase::InitText(SwRootFrame const*const pLayout)
169 {
170  // 'this' is 'SwTOXSortTabBase const*', so the virtual
171  // mechanism will call the derived class' GetText_Impl
172  assert(!m_bValidText);
173  m_aSort = GetText_Impl(pLayout);
174  m_bValidText = true;
175 }
176 
178 {
179  assert(m_bValidText);
180  return m_aSort;
181 }
182 
183 inline const css::lang::Locale& SwTOXSortTabBase::GetLocale() const
184 {
185  return aLocale;
186 }
187 
191 struct SwTOXIndex final : public SwTOXSortTabBase
192 {
194  const SwTOXInternational& rIntl,
195  const css::lang::Locale& rLocale );
196 
197  virtual void FillText(SwTextNode& rNd, const SwIndex& rInsPos,
198  sal_uInt16 nAuthField, SwRootFrame const* pLayout) const override;
199  virtual sal_uInt16 GetLevel() const override;
200  virtual bool equivalent( const SwTOXSortTabBase& ) override;
201  virtual bool sort_lt( const SwTOXSortTabBase& ) override;
202 
203 private:
204  virtual TextAndReading GetText_Impl(SwRootFrame const* pLayout) const override;
205 
207 };
208 
209 struct SwTOXCustom final : public SwTOXSortTabBase
210 {
211  SwTOXCustom( const TextAndReading& rKey, sal_uInt16 nLevel,
212  const SwTOXInternational& rIntl,
213  const css::lang::Locale& rLocale );
214 
215  virtual sal_uInt16 GetLevel() const override;
216  virtual bool equivalent( const SwTOXSortTabBase& ) override;
217  virtual bool sort_lt( const SwTOXSortTabBase& ) override;
218 
219 private:
220  virtual TextAndReading GetText_Impl(SwRootFrame const* pLayout) const override;
221 
223  sal_uInt16 nLev;
224 };
225 
229 struct SwTOXContent final : public SwTOXSortTabBase
230 {
231  SwTOXContent( const SwTextNode&, const SwTextTOXMark*,
232  const SwTOXInternational& rIntl );
233 
234  virtual void FillText(SwTextNode& rNd, const SwIndex& rInsPos,
235  sal_uInt16 nAuthField, SwRootFrame const* pLayout) const override;
236  virtual sal_uInt16 GetLevel() const override;
237 private:
238  virtual TextAndReading GetText_Impl(SwRootFrame const* pLayout) const override;
239 
240 };
241 
242 struct SwTOXPara final : public SwTOXSortTabBase
243 {
245  sal_uInt16 nLevel = FORM_ALPHA_DELIMITER,
246  const OUString& sSeqName = OUString());
247 
248  void SetStartIndex(sal_Int32 nSet) { nStartIndex = nSet; }
249  void SetEndIndex(sal_Int32 nSet) { nEndIndex = nSet; }
250 
251  virtual void FillText(SwTextNode& rNd, const SwIndex& rInsPos,
252  sal_uInt16 nAuthField, SwRootFrame const* pLayout) const override;
253  virtual sal_uInt16 GetLevel() const override;
254 
255  virtual std::pair<OUString, bool> GetURL(SwRootFrame const*const pLayout) const override;
256  virtual bool IsFullPara() const override;
257 private:
258  virtual TextAndReading GetText_Impl(SwRootFrame const* pLayout) const override;
259 
261  sal_uInt16 m_nLevel;
262  sal_Int32 nStartIndex;
263  sal_Int32 nEndIndex;
264  OUString m_sSequenceName;
265 };
266 
267 struct SwTOXTable final : public SwTOXSortTabBase
268 {
269  SwTOXTable( const SwContentNode& rNd );
270 
271  void SetLevel(sal_uInt16 nSet){nLevel = nSet;}
272 
273  virtual sal_uInt16 GetLevel() const override;
274 
275  virtual std::pair<OUString, bool> GetURL(SwRootFrame const*const pLayout) const override;
276 
277 private:
278  virtual TextAndReading GetText_Impl(SwRootFrame const* pLayout) const override;
279 
280  sal_uInt16 nLevel;
281 };
282 
284 struct SwTOXAuthority final : public SwTOXSortTabBase
285 {
286 private:
288  virtual void FillText(SwTextNode& rNd, const SwIndex& rInsPos,
289  sal_uInt16 nAuthField, SwRootFrame const* pLayout) const override;
290  virtual TextAndReading GetText_Impl(SwRootFrame const* pLayout) const override;
291 
292 public:
293  SwTOXAuthority( const SwContentNode& rNd, SwFormatField& rField, const SwTOXInternational& rIntl );
294 
296 
297  virtual bool equivalent( const SwTOXSortTabBase& ) override;
298  virtual bool sort_lt( const SwTOXSortTabBase& ) override;
299  virtual sal_uInt16 GetLevel() const override;
300  OUString GetText(sal_uInt16 nAuthField, const SwRootFrame* pLayout) const;
301 
303  static OUString GetSourceURL(const OUString& rText);
304 };
305 
306 #endif // INCLUDED_SW_SOURCE_CORE_INC_TXMSRT_HXX
307 
308 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
virtual sal_uInt16 GetLevel() const override
Definition: txmsrt.cxx:467
static SwTOIOptions nOpt
Definition: txmsrt.hxx:134
sal_uInt16 m_nLevel
Definition: txmsrt.hxx:261
const css::lang::Locale & GetLocale() const
Definition: txmsrt.hxx:183
OUString GetIndexKey(const TextAndReading &rTaR, const css::lang::Locale &rLcl) const
Definition: txmsrt.cxx:122
SwTOXElement eType
Definition: txmsrt.hxx:260
virtual sal_uInt16 GetLevel() const override
Definition: txmsrt.cxx:427
virtual TextAndReading GetText_Impl(SwRootFrame const *pLayout) const override
Definition: txmsrt.cxx:486
SwTOIOptions
Definition: tox.hxx:384
OUString sReading
Definition: txmsrt.hxx:62
virtual std::pair< OUString, bool > GetURL(SwRootFrame const *const pLayout) const override
Definition: txmsrt.cxx:676
SwTOXSource(const SwContentNode *pNode, sal_Int32 n, bool bMain)
Definition: txmsrt.hxx:53
sal_uInt16 GetType() const
Definition: txmsrt.hxx:143
virtual sal_uInt16 GetLevel() const =0
std::unique_ptr< IndexEntrySupplierWrapper > m_pIndexWrapper
Definition: txmsrt.hxx:74
sal_Int32 nStartIndex
Definition: txmsrt.hxx:262
virtual bool sort_lt(const SwTOXSortTabBase &) override
Definition: txmsrt.cxx:337
SwTOXIndex(const SwTextNode &, const SwTextTOXMark *, SwTOIOptions nOptions, sal_uInt8 nKeyLevel, const SwTOXInternational &rIntl, const css::lang::Locale &rLocale)
Definition: txmsrt.cxx:301
LanguageType m_eLang
Definition: txmsrt.hxx:76
sal_Int32 nPos
Definition: txmsrt.hxx:50
virtual bool equivalent(const SwTOXSortTabBase &) override
Definition: txmsrt.cxx:315
virtual void FillText(SwTextNode &rNd, const SwIndex &rInsPos, sal_uInt16 nAuthField, SwRootFrame const *pLayout) const override
Definition: txmsrt.cxx:875
static OUString GetSourceURL(const OUString &rText)
Gets the URL of the underlying SwAuthEntry, ignoring its page number.
Definition: txmsrt.cxx:850
virtual TextAndReading GetText_Impl(SwRootFrame const *pLayout) const override
Definition: txmsrt.cxx:472
The root element of a Writer document layout.
Definition: rootfrm.hxx:81
OUString GetFollowingText(bool bMorePages) const
Definition: txmsrt.cxx:128
sal_uInt16 nLevel
Definition: txmsrt.hxx:280
virtual sal_uInt16 GetLevel() const override
Definition: txmsrt.cxx:525
For sorting by position.
Definition: txmsrt.hxx:229
static LanguageType nLang
Definition: srtdlg.cxx:51
SwTOXAuthority(const SwContentNode &rNd, SwFormatField &rField, const SwTOXInternational &rIntl)
Definition: txmsrt.cxx:789
virtual bool IsFullPara() const
Definition: txmsrt.cxx:215
virtual ~SwTOXSortTabBase()
Definition: txmsrt.hxx:141
virtual sal_uInt16 GetLevel() const override
Definition: txmsrt.cxx:767
sal_uInt8 nKeyLevel
Definition: txmsrt.hxx:206
sal_Int32 nEndIndex
Definition: txmsrt.hxx:263
virtual void FillText(SwTextNode &rNd, const SwIndex &rInsPos, sal_uInt16 nAuthField, SwRootFrame const *pLayout) const override
Definition: txmsrt.cxx:507
TOXSortType
Definition: txmsrt.hxx:37
virtual bool equivalent(const SwTOXSortTabBase &)
Definition: txmsrt.cxx:226
bool IsNumeric(const OUString &rStr) const
Definition: txmsrt.cxx:108
bool IsEqual(const TextAndReading &rTaR1, const css::lang::Locale &rLocale1, const TextAndReading &rTaR2, const css::lang::Locale &rLocale2) const
Definition: txmsrt.hxx:93
virtual bool equivalent(const SwTOXSortTabBase &) override
Definition: txmsrt.cxx:453
virtual bool equivalent(const SwTOXSortTabBase &) override
Definition: txmsrt.cxx:917
const SwTextNode * pTOXNd
Definition: txmsrt.hxx:128
virtual TextAndReading GetText_Impl(SwRootFrame const *pLayout) const override
Definition: txmsrt.cxx:819
TextAndReading m_aSort
Definition: txmsrt.hxx:163
OUString ToUpper(const OUString &rStr, sal_Int32 nPos) const
Definition: txmsrt.cxx:103
For sorting by text.
Definition: txmsrt.hxx:191
virtual TextAndReading GetText_Impl(SwRootFrame const *pLayout) const override
Definition: txmsrt.cxx:555
sal_Int32 nCntPos
Definition: txmsrt.hxx:132
OUString m_sSortAlgorithm
Definition: txmsrt.hxx:77
SwTOXInternational(LanguageType nLang, SwTOIOptions nOptions, const OUString &rSortAlgorithm)
Definition: txmsrt.cxx:57
SwTOXElement
Definition: tox.hxx:363
bool operator<(const SwTOXSortTabBase &) const =delete
void SetEndIndex(sal_Int32 nSet)
Definition: txmsrt.hxx:249
virtual TextAndReading GetText_Impl(SwRootFrame const *pLayout) const override
Definition: txmsrt.cxx:750
const SwContentNode * pNd
Definition: txmsrt.hxx:49
Marks a character position inside a document model node.
Definition: index.hxx:33
SwTOXTable(const SwContentNode &rNd)
Definition: txmsrt.cxx:744
const SwTOXInternational * pTOXIntl
Definition: txmsrt.hxx:130
virtual void FillText(SwTextNode &rNd, const SwIndex &rInsPos, sal_uInt16 nAuthField, SwRootFrame const *pLayout) const override
Definition: txmsrt.cxx:610
virtual std::pair< OUString, bool > GetURL(SwRootFrame const *const pLayout) const
Definition: txmsrt.cxx:188
const SwTextTOXMark * pTextMark
Definition: txmsrt.hxx:129
sal_uInt16 nLev
Definition: txmsrt.hxx:223
void SetStartIndex(sal_Int32 nSet)
Definition: txmsrt.hxx:248
virtual bool sort_lt(const SwTOXSortTabBase &) override
Definition: txmsrt.cxx:460
virtual TextAndReading GetText_Impl(SwRootFrame const *pLayout) const override
Definition: txmsrt.cxx:361
virtual sal_uInt16 GetLevel() const override
Definition: txmsrt.cxx:798
SwTOIOptions m_nOptions
Definition: txmsrt.hxx:78
SwTOXPara(SwContentNode &, SwTOXElement, sal_uInt16 nLevel=FORM_ALPHA_DELIMITER, const OUString &sSeqName=OUString())
Definition: txmsrt.cxx:533
SwTextNode is a paragraph in the document model.
Definition: ndtxt.hxx:79
OUString sText
Definition: txmsrt.hxx:61
SwTOXCustom(const TextAndReading &rKey, sal_uInt16 nLevel, const SwTOXInternational &rIntl, const css::lang::Locale &rLocale)
Definition: txmsrt.cxx:444
TextAndReading m_aKey
Definition: txmsrt.hxx:222
bool bMainEntry
Definition: txmsrt.hxx:51
TextAndReading(const OUString &rText, const OUString &rReading)
Definition: txmsrt.hxx:66
SwNodeOffset nPos
Definition: txmsrt.hxx:131
SwFormatField & GetFieldFormat()
Definition: txmsrt.hxx:295
bool IsLess(const TextAndReading &rTaR1, const css::lang::Locale &rLocale1, const TextAndReading &rTaR2, const css::lang::Locale &rLocale2) const
Definition: txmsrt.hxx:101
unsigned char sal_uInt8
css::lang::Locale aLocale
Definition: txmsrt.hxx:127
virtual std::pair< OUString, bool > GetURL(SwRootFrame const *const pLayout) const override
Definition: txmsrt.cxx:772
#define FORM_ALPHA_DELIMITER
Definition: tox.hxx:205
virtual bool IsFullPara() const override
Definition: txmsrt.cxx:730
OUString m_sSequenceName
Definition: txmsrt.hxx:264
virtual sal_uInt16 GetLevel() const override
Definition: txmsrt.cxx:662
static SwTOIOptions GetOptions()
Definition: txmsrt.hxx:144
SwFormatField & m_rField
Definition: txmsrt.hxx:287
virtual void FillText(SwTextNode &rNd, const SwIndex &rInsPos, sal_uInt16 nAuthField, SwRootFrame const *pLayout) const
Definition: txmsrt.cxx:220
sal_uInt16 nType
Definition: txmsrt.hxx:133
bool operator==(const SwTOXSortTabBase &) const =delete
std::unique_ptr< CharClass > m_pCharClass
Definition: txmsrt.hxx:75
TextAndReading const & GetText() const
Definition: txmsrt.hxx:177
void InitText(SwRootFrame const *const pLayout)
Definition: txmsrt.hxx:168
virtual bool sort_lt(const SwTOXSortTabBase &)
Definition: txmsrt.cxx:252
Class for sorting directories.
Definition: txmsrt.hxx:121
SwTOXContent(const SwTextNode &, const SwTextTOXMark *, const SwTOXInternational &rIntl)
Definition: txmsrt.cxx:478
std::vector< SwTOXSource > aTOXSources
Definition: txmsrt.hxx:126
void SetLevel(sal_uInt16 nSet)
Definition: txmsrt.hxx:271
sal_Int32 Compare(const TextAndReading &rTaR1, const css::lang::Locale &rLocale1, const TextAndReading &rTaR2, const css::lang::Locale &rLocale2) const
Definition: txmsrt.cxx:113
virtual bool sort_lt(const SwTOXSortTabBase &) override
Definition: txmsrt.cxx:957
virtual void FillText(SwTextNode &rNd, const SwIndex &rInsPos, sal_uInt16 nAuthField, SwRootFrame const *pLayout) const override
Definition: txmsrt.cxx:397
Represents one row in the bibliography table.
Definition: txmsrt.hxx:284
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:134