LibreOffice Module sw (master) 1
authfld.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_INC_AUTHFLD_HXX
20#define INCLUDED_SW_INC_AUTHFLD_HXX
21
22#include <sal/config.h>
23
24#include "swdllapi.h"
25#include "fldbas.hxx"
26#include "toxe.hxx"
27#include <rtl/ref.hxx>
28#include <sal/log.hxx>
30
31#include <memory>
32#include <vector>
33
35class SwTextAttr;
36class SwForm;
37
39{
42public:
43 SwAuthEntry() = default;
44 SwAuthEntry( const SwAuthEntry& rCopy );
45 bool operator==(const SwAuthEntry& rComp) const;
46
47 inline OUString const & GetAuthorField(ToxAuthorityField ePos) const;
48 inline void SetAuthorField(ToxAuthorityField ePos,
49 const OUString& rField);
50 void dumpAsXml(xmlTextWriterPtr pWriter) const;
51};
52
54{
59 bSortAscending(true){}
60};
61
62typedef std::vector<SwTOXSortKey> SortKeyArr;
63typedef std::vector<rtl::Reference<SwAuthEntry>> SwAuthDataArr;
64
66{
69 std::vector<SwAuthEntry*> m_SequArr;
70 std::vector<SwAuthEntry*> m_SequArrRLHidden;
78
79 virtual void SwClientNotify(const SwModify&, const SfxHint&) override;
80
81public:
83 virtual ~SwAuthorityFieldType() override;
84
85 virtual std::unique_ptr<SwFieldType> Copy() const override;
86
87 virtual void QueryValue( css::uno::Any& rVal, sal_uInt16 nWhichId ) const override;
88 virtual void PutValue( const css::uno::Any& rVal, sal_uInt16 nWhichId ) override;
89
90 void SetDoc(SwDoc* pNewDoc) { m_pDoc = pNewDoc; }
91 SwDoc* GetDoc(){ return m_pDoc; }
92 void RemoveField(const SwAuthEntry* nHandle);
93 SwAuthEntry* AddField(std::u16string_view rFieldContents);
95 {
96 m_SequArr.clear();
97 m_SequArrRLHidden.clear();
98 }
99
100 void GetAllEntryIdentifiers( std::vector<OUString>& rToFill ) const;
101 SwAuthEntry* GetEntryByIdentifier(std::u16string_view rIdentifier) const;
102
103 bool ChangeEntryContent(const SwAuthEntry* pNewEntry);
104 // import interface
105 SwAuthEntry* AppendField(const SwAuthEntry& rInsert);
106
107 sal_uInt16 GetSequencePos(const SwAuthEntry* pAuthEntry, SwRootFrame const* pLayout);
108 std::unique_ptr<SwTOXInternational> CreateTOXInternational() const;
109
110 bool IsSequence() const {return m_bIsSequence;}
111 void SetSequence(bool bSet)
112 {
113 DelSequenceArray();
114 m_bIsSequence = bSet;
115 }
116
118 {
119 m_cPrefix = cPre;
120 m_cSuffix = cSuf;
121 }
122 sal_Unicode GetPrefix() const { return m_cPrefix;}
123 sal_Unicode GetSuffix() const { return m_cSuffix;}
124
125 bool IsSortByDocument() const {return m_bSortByDocument;}
126 void SetSortByDocument(bool bSet)
127 {
128 DelSequenceArray();
129 m_bSortByDocument = bSet;
130 }
131
132 sal_uInt16 GetSortKeyCount() const ;
133 const SwTOXSortKey* GetSortKey(sal_uInt16 nIdx) const ;
134 void SetSortKeys(sal_uInt16 nKeyCount, SwTOXSortKey const nKeys[]);
135
136 //initui.cxx
137 static OUString const & GetAuthFieldName(ToxAuthorityField eType);
138 static OUString const & GetAuthTypeName(ToxAuthorityType eType);
139
140 LanguageType GetLanguage() const {return m_eLanguage;}
141 void SetLanguage(LanguageType nLang) {m_eLanguage = nLang;}
142
143 const OUString& GetSortAlgorithm() const {return m_sSortAlgorithm;}
144 void SetSortAlgorithm(const OUString& rSet) {m_sSortAlgorithm = rSet;}
145 void dumpAsXml(xmlTextWriterPtr pWriter) const override;
146
147};
148
161{
163 mutable sal_IntPtr m_nTempSequencePos;
164 mutable sal_IntPtr m_nTempSequencePosRLHidden;
165
166 virtual OUString ExpandImpl(SwRootFrame const* pLayout) const override;
167 virtual std::unique_ptr<SwField> Copy() const override;
168
169public:
170 enum TargetType : sal_uInt16
171 {
172 UseDisplayURL = 0,
173 UseTargetURL = 1,
174 None = 2,
175 BibliographyTableRow = 3,
176 // BibliographyTablePage = 4, // TODO: implement
177 };
178
179
181 OUString ConditionalExpandAuthIdentifier(SwRootFrame const* pLayout) const;
182
183 //To handle Citation
184 OUString ExpandCitation(ToxAuthorityField eField, SwRootFrame const* pLayout) const;
185
186 SwAuthorityField(SwAuthorityFieldType* pType, std::u16string_view rFieldContents);
188 virtual ~SwAuthorityField() override;
189
190 const OUString & GetFieldText(ToxAuthorityField eField) const;
191
192 virtual void SetPar1(const OUString& rStr) override;
193 virtual SwFieldType* ChgTyp( SwFieldType* ) override;
194
195 virtual bool QueryValue( css::uno::Any& rVal, sal_uInt16 nWhichId ) const override;
196 virtual bool PutValue( const css::uno::Any& rVal, sal_uInt16 nWhichId ) override;
197
198 SwAuthEntry* GetAuthEntry() const { return m_xAuthEntry.get(); }
199
200 virtual OUString GetDescription() const override;
201
209 OUString GetAuthority(const SwRootFrame *pLayout,
210 const SwForm *pTOX = nullptr) const;
211
216 TargetType GetTargetType() const;
221 OUString GetAbsoluteURL() const;
222
226 OUString GetRelativeURI() const;
227
228 void dumpAsXml(xmlTextWriterPtr pWriter) const override;
229};
230
231inline OUString const & SwAuthEntry::GetAuthorField(ToxAuthorityField ePos) const
232{
233 SAL_WARN_IF(AUTH_FIELD_END <= ePos, "sw", "wrong index");
234 return m_aAuthFields[ePos];
235}
236inline void SwAuthEntry::SetAuthorField(ToxAuthorityField ePos, const OUString& rField)
237{
238 SAL_WARN_IF(AUTH_FIELD_END <= ePos, "sw", "wrong index");
239 if(AUTH_FIELD_END > ePos)
240 m_aAuthFields[ePos] = rField;
241}
242
243#endif
244
245/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
css::chart::ChartAxisLabelPosition ePos
std::vector< SwTOXSortKey > SortKeyArr
Definition: authfld.hxx:62
std::vector< rtl::Reference< SwAuthEntry > > SwAuthDataArr
Definition: authfld.hxx:63
void dumpAsXml(xmlTextWriterPtr pWriter) const
Definition: authfld.cxx:762
void SetAuthorField(ToxAuthorityField ePos, const OUString &rField)
Definition: authfld.hxx:236
OUString const & GetAuthorField(ToxAuthorityField ePos) const
Definition: authfld.hxx:231
OUString m_aAuthFields[AUTH_FIELD_END]
Definition: authfld.hxx:41
bool operator==(const SwAuthEntry &rComp) const
Definition: authfld.cxx:67
SwAuthEntry()=default
std::vector< SwAuthEntry * > m_SequArrRLHidden
hidden redlines
Definition: authfld.hxx:70
bool IsSequence() const
Definition: authfld.hxx:110
SortKeyArr m_SortKeyArr
Definition: authfld.hxx:71
std::vector< SwAuthEntry * > m_SequArr
Definition: authfld.hxx:69
sal_Unicode GetPrefix() const
Definition: authfld.hxx:122
sal_Unicode m_cPrefix
Definition: authfld.hxx:72
void SetSequence(bool bSet)
Definition: authfld.hxx:111
SwAuthDataArr m_DataArr
Definition: authfld.hxx:68
OUString m_sSortAlgorithm
Definition: authfld.hxx:77
sal_Unicode GetSuffix() const
Definition: authfld.hxx:123
bool IsSortByDocument() const
Definition: authfld.hxx:125
void DelSequenceArray()
Definition: authfld.hxx:94
void SetLanguage(LanguageType nLang)
Definition: authfld.hxx:141
void SetSortByDocument(bool bSet)
Definition: authfld.hxx:126
void SetDoc(SwDoc *pNewDoc)
Definition: authfld.hxx:90
LanguageType GetLanguage() const
Definition: authfld.hxx:140
SwDoc * GetDoc()
Definition: authfld.hxx:91
const OUString & GetSortAlgorithm() const
Definition: authfld.hxx:143
void SetPreSuffix(sal_Unicode cPre, sal_Unicode cSuf)
Definition: authfld.hxx:117
LanguageType m_eLanguage
Definition: authfld.hxx:76
void SetSortAlgorithm(const OUString &rSet)
Definition: authfld.hxx:144
sal_Unicode m_cSuffix
Definition: authfld.hxx:73
Represents an inserted bibliography entry, created using Insert -> Table of Contents and Index -> Bib...
Definition: authfld.hxx:161
sal_IntPtr m_nTempSequencePos
Definition: authfld.hxx:163
SwAuthEntry * GetAuthEntry() const
Definition: authfld.hxx:198
sal_IntPtr m_nTempSequencePosRLHidden
hidden redlines
Definition: authfld.hxx:164
rtl::Reference< SwAuthEntry > m_xAuthEntry
Definition: authfld.hxx:162
Definition: doc.hxx:197
Instances of SwFields and those derived from it occur 0 to n times.
Definition: fldbas.hxx:247
virtual void QueryValue(css::uno::Any &rVal, sal_uInt16 nWhich) const
Definition: fldbas.cxx:144
virtual void PutValue(const css::uno::Any &rVal, sal_uInt16 nWhich)
Definition: fldbas.cxx:147
virtual std::unique_ptr< SwFieldType > Copy() const =0
virtual void dumpAsXml(xmlTextWriterPtr pWriter) const
Definition: fldbas.cxx:157
Base class of all fields.
Definition: fldbas.hxx:296
Definition: tox.hxx:314
The root element of a Writer document layout.
Definition: rootfrm.hxx:85
A wrapper around SfxPoolItem to store the start position of (usually) a text portion,...
Definition: txatbase.hxx:44
struct _xmlTextWriter * xmlTextWriterPtr
virtual void GetDescription(OUString &rName) override
#define SAL_WARN_IF(condition, area, stream)
None
eField
static SfxItemSet & rSet
static LanguageType nLang
Definition: srtdlg.cxx:51
bool bSortAscending
Definition: authfld.hxx:56
ToxAuthorityField eField
Definition: authfld.hxx:55
#define SW_DLLPUBLIC
Definition: swdllapi.h:28
ToxAuthorityField
Definition: toxe.hxx:83
@ AUTH_FIELD_END
Definition: toxe.hxx:121
ToxAuthorityType
Definition: toxe.hxx:53
sal_uInt16 sal_Unicode