android: Update app-specific/MIME type icons
[LibreOffice.git] / sw / inc / dbfld.hxx
blob1ecbf4dfeeb0815b67271ecf5f2026fdd3109d61
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
19 #ifndef INCLUDED_SW_INC_DBFLD_HXX
20 #define INCLUDED_SW_INC_DBFLD_HXX
22 #include "swdllapi.h"
23 #include "fldbas.hxx"
24 #include "swdbdata.hxx"
26 class SwDoc;
28 // Database field.
29 class SW_DLLPUBLIC SwDBFieldType final : public SwValueFieldType
31 SwDBData m_aDBData;
32 OUString m_sName; ///< only used in ::GetName() !
33 OUString m_sColumn;
34 tools::Long m_nRefCnt;
36 public:
38 SwDBFieldType(SwDoc* pDocPtr, const OUString& rColumnName, SwDBData aDBData);
39 virtual ~SwDBFieldType() override;
41 virtual OUString GetName() const override;
42 virtual std::unique_ptr<SwFieldType> Copy() const override;
44 void AddRef() { m_nRefCnt++; }
45 void ReleaseRef();
47 const OUString& GetColumnName() const {return m_sColumn;}
48 const SwDBData& GetDBData() const {return m_aDBData;}
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 {};
55 // Classes derived from SwFields. They overlay the expand-function.
56 // Content is formatted according to the format (if available).
57 class SW_DLLPUBLIC SwDBField final : public SwValueField
59 OUString m_aContent;
60 OUString m_sFieldCode; ///< contains Word's field code
61 sal_uInt16 m_nSubType;
62 bool m_bIsInBodyText : 1;
63 bool m_bValidValue : 1;
64 bool m_bInitialized : 1;
66 virtual OUString ExpandImpl(SwRootFrame const* pLayout) const override;
67 virtual std::unique_ptr<SwField> Copy() const override;
69 public:
70 SwDBField(SwDBFieldType*, sal_uInt32 nFormat = 0);
71 virtual ~SwDBField() override;
73 virtual SwFieldType* ChgTyp( SwFieldType* ) override;
75 /// Current text.
76 inline void SetExpansion(const OUString& rStr);
78 virtual sal_uInt16 GetSubType() const override;
79 virtual void SetSubType(sal_uInt16 nType) override;
81 virtual OUString GetFieldName() const override;
83 /// For calculations in expressions.
84 void ChgValue( double d, bool bVal );
86 /// Get the evaluation via DBManager string.
87 void Evaluate();
89 /// Evaluation for header and footer.
90 void InitContent();
91 void InitContent(const OUString& rExpansion);
93 inline void ChgBodyTextFlag( bool bIsInBody );
95 bool IsInitialized() const { return m_bInitialized; }
96 void ClearInitialized() { m_bInitialized = false; }
97 void SetInitialized() { m_bInitialized = true; }
99 /// Get name.
100 virtual OUString GetPar1() const override;
102 /// access to the command string
103 void SetFieldCode(const OUString& rStr) { m_sFieldCode = rStr; }
105 /// DBName
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;
110 static bool FormatValue( SvNumberFormatter const * pDocFormatter, OUString const &aString, sal_uInt32 nFormat,
111 double &aNumber, sal_Int32 nColumnType, SwDBField *pField = nullptr );
114 inline void SwDBField::SetExpansion(const OUString& rStr)
115 { m_aContent = rStr; }
117 /// set from UpdateExpFields (the Node-Position is known there)
118 inline void SwDBField::ChgBodyTextFlag( bool bIsInBody )
119 { m_bIsInBodyText = bIsInBody; }
121 // Base class for all other database fields.
122 class SW_DLLPUBLIC SwDBNameInfField : public SwField
124 SwDBData m_aDBData;
125 sal_uInt16 m_nSubType;
127 protected:
128 const SwDBData& GetDBData() const {return m_aDBData;}
129 SwDBData& GetDBData() {return m_aDBData;}
131 SwDBNameInfField(SwFieldType* pTyp, SwDBData aDBData, sal_uInt32 nFormat = 0);
133 public:
134 /// DBName
135 const SwDBData& GetRealDBData() const { return m_aDBData; }
136 SwDBData& GetRealDBData() { return m_aDBData; }
138 SwDBData GetDBData(SwDoc* pDoc);
139 void SetDBData(const SwDBData& rDBData);
141 virtual OUString GetFieldName() const override;
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;
149 // Database field next record.
150 class SW_DLLPUBLIC SwDBNextSetFieldType final : public SwFieldType
152 public:
153 SwDBNextSetFieldType();
155 virtual std::unique_ptr<SwFieldType> Copy() const override;
158 // Next data record with condition.
159 class SW_DLLPUBLIC SwDBNextSetField final : public SwDBNameInfField
161 OUString m_aCond;
162 bool m_bCondValid;
164 public:
165 SwDBNextSetField( SwDBNextSetFieldType*,
166 OUString aCond, const SwDBData& rDBData);
168 virtual OUString ExpandImpl(SwRootFrame const* pLayout) const override;
169 virtual std::unique_ptr<SwField> Copy() const override;
171 void Evaluate(const SwDoc&);
172 inline void SetCondValid(bool bCond);
173 inline bool IsCondValid() const;
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;
182 inline bool SwDBNextSetField::IsCondValid() const
183 { return m_bCondValid; }
185 inline void SwDBNextSetField::SetCondValid(bool bCond)
186 { m_bCondValid = bCond; }
188 // Database field next record.
189 class SwDBNumSetFieldType final : public SwFieldType
191 public:
192 SwDBNumSetFieldType();
194 virtual std::unique_ptr<SwFieldType> Copy() const override;
197 // Data record with number xxx.
198 // Number is in nFormat (bit of a misuse!)
199 class SwDBNumSetField final : public SwDBNameInfField
201 OUString m_aCond;
202 OUString m_aPar2;
203 bool m_bCondValid;
205 public:
206 SwDBNumSetField(SwDBNumSetFieldType*, OUString aCond, OUString aDBNum, const SwDBData& rDBData);
208 virtual OUString ExpandImpl(SwRootFrame const* pLayout) const override;
209 virtual std::unique_ptr<SwField> Copy() const override;
211 inline bool IsCondValid() const;
212 inline void SetCondValid(bool bCond);
213 void Evaluate(const SwDoc&);
215 // Condition
216 virtual OUString GetPar1() const override;
217 virtual void SetPar1(const OUString& rStr) override;
219 // Number of data record.
220 virtual OUString GetPar2() const override;
221 virtual void SetPar2(const OUString& rStr) override;
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;
228 inline bool SwDBNumSetField::IsCondValid() const
229 { return m_bCondValid; }
231 inline void SwDBNumSetField::SetCondValid(bool bCond)
232 { m_bCondValid = bCond; }
234 // Database name.
235 class SwDBNameFieldType final : public SwFieldType
237 SwDoc *m_pDoc;
238 public:
239 SwDBNameFieldType(SwDoc*);
241 OUString Expand() const;
242 virtual std::unique_ptr<SwFieldType> Copy() const override;
245 // Database field.
246 class SwDBNameField final : public SwDBNameInfField
248 public:
249 SwDBNameField(SwDBNameFieldType*, const SwDBData& rDBData);
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;
257 // Number of data record.
258 class SW_DLLPUBLIC SwDBSetNumberFieldType final : public SwFieldType
260 public:
261 SwDBSetNumberFieldType();
263 virtual std::unique_ptr<SwFieldType> Copy() const override;
266 // Database field.
267 class SW_DLLPUBLIC SwDBSetNumberField final : public SwDBNameInfField
269 tools::Long m_nNumber;
270 public:
271 SwDBSetNumberField(SwDBSetNumberFieldType*, const SwDBData& rDBData, sal_uInt32 nFormat = 0);
273 virtual OUString ExpandImpl(SwRootFrame const* pLayout) const override;
274 virtual std::unique_ptr<SwField> Copy() const override;
275 void Evaluate(const SwDoc&);
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;
283 inline tools::Long SwDBSetNumberField::GetSetNumber() const
284 { return m_nNumber; }
286 inline void SwDBSetNumberField::SetSetNumber(tools::Long nNum)
287 { m_nNumber = nNum; }
289 #endif // INCLUDED_SW_INC_DBFLD_HXX
291 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */