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 "swdllapi.h"
23#include "fldbas.hxx"
24#include "toxe.hxx"
25#include <rtl/ref.hxx>
26#include <sal/log.hxx>
28
29#include <memory>
30#include <vector>
31
33class SwTextAttr;
34
36{
39public:
40 SwAuthEntry() = default;
41 SwAuthEntry( const SwAuthEntry& rCopy );
42 bool operator==(const SwAuthEntry& rComp) const;
43
44 inline OUString const & GetAuthorField(ToxAuthorityField ePos) const;
45 inline void SetAuthorField(ToxAuthorityField ePos,
46 const OUString& rField);
47 void dumpAsXml(xmlTextWriterPtr pWriter) const;
48};
49
51{
56 bSortAscending(true){}
57};
58
59typedef std::vector<SwTOXSortKey> SortKeyArr;
60typedef std::vector<rtl::Reference<SwAuthEntry>> SwAuthDataArr;
61
63{
66 std::vector<SwAuthEntry*> m_SequArr;
67 std::vector<SwAuthEntry*> m_SequArrRLHidden;
75
76 virtual void SwClientNotify(const SwModify&, const SfxHint&) override;
77
78public:
80 virtual ~SwAuthorityFieldType() override;
81
82 virtual std::unique_ptr<SwFieldType> Copy() const override;
83
84 virtual void QueryValue( css::uno::Any& rVal, sal_uInt16 nWhichId ) const override;
85 virtual void PutValue( const css::uno::Any& rVal, sal_uInt16 nWhichId ) override;
86
87 void SetDoc(SwDoc* pNewDoc) { m_pDoc = pNewDoc; }
88 SwDoc* GetDoc(){ return m_pDoc; }
89 void RemoveField(const SwAuthEntry* nHandle);
90 SwAuthEntry* AddField(std::u16string_view rFieldContents);
92 {
93 m_SequArr.clear();
94 m_SequArrRLHidden.clear();
95 }
96
97 void GetAllEntryIdentifiers( std::vector<OUString>& rToFill ) const;
98 SwAuthEntry* GetEntryByIdentifier(std::u16string_view rIdentifier) const;
99
100 bool ChangeEntryContent(const SwAuthEntry* pNewEntry);
101 // import interface
102 SwAuthEntry* AppendField(const SwAuthEntry& rInsert);
103
104 sal_uInt16 GetSequencePos(const SwAuthEntry* pAuthEntry, SwRootFrame const* pLayout);
105 std::unique_ptr<SwTOXInternational> CreateTOXInternational() const;
106
107 bool IsSequence() const {return m_bIsSequence;}
108 void SetSequence(bool bSet)
109 {
110 DelSequenceArray();
111 m_bIsSequence = bSet;
112 }
113
115 {
116 m_cPrefix = cPre;
117 m_cSuffix = cSuf;
118 }
119 sal_Unicode GetPrefix() const { return m_cPrefix;}
120 sal_Unicode GetSuffix() const { return m_cSuffix;}
121
122 bool IsSortByDocument() const {return m_bSortByDocument;}
123 void SetSortByDocument(bool bSet)
124 {
125 DelSequenceArray();
126 m_bSortByDocument = bSet;
127 }
128
129 sal_uInt16 GetSortKeyCount() const ;
130 const SwTOXSortKey* GetSortKey(sal_uInt16 nIdx) const ;
131 void SetSortKeys(sal_uInt16 nKeyCount, SwTOXSortKey const nKeys[]);
132
133 //initui.cxx
134 static OUString const & GetAuthFieldName(ToxAuthorityField eType);
135 static OUString const & GetAuthTypeName(ToxAuthorityType eType);
136
137 LanguageType GetLanguage() const {return m_eLanguage;}
138 void SetLanguage(LanguageType nLang) {m_eLanguage = nLang;}
139
140 const OUString& GetSortAlgorithm() const {return m_sSortAlgorithm;}
141 void SetSortAlgorithm(const OUString& rSet) {m_sSortAlgorithm = rSet;}
142 void dumpAsXml(xmlTextWriterPtr pWriter) const override;
143
144};
145
155{
157 mutable sal_IntPtr m_nTempSequencePos;
158 mutable sal_IntPtr m_nTempSequencePosRLHidden;
159
160 virtual OUString ExpandImpl(SwRootFrame const* pLayout) const override;
161 virtual std::unique_ptr<SwField> Copy() const override;
162
163public:
165 OUString ConditionalExpandAuthIdentifier(SwRootFrame const* pLayout) const;
166
167 //To handle Citation
168 OUString ExpandCitation(ToxAuthorityField eField, SwRootFrame const* pLayout) const;
169
170 SwAuthorityField(SwAuthorityFieldType* pType, std::u16string_view rFieldContents);
172 virtual ~SwAuthorityField() override;
173
174 const OUString & GetFieldText(ToxAuthorityField eField) const;
175
176 virtual void SetPar1(const OUString& rStr) override;
177 virtual SwFieldType* ChgTyp( SwFieldType* ) override;
178
179 virtual bool QueryValue( css::uno::Any& rVal, sal_uInt16 nWhichId ) const override;
180 virtual bool PutValue( const css::uno::Any& rVal, sal_uInt16 nWhichId ) override;
181
182 SwAuthEntry* GetAuthEntry() const { return m_xAuthEntry.get(); }
183
184 virtual OUString GetDescription() const override;
185
187 OUString GetAuthority(const SwTextAttr* pTextAttr, const SwRootFrame* pLayout) const;
188
189 bool HasURL() const;
190 OUString GetAbsoluteURL() const;
191
192 void dumpAsXml(xmlTextWriterPtr pWriter) const override;
193};
194
195inline OUString const & SwAuthEntry::GetAuthorField(ToxAuthorityField ePos) const
196{
197 SAL_WARN_IF(AUTH_FIELD_END <= ePos, "sw", "wrong index");
198 return m_aAuthFields[ePos];
199}
200inline void SwAuthEntry::SetAuthorField(ToxAuthorityField ePos, const OUString& rField)
201{
202 SAL_WARN_IF(AUTH_FIELD_END <= ePos, "sw", "wrong index");
203 if(AUTH_FIELD_END > ePos)
204 m_aAuthFields[ePos] = rField;
205}
206
207#endif
208
209/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
css::chart::ChartAxisLabelPosition ePos
struct _xmlTextWriter * xmlTextWriterPtr
std::vector< SwTOXSortKey > SortKeyArr
Definition: authfld.hxx:59
std::vector< rtl::Reference< SwAuthEntry > > SwAuthDataArr
Definition: authfld.hxx:60
void dumpAsXml(xmlTextWriterPtr pWriter) const
Definition: authfld.cxx:686
void SetAuthorField(ToxAuthorityField ePos, const OUString &rField)
Definition: authfld.hxx:200
OUString const & GetAuthorField(ToxAuthorityField ePos) const
Definition: authfld.hxx:195
OUString m_aAuthFields[AUTH_FIELD_END]
Definition: authfld.hxx:38
bool operator==(const SwAuthEntry &rComp) const
Definition: authfld.cxx:62
SwAuthEntry()=default
std::vector< SwAuthEntry * > m_SequArrRLHidden
hidden redlines
Definition: authfld.hxx:67
bool IsSequence() const
Definition: authfld.hxx:107
SortKeyArr m_SortKeyArr
Definition: authfld.hxx:68
std::vector< SwAuthEntry * > m_SequArr
Definition: authfld.hxx:66
sal_Unicode GetPrefix() const
Definition: authfld.hxx:119
sal_Unicode m_cPrefix
Definition: authfld.hxx:69
void SetSequence(bool bSet)
Definition: authfld.hxx:108
SwAuthDataArr m_DataArr
Definition: authfld.hxx:65
OUString m_sSortAlgorithm
Definition: authfld.hxx:74
sal_Unicode GetSuffix() const
Definition: authfld.hxx:120
bool IsSortByDocument() const
Definition: authfld.hxx:122
void DelSequenceArray()
Definition: authfld.hxx:91
void SetLanguage(LanguageType nLang)
Definition: authfld.hxx:138
void SetSortByDocument(bool bSet)
Definition: authfld.hxx:123
void SetDoc(SwDoc *pNewDoc)
Definition: authfld.hxx:87
LanguageType GetLanguage() const
Definition: authfld.hxx:137
SwDoc * GetDoc()
Definition: authfld.hxx:88
const OUString & GetSortAlgorithm() const
Definition: authfld.hxx:140
void SetPreSuffix(sal_Unicode cPre, sal_Unicode cSuf)
Definition: authfld.hxx:114
LanguageType m_eLanguage
Definition: authfld.hxx:73
void SetSortAlgorithm(const OUString &rSet)
Definition: authfld.hxx:141
sal_Unicode m_cSuffix
Definition: authfld.hxx:70
invariant for SwAuthorityField is that it is always registered at its SwAuthorityFieldType via AddFie...
Definition: authfld.hxx:155
sal_IntPtr m_nTempSequencePos
Definition: authfld.hxx:157
SwAuthEntry * GetAuthEntry() const
Definition: authfld.hxx:182
sal_IntPtr m_nTempSequencePosRLHidden
hidden redlines
Definition: authfld.hxx:158
rtl::Reference< SwAuthEntry > m_xAuthEntry
Definition: authfld.hxx:156
Definition: doc.hxx:194
Instances of SwFields and those derived from it occur 0 to n times.
Definition: fldbas.hxx:242
virtual void QueryValue(css::uno::Any &rVal, sal_uInt16 nWhich) const
Definition: fldbas.cxx:142
virtual void PutValue(const css::uno::Any &rVal, sal_uInt16 nWhich)
Definition: fldbas.cxx:145
virtual std::unique_ptr< SwFieldType > Copy() const =0
virtual void dumpAsXml(xmlTextWriterPtr pWriter) const
Definition: fldbas.cxx:155
Base class of all fields.
Definition: fldbas.hxx:292
The root element of a Writer document layout.
Definition: rootfrm.hxx:82
A wrapper around SfxPoolItem to store the start position of (usually) a text portion,...
Definition: txatbase.hxx:44
virtual void GetDescription(OUString &rName) override
#define SAL_WARN_IF(condition, area, stream)
eField
static SfxItemSet & rSet
static LanguageType nLang
Definition: srtdlg.cxx:51
bool bSortAscending
Definition: authfld.hxx:53
ToxAuthorityField eField
Definition: authfld.hxx:52
#define SW_DLLPUBLIC
Definition: swdllapi.h:28
ToxAuthorityField
Definition: toxe.hxx:83
@ AUTH_FIELD_END
Definition: toxe.hxx:118
ToxAuthorityType
Definition: toxe.hxx:53
sal_uInt16 sal_Unicode