LibreOffice Module sw (master) 1
dbfld.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_DBFLD_HXX
20#define INCLUDED_SW_INC_DBFLD_HXX
21
22#include "swdllapi.h"
23#include "fldbas.hxx"
24#include "swdbdata.hxx"
25
26class SwDoc;
27
28// Database field.
30{
32 OUString m_sName;
33 OUString m_sColumn;
35
36public:
37
38 SwDBFieldType(SwDoc* pDocPtr, const OUString& rColumnName, SwDBData aDBData);
39 virtual ~SwDBFieldType() override;
40
41 virtual OUString GetName() const override;
42 virtual std::unique_ptr<SwFieldType> Copy() const override;
43
44 void AddRef() { m_nRefCnt++; }
45 void ReleaseRef();
46
47 const OUString& GetColumnName() const {return m_sColumn;}
48 const SwDBData& GetDBData() const {return m_aDBData;}
49
50 virtual void QueryValue( css::uno::Any& rVal, sal_uInt16 nWhich ) const override;
51 virtual void PutValue( const css::uno::Any& rVal, sal_uInt16 nWhich ) override;
52 virtual void UpdateFields() override {};
53};
54
55// Classes derived from SwFields. They overlay the expand-function.
56// Content is formatted according to the format (if available).
58{
59 OUString m_aContent;
60 OUString m_sFieldCode;
61 sal_uInt16 m_nSubType;
63 bool m_bValidValue : 1;
65
66 virtual OUString ExpandImpl(SwRootFrame const* pLayout) const override;
67 virtual std::unique_ptr<SwField> Copy() const override;
68
69public:
70 SwDBField(SwDBFieldType*, sal_uInt32 nFormat = 0);
71 virtual ~SwDBField() override;
72
73 virtual SwFieldType* ChgTyp( SwFieldType* ) override;
74
76 inline void SetExpansion(const OUString& rStr);
77
78 virtual sal_uInt16 GetSubType() const override;
79 virtual void SetSubType(sal_uInt16 nType) override;
80
81 virtual OUString GetFieldName() const override;
82
84 void ChgValue( double d, bool bVal );
85
87 void Evaluate();
88
90 void InitContent();
91 void InitContent(const OUString& rExpansion);
92
93 inline void ChgBodyTextFlag( bool bIsInBody );
94
95 bool IsInitialized() const { return m_bInitialized; }
96 void ClearInitialized() { m_bInitialized = false; }
97 void SetInitialized() { m_bInitialized = true; }
98
100 virtual OUString GetPar1() const override;
101
103 void SetFieldCode(const OUString& rStr) { m_sFieldCode = rStr; }
104
106 const SwDBData& GetDBData() const { return static_cast<SwDBFieldType*>(GetTyp())->GetDBData(); }
107 virtual bool QueryValue( css::uno::Any& rVal, sal_uInt16 nWhich ) const override;
108 virtual bool PutValue( const css::uno::Any& rVal, sal_uInt16 nWhich ) override;
109
110 static bool FormatValue( SvNumberFormatter const * pDocFormatter, OUString const &aString, sal_uInt32 nFormat,
111 double &aNumber, sal_Int32 nColumnType, SwDBField *pField = nullptr );
112};
113
114inline void SwDBField::SetExpansion(const OUString& rStr)
115 { m_aContent = rStr; }
116
118inline void SwDBField::ChgBodyTextFlag( bool bIsInBody )
119 { m_bIsInBodyText = bIsInBody; }
120
121// Base class for all other database fields.
123{
125 sal_uInt16 m_nSubType;
126
127protected:
128 const SwDBData& GetDBData() const {return m_aDBData;}
129 SwDBData& GetDBData() {return m_aDBData;}
130
131 SwDBNameInfField(SwFieldType* pTyp, SwDBData aDBData, sal_uInt32 nFormat = 0);
132
133public:
135 const SwDBData& GetRealDBData() const { return m_aDBData; }
136 SwDBData& GetRealDBData() { return m_aDBData; }
137
138 SwDBData GetDBData(SwDoc* pDoc);
139 void SetDBData(const SwDBData& rDBData);
140
141 virtual OUString GetFieldName() const override;
142
143 virtual bool QueryValue( css::uno::Any& rVal, sal_uInt16 nWhich ) const override;
144 virtual bool PutValue( const css::uno::Any& rVal, sal_uInt16 nWhich ) override;
145 virtual sal_uInt16 GetSubType() const override;
146 virtual void SetSubType(sal_uInt16 nType) override;
147};
148
149// Database field next record.
151{
152public:
154
155 virtual std::unique_ptr<SwFieldType> Copy() const override;
156};
157
158// Next data record with condition.
160{
161 OUString m_aCond;
163
164public:
166 OUString aCond, const SwDBData& rDBData);
167
168 virtual OUString ExpandImpl(SwRootFrame const* pLayout) const override;
169 virtual std::unique_ptr<SwField> Copy() const override;
170
171 void Evaluate(const SwDoc&);
172 inline void SetCondValid(bool bCond);
173 inline bool IsCondValid() const;
174
175 // Condition
176 virtual OUString GetPar1() const override;
177 virtual void SetPar1(const OUString& rStr) override;
178 virtual bool QueryValue( css::uno::Any& rVal, sal_uInt16 nWhich ) const override;
179 virtual bool PutValue( const css::uno::Any& rVal, sal_uInt16 nWhich ) override;
180};
181
183 { return m_bCondValid; }
184
185inline void SwDBNextSetField::SetCondValid(bool bCond)
186 { m_bCondValid = bCond; }
187
188// Database field next record.
190{
191public:
193
194 virtual std::unique_ptr<SwFieldType> Copy() const override;
195};
196
197// Data record with number xxx.
198// Number is in nFormat (bit of a misuse!)
200{
201 OUString m_aCond;
202 OUString m_aPar2;
204
205public:
206 SwDBNumSetField(SwDBNumSetFieldType*, OUString aCond, OUString aDBNum, const SwDBData& rDBData);
207
208 virtual OUString ExpandImpl(SwRootFrame const* pLayout) const override;
209 virtual std::unique_ptr<SwField> Copy() const override;
210
211 inline bool IsCondValid() const;
212 inline void SetCondValid(bool bCond);
213 void Evaluate(const SwDoc&);
214
215 // Condition
216 virtual OUString GetPar1() const override;
217 virtual void SetPar1(const OUString& rStr) override;
218
219 // Number of data record.
220 virtual OUString GetPar2() const override;
221 virtual void SetPar2(const OUString& rStr) override;
222
223 // Number of data record is in nFormat!!
224 virtual bool QueryValue( css::uno::Any& rVal, sal_uInt16 nWhich ) const override;
225 virtual bool PutValue( const css::uno::Any& rVal, sal_uInt16 nWhich ) override;
226};
227
229 { return m_bCondValid; }
230
231inline void SwDBNumSetField::SetCondValid(bool bCond)
232 { m_bCondValid = bCond; }
233
234// Database name.
235class SwDBNameFieldType final : public SwFieldType
236{
238public:
240
241 OUString Expand() const;
242 virtual std::unique_ptr<SwFieldType> Copy() const override;
243};
244
245// Database field.
246class SwDBNameField final : public SwDBNameInfField
247{
248public:
249 SwDBNameField(SwDBNameFieldType*, const SwDBData& rDBData);
250
251 virtual OUString ExpandImpl(SwRootFrame const* pLayout) const override;
252 virtual std::unique_ptr<SwField> Copy() const override;
253 virtual bool QueryValue( css::uno::Any& rVal, sal_uInt16 nWhich ) const override;
254 virtual bool PutValue( const css::uno::Any& rVal, sal_uInt16 nWhich ) override;
255};
256
257// Number of data record.
259{
260public:
262
263 virtual std::unique_ptr<SwFieldType> Copy() const override;
264};
265
266// Database field.
268{
270public:
271 SwDBSetNumberField(SwDBSetNumberFieldType*, const SwDBData& rDBData, sal_uInt32 nFormat = 0);
272
273 virtual OUString ExpandImpl(SwRootFrame const* pLayout) const override;
274 virtual std::unique_ptr<SwField> Copy() const override;
275 void Evaluate(const SwDoc&);
276
277 inline tools::Long GetSetNumber() const;
278 inline void SetSetNumber(tools::Long nNum);
279 virtual bool QueryValue( css::uno::Any& rVal, sal_uInt16 nWhich ) const override;
280 virtual bool PutValue( const css::uno::Any& rVal, sal_uInt16 nWhich ) override;
281};
282
284 { return m_nNumber; }
285
287 { m_nNumber = nNum; }
288
289#endif // INCLUDED_SW_INC_DBFLD_HXX
290
291/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
const OUString & GetColumnName() const
Definition: dbfld.hxx:47
tools::Long m_nRefCnt
Definition: dbfld.hxx:34
void AddRef()
Definition: dbfld.hxx:44
const SwDBData & GetDBData() const
Definition: dbfld.hxx:48
OUString m_sName
only used in GetName() !
Definition: dbfld.hxx:32
virtual void UpdateFields() override
Definition: dbfld.hxx:52
OUString m_sColumn
Definition: dbfld.hxx:33
SwDBData m_aDBData
Definition: dbfld.hxx:31
void SetFieldCode(const OUString &rStr)
access to the command string
Definition: dbfld.hxx:103
bool m_bValidValue
Definition: dbfld.hxx:63
bool m_bInitialized
Definition: dbfld.hxx:64
void SetInitialized()
Definition: dbfld.hxx:97
OUString m_sFieldCode
contains Word's field code
Definition: dbfld.hxx:60
void ChgBodyTextFlag(bool bIsInBody)
set from UpdateExpFields (the Node-Position is known there)
Definition: dbfld.hxx:118
bool IsInitialized() const
Definition: dbfld.hxx:95
bool m_bIsInBodyText
Definition: dbfld.hxx:62
void SetExpansion(const OUString &rStr)
Current text.
Definition: dbfld.hxx:114
sal_uInt16 m_nSubType
Definition: dbfld.hxx:61
void ClearInitialized()
Definition: dbfld.hxx:96
OUString m_aContent
Definition: dbfld.hxx:59
const SwDBData & GetDBData() const
DBName.
Definition: dbfld.hxx:106
SwDBNameFieldType(SwDoc *)
Definition: dbfld.cxx:736
SwDoc * m_pDoc
Definition: dbfld.hxx:237
OUString Expand() const
Definition: dbfld.cxx:742
virtual std::unique_ptr< SwFieldType > Copy() const override
Definition: dbfld.cxx:748
virtual bool QueryValue(css::uno::Any &rVal, sal_uInt16 nWhich) const override
Definition: dbfld.cxx:775
virtual bool PutValue(const css::uno::Any &rVal, sal_uInt16 nWhich) override
Definition: dbfld.cxx:780
SwDBNameField(SwDBNameFieldType *, const SwDBData &rDBData)
Definition: dbfld.cxx:755
virtual OUString ExpandImpl(SwRootFrame const *pLayout) const override
Definition: dbfld.cxx:759
virtual std::unique_ptr< SwField > Copy() const override
Definition: dbfld.cxx:766
SwDBData & GetRealDBData()
Definition: dbfld.hxx:136
const SwDBData & GetDBData() const
Definition: dbfld.hxx:128
sal_uInt16 m_nSubType
Definition: dbfld.hxx:125
SwDBData m_aDBData
Definition: dbfld.hxx:124
const SwDBData & GetRealDBData() const
DBName.
Definition: dbfld.hxx:135
SwDBData & GetDBData()
Definition: dbfld.hxx:129
OUString m_aCond
Definition: dbfld.hxx:161
bool m_bCondValid
Definition: dbfld.hxx:162
void SetCondValid(bool bCond)
Definition: dbfld.hxx:185
bool IsCondValid() const
Definition: dbfld.hxx:182
virtual std::unique_ptr< SwFieldType > Copy() const override
Definition: dbfld.cxx:633
bool m_bCondValid
Definition: dbfld.hxx:203
bool IsCondValid() const
Definition: dbfld.hxx:228
void Evaluate(const SwDoc &)
Definition: dbfld.cxx:662
virtual void SetPar2(const OUString &rStr) override
set condition
Definition: dbfld.cxx:693
virtual OUString GetPar2() const override
get condition
Definition: dbfld.cxx:687
virtual std::unique_ptr< SwField > Copy() const override
Definition: dbfld.cxx:653
virtual OUString ExpandImpl(SwRootFrame const *pLayout) const override
Definition: dbfld.cxx:648
virtual bool PutValue(const css::uno::Any &rVal, sal_uInt16 nWhich) override
Definition: dbfld.cxx:715
OUString m_aPar2
Definition: dbfld.hxx:202
OUString m_aCond
Definition: dbfld.hxx:201
SwDBNumSetField(SwDBNumSetFieldType *, OUString aCond, OUString aDBNum, const SwDBData &rDBData)
Definition: dbfld.cxx:638
void SetCondValid(bool bCond)
Definition: dbfld.hxx:231
virtual bool QueryValue(css::uno::Any &rVal, sal_uInt16 nWhich) const override
Definition: dbfld.cxx:698
virtual OUString GetPar1() const override
get LogDBName
Definition: dbfld.cxx:675
virtual void SetPar1(const OUString &rStr) override
set LogDBName
Definition: dbfld.cxx:681
void SetSetNumber(tools::Long nNum)
Definition: dbfld.hxx:286
tools::Long m_nNumber
Definition: dbfld.hxx:269
tools::Long GetSetNumber() const
Definition: dbfld.hxx:283
Definition: doc.hxx:197
Instances of SwFields and those derived from it occur 0 to n times.
Definition: fldbas.hxx:247
virtual OUString GetName() const
Only in derived classes.
Definition: fldbas.cxx:139
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
Base class of all fields.
Definition: fldbas.hxx:296
The root element of a Writer document layout.
Definition: rootfrm.hxx:85
Fields containing values that have to be formatted via number formatter.
Definition: fldbas.hxx:419
long Long
#define SW_DLLPUBLIC
Definition: swdllapi.h:28