1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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 .
24 #include "swdbdata.hxx"
30 /*--------------------------------------------------------------------
32 --------------------------------------------------------------------*/
34 class SW_DLLPUBLIC SwDBFieldType
: public SwValueFieldType
37 OUString sName
; ///< only used in ::GetName() !
43 SwDBFieldType(SwDoc
* pDocPtr
, const String
& rColumnName
, const SwDBData
& rDBData
);
46 virtual const OUString
& GetName() const;
47 virtual SwFieldType
* Copy() const;
49 inline void AddRef() { nRefCnt
++; }
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
67 OUString sFieldCode
; ///< contains Word's field code
69 bool bIsInBodyTxt
: 1;
71 bool bInitialized
: 1;
73 virtual String
Expand() const;
74 virtual SwField
* Copy() const;
77 SwDBField(SwDBFieldType
*, sal_uLong nFmt
= 0);
80 virtual SwFieldType
* ChgTyp( SwFieldType
* );
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.
96 /// Evaluation for header and footer.
97 void ChangeExpansion( const SwFrm
*, const SwTxtFld
* );
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; }
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
; }
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
)
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
137 const SwDBData
& GetDBData() const {return aDBData
;}
138 SwDBData
& GetDBData() {return aDBData
;}
140 SwDBNameInfField(SwFieldType
* pTyp
, const SwDBData
& rDBData
, sal_uLong nFmt
= 0);
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
164 SwDBNextSetFieldType();
166 virtual SwFieldType
* Copy() const;
169 /*--------------------------------------------------------------------
170 Next data record with condition.
171 --------------------------------------------------------------------*/
173 class SW_DLLPUBLIC SwDBNextSetField
: public SwDBNameInfField
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;
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
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
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
*);
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 /*--------------------------------------------------------------------
256 --------------------------------------------------------------------*/
258 class SwDBNameFieldType
: public SwFieldType
262 SwDBNameFieldType(SwDoc
*);
264 String
Expand(sal_uLong
) const;
265 virtual SwFieldType
* Copy() const;
268 /*--------------------------------------------------------------------
270 --------------------------------------------------------------------*/
272 class SW_DLLPUBLIC SwDBNameField
: public SwDBNameInfField
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
290 SwDBSetNumberFieldType();
292 virtual SwFieldType
* Copy() const;
295 /*--------------------------------------------------------------------
297 --------------------------------------------------------------------*/
299 class SW_DLLPUBLIC SwDBSetNumberField
: public SwDBNameInfField
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
319 inline void SwDBSetNumberField::SetSetNumber(long nNum
)
322 #endif // SW_DBFLD_HXX
324 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */