bump product version to 4.1.6.2
[LibreOffice.git] / sw / inc / dbfld.hxx
blobb4f55a9ee3d7df75569684c614453732b0fbbcf2
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 SW_DBFLD_HXX
20 #define SW_DBFLD_HXX
22 #include "swdllapi.h"
23 #include "fldbas.hxx"
24 #include "swdbdata.hxx"
26 class SwDoc;
27 class SwTxtFld;
28 class SwFrm;
30 /*--------------------------------------------------------------------
31 Database field.
32 --------------------------------------------------------------------*/
34 class SW_DLLPUBLIC SwDBFieldType : public SwValueFieldType
36 SwDBData aDBData; //
37 OUString sName; ///< only used in ::GetName() !
38 String sColumn;
39 long nRefCnt;
41 public:
43 SwDBFieldType(SwDoc* pDocPtr, const String& rColumnName, const SwDBData& rDBData);
44 ~SwDBFieldType();
46 virtual const OUString& GetName() const;
47 virtual SwFieldType* Copy() const;
49 inline void AddRef() { nRefCnt++; }
50 void ReleaseRef();
52 const String& GetColumnName() const {return sColumn;}
53 const SwDBData& GetDBData() const {return aDBData;}
55 virtual bool QueryValue( com::sun::star::uno::Any& rVal, sal_uInt16 nWhich ) const;
56 virtual bool PutValue( const com::sun::star::uno::Any& rVal, sal_uInt16 nWhich );
59 /*--------------------------------------------------------------------
60 Classes derived from SwFields. They overlay the expand-function.
61 Content is formated according to the format (if available).
62 --------------------------------------------------------------------*/
64 class SW_DLLPUBLIC SwDBField : public SwValueField
66 OUString aContent;
67 OUString sFieldCode; ///< contains Word's field code
68 sal_uInt16 nSubType;
69 bool bIsInBodyTxt : 1;
70 bool bValidValue : 1;
71 bool bInitialized : 1;
73 virtual String Expand() const;
74 virtual SwField* Copy() const;
76 public:
77 SwDBField(SwDBFieldType*, sal_uLong nFmt = 0);
78 virtual ~SwDBField();
80 virtual SwFieldType* ChgTyp( SwFieldType* );
82 /// Current text.
83 inline void SetExpansion(const String& rStr);
85 virtual sal_uInt16 GetSubType() const;
86 virtual void SetSubType(sal_uInt16 nType);
88 virtual String GetFieldName() const;
90 /// For calculations in expressions.
91 void ChgValue( double d, bool bVal );
93 /// Get the evaluation via DBMgr string.
94 void Evaluate();
96 /// Evaluation for header and footer.
97 void ChangeExpansion( const SwFrm*, const SwTxtFld* );
98 void InitContent();
99 void InitContent(const String& rExpansion);
101 inline void ChgBodyTxtFlag( bool bIsInBody );
103 inline bool IsInitialized() const { return bInitialized; }
104 inline void ClearInitialized() { bInitialized = false; }
105 inline void SetInitialized() { bInitialized = true; }
107 /// Get name.
108 virtual const OUString& GetPar1() const;
110 /// access to the command string
111 const OUString& GetFieldCode() const { return sFieldCode;}
112 void SetFieldCode(const OUString& rStr) { sFieldCode = rStr; }
114 /// DBName
115 inline const SwDBData& GetDBData() const { return ((SwDBFieldType*)GetTyp())->GetDBData(); }
116 virtual bool QueryValue( com::sun::star::uno::Any& rVal, sal_uInt16 nWhich ) const;
117 virtual bool PutValue( const com::sun::star::uno::Any& rVal, sal_uInt16 nWhich );
120 inline void SwDBField::SetExpansion(const String& rStr)
121 { aContent = rStr; }
123 /// set from UpdateExpFlds (the Node-Position is known there)
124 inline void SwDBField::ChgBodyTxtFlag( bool bIsInBody )
125 { bIsInBodyTxt = bIsInBody; }
127 /*--------------------------------------------------------------------
128 Base class for all other database fields.
129 --------------------------------------------------------------------*/
131 class SW_DLLPUBLIC SwDBNameInfField : public SwField
133 SwDBData aDBData;
134 sal_uInt16 nSubType;
136 protected:
137 const SwDBData& GetDBData() const {return aDBData;}
138 SwDBData& GetDBData() {return aDBData;}
140 SwDBNameInfField(SwFieldType* pTyp, const SwDBData& rDBData, sal_uLong nFmt = 0);
142 public:
143 /// DBName
144 inline const SwDBData& GetRealDBData() { return aDBData; }
146 SwDBData GetDBData(SwDoc* pDoc);
147 void SetDBData(const SwDBData& rDBData);
149 virtual String GetFieldName() const;
151 virtual bool QueryValue( com::sun::star::uno::Any& rVal, sal_uInt16 nWhich ) const;
152 virtual bool PutValue( const com::sun::star::uno::Any& rVal, sal_uInt16 nWhich );
153 virtual sal_uInt16 GetSubType() const;
154 virtual void SetSubType(sal_uInt16 nType);
157 /*--------------------------------------------------------------------
158 Database field next record.
159 --------------------------------------------------------------------*/
161 class SW_DLLPUBLIC SwDBNextSetFieldType : public SwFieldType
163 public:
164 SwDBNextSetFieldType();
166 virtual SwFieldType* Copy() const;
169 /*--------------------------------------------------------------------
170 Next data record with condition.
171 --------------------------------------------------------------------*/
173 class SW_DLLPUBLIC SwDBNextSetField : public SwDBNameInfField
175 OUString aCond;
176 bool bCondValid;
178 public:
179 SwDBNextSetField( SwDBNextSetFieldType*,
180 const String& rCond, const String& rDummy, const SwDBData& rDBData);
182 virtual String Expand() const;
183 virtual SwField* Copy() const;
185 void Evaluate(SwDoc*);
186 inline void SetCondValid(bool bCond);
187 inline bool IsCondValid() const;
189 // Condition
190 virtual const OUString& GetPar1() const;
191 virtual void SetPar1(const OUString& rStr);
192 virtual bool QueryValue( com::sun::star::uno::Any& rVal, sal_uInt16 nWhich ) const;
193 virtual bool PutValue( const com::sun::star::uno::Any& rVal, sal_uInt16 nWhich );
196 inline bool SwDBNextSetField::IsCondValid() const
197 { return bCondValid; }
199 inline void SwDBNextSetField::SetCondValid(bool bCond)
200 { bCondValid = bCond; }
202 /*--------------------------------------------------------------------
203 Database field next record.
204 --------------------------------------------------------------------*/
206 class SwDBNumSetFieldType : public SwFieldType
208 public:
209 SwDBNumSetFieldType();
211 virtual SwFieldType* Copy() const;
214 /*--------------------------------------------------------------------
215 Data record with number xxx.
216 Number is in nFormat (bit of a misuse!)
217 --------------------------------------------------------------------*/
219 class SwDBNumSetField : public SwDBNameInfField
221 OUString aCond;
222 String aPar2;
223 bool bCondValid;
225 public:
226 SwDBNumSetField(SwDBNumSetFieldType*, const String& rCond, const String& rDBNum, const SwDBData& rDBData);
228 virtual String Expand() const;
229 virtual SwField* Copy() const;
231 inline bool IsCondValid() const;
232 inline void SetCondValid(bool bCond);
233 void Evaluate(SwDoc*);
235 // Condition
236 virtual const OUString& GetPar1() const;
237 virtual void SetPar1(const OUString& rStr);
239 // Number of data record.
240 virtual OUString GetPar2() const;
241 virtual void SetPar2(const OUString& rStr);
243 // Number of data record is in nFormat!!
244 virtual bool QueryValue( com::sun::star::uno::Any& rVal, sal_uInt16 nWhich ) const;
245 virtual bool PutValue( const com::sun::star::uno::Any& rVal, sal_uInt16 nWhich );
248 inline bool SwDBNumSetField::IsCondValid() const
249 { return bCondValid; }
251 inline void SwDBNumSetField::SetCondValid(bool bCond)
252 { bCondValid = bCond; }
254 /*--------------------------------------------------------------------
255 Database name.
256 --------------------------------------------------------------------*/
258 class SwDBNameFieldType : public SwFieldType
260 SwDoc *pDoc;
261 public:
262 SwDBNameFieldType(SwDoc*);
264 String Expand(sal_uLong) const;
265 virtual SwFieldType* Copy() const;
268 /*--------------------------------------------------------------------
269 Database field.
270 --------------------------------------------------------------------*/
272 class SW_DLLPUBLIC SwDBNameField : public SwDBNameInfField
274 public:
275 SwDBNameField(SwDBNameFieldType*, const SwDBData& rDBData, sal_uLong nFmt = 0);
277 virtual String Expand() const;
278 virtual SwField* Copy() const;
279 virtual bool QueryValue( com::sun::star::uno::Any& rVal, sal_uInt16 nWhich ) const;
280 virtual bool PutValue( const com::sun::star::uno::Any& rVal, sal_uInt16 nWhich );
283 /*--------------------------------------------------------------------
284 Number of data record.
285 --------------------------------------------------------------------*/
287 class SW_DLLPUBLIC SwDBSetNumberFieldType : public SwFieldType
289 public:
290 SwDBSetNumberFieldType();
292 virtual SwFieldType* Copy() const;
295 /*--------------------------------------------------------------------
296 Database field.
297 --------------------------------------------------------------------*/
299 class SW_DLLPUBLIC SwDBSetNumberField : public SwDBNameInfField
301 long nNumber;
303 public:
304 SwDBSetNumberField(SwDBSetNumberFieldType*, const SwDBData& rDBData, sal_uLong nFmt = 0);
306 virtual String Expand() const;
307 virtual SwField* Copy() const;
308 void Evaluate(SwDoc*);
310 inline long GetSetNumber() const;
311 inline void SetSetNumber(long nNum);
312 virtual bool QueryValue( com::sun::star::uno::Any& rVal, sal_uInt16 nWhich ) const;
313 virtual bool PutValue( const com::sun::star::uno::Any& rVal, sal_uInt16 nWhich );
316 inline long SwDBSetNumberField::GetSetNumber() const
317 { return nNumber; }
319 inline void SwDBSetNumberField::SetSetNumber(long nNum)
320 { nNumber = nNum; }
322 #endif // SW_DBFLD_HXX
324 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */