1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: dbfld.hxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
35 #include <swdbdata.hxx>
43 /*--------------------------------------------------------------------
44 Beschreibung: Datenbankfeld
45 --------------------------------------------------------------------*/
47 class SwDBFieldType
: public SwValueFieldType
50 String sName
; // only used in ::GetName() !
56 SwDBFieldType(SwDoc
* pDocPtr
, const String
& rColumnName
, const SwDBData
& rDBData
);
58 virtual const String
& GetName() const;
59 virtual SwFieldType
* Copy() const;
61 inline void AddRef() { nRefCnt
++; }
63 inline long GetRefCount() { return nRefCnt
; }
65 const String
& GetColumnName() const {return sColumn
;}
66 const SwDBData
& GetDBData() const {return aDBData
;}
68 virtual BOOL
QueryValue( ::com::sun::star::uno::Any
& rVal
, BYTE nMId
) const;
69 virtual BOOL
PutValue( const ::com::sun::star::uno::Any
& rVal
, BYTE nMId
);
72 /*--------------------------------------------------------------------
74 von SwFields abgeleitete Klassen. Sie ueberlagern die Expand-Funktion.
75 Der Inhalt wird entsprechend dem Format, soweit vorhanden, formatiert.
76 --------------------------------------------------------------------*/
78 class SwDBField
: public SwValueField
82 BOOL bIsInBodyTxt
: 1;
84 BOOL bInitialized
: 1;
87 SwDBField(SwDBFieldType
*, ULONG nFmt
= 0);
90 virtual SwFieldType
* ChgTyp( SwFieldType
* );
93 inline void SetExpansion(const String
& rStr
);
94 virtual String
Expand() const;
95 virtual SwField
* Copy() const;
97 virtual USHORT
GetSubType() const;
98 virtual void SetSubType(USHORT nType
);
102 // fuer Berechnungen in Ausdruecken
103 void ChgValue( double d
, BOOL bVal
);
105 // Evaluierung ueber den DBMgr String rauspulen
108 // Evaluierung fuer Kopf und Fusszeilen
109 void ChangeExpansion( const SwFrm
*, const SwTxtFld
* );
111 void InitContent(const String
& rExpansion
);
112 String
GetOldContent();
114 inline void ChgBodyTxtFlag( BOOL bIsInBody
);
115 inline BOOL
IsInBodyTxt() const;
117 inline BOOL
IsValidValue() const { return bValidValue
; }
119 inline BOOL
IsInitialized() const { return bInitialized
; }
120 inline void ClearInitialized() { bInitialized
= FALSE
; }
121 inline void SetInitialized() { bInitialized
= TRUE
; }
124 virtual const String
& GetPar1() const;
127 inline const SwDBData
& GetDBData() const { return ((SwDBFieldType
*)GetTyp())->GetDBData(); }
128 virtual BOOL
QueryValue( ::com::sun::star::uno::Any
& rVal
, BYTE nMId
) const;
129 virtual BOOL
PutValue( const ::com::sun::star::uno::Any
& rVal
, BYTE nMId
);
132 inline void SwDBField::SetExpansion(const String
& rStr
)
135 // wird von der Formatierung abgefragt
136 inline BOOL
SwDBField::IsInBodyTxt() const
137 { return bIsInBodyTxt
; }
139 // wird von UpdateExpFlds gesetzt (dort ist die Node-Position bekannt)
140 inline void SwDBField::ChgBodyTxtFlag( BOOL bIsInBody
)
141 { bIsInBodyTxt
= bIsInBody
; }
143 /*--------------------------------------------------------------------
144 Beschreibung: Basisklasse fuer alle weiteren Datenbankfelder
145 --------------------------------------------------------------------*/
147 class SwDBNameInfField
: public SwField
153 const SwDBData
& GetDBData() const {return aDBData
;}
154 SwDBData
& GetDBData() {return aDBData
;}
156 SwDBNameInfField(SwFieldType
* pTyp
, const SwDBData
& rDBData
, ULONG nFmt
= 0);
160 inline const SwDBData
& GetRealDBData() { return aDBData
; }
162 SwDBData
GetDBData(SwDoc
* pDoc
);
163 inline void SetDBData(const SwDBData
& rDBData
) { aDBData
= rDBData
; }
166 virtual BOOL
QueryValue( ::com::sun::star::uno::Any
& rVal
, BYTE nMId
) const;
167 virtual BOOL
PutValue( const ::com::sun::star::uno::Any
& rVal
, BYTE nMId
);
168 virtual USHORT
GetSubType() const;
169 virtual void SetSubType(USHORT nType
);
173 /*--------------------------------------------------------------------
174 Beschreibung: Datenbankfeld Naechster Satz
175 --------------------------------------------------------------------*/
177 class SwDBNextSetFieldType
: public SwFieldType
180 SwDBNextSetFieldType();
182 virtual SwFieldType
* Copy() const;
186 /*--------------------------------------------------------------------
187 Beschreibung: Naechsten Datensatz mit Bedingung
188 --------------------------------------------------------------------*/
190 class SwDBNextSetField
: public SwDBNameInfField
196 SwDBNextSetField( SwDBNextSetFieldType
*,
197 const String
& rCond
, const String
& rDummy
, const SwDBData
& rDBData
);
199 virtual String
Expand() const;
200 virtual SwField
* Copy() const;
202 void Evaluate(SwDoc
*);
203 inline void SetCondValid(BOOL bCond
);
204 inline BOOL
IsCondValid() const;
207 virtual const String
& GetPar1() const;
208 virtual void SetPar1(const String
& rStr
);
209 virtual BOOL
QueryValue( ::com::sun::star::uno::Any
& rVal
, BYTE nMId
) const;
210 virtual BOOL
PutValue( const ::com::sun::star::uno::Any
& rVal
, BYTE nMId
);
213 inline BOOL
SwDBNextSetField::IsCondValid() const
214 { return bCondValid
; }
216 inline void SwDBNextSetField::SetCondValid(BOOL bCond
)
217 { bCondValid
= bCond
; }
219 /*--------------------------------------------------------------------
220 Beschreibung: Datenbankfeld Naechster Satz
221 --------------------------------------------------------------------*/
223 class SwDBNumSetFieldType
: public SwFieldType
226 SwDBNumSetFieldType();
228 virtual SwFieldType
* Copy() const;
232 /*--------------------------------------------------------------------
233 Beschreibung: Datensatz mit Nummer xxx
234 Die Nummer steht in nFormat
236 --------------------------------------------------------------------*/
238 class SwDBNumSetField
: public SwDBNameInfField
245 SwDBNumSetField(SwDBNumSetFieldType
*, const String
& rCond
, const String
& rDBNum
, const SwDBData
& rDBData
);
247 virtual String
Expand() const;
248 virtual SwField
* Copy() const;
250 inline BOOL
IsCondValid() const;
251 inline void SetCondValid(BOOL bCond
);
252 void Evaluate(SwDoc
*);
255 virtual const String
& GetPar1() const;
256 virtual void SetPar1(const String
& rStr
);
259 virtual String
GetPar2() const;
260 virtual void SetPar2(const String
& rStr
);
262 // Die Datensatznummer steht in nFormat !!
263 virtual BOOL
QueryValue( ::com::sun::star::uno::Any
& rVal
, BYTE nMId
) const;
264 virtual BOOL
PutValue( const ::com::sun::star::uno::Any
& rVal
, BYTE nMId
);
267 inline BOOL
SwDBNumSetField::IsCondValid() const
268 { return bCondValid
; }
270 inline void SwDBNumSetField::SetCondValid(BOOL bCond
)
271 { bCondValid
= bCond
; }
273 /*--------------------------------------------------------------------
274 Beschreibung: Datenbankname
275 --------------------------------------------------------------------*/
277 class SwDBNameFieldType
: public SwFieldType
281 SwDBNameFieldType(SwDoc
*);
283 String
Expand(ULONG
) const;
284 virtual SwFieldType
* Copy() const;
287 /*--------------------------------------------------------------------
288 Beschreibung: Datenbankfeld
289 --------------------------------------------------------------------*/
291 class SwDBNameField
: public SwDBNameInfField
294 SwDBNameField(SwDBNameFieldType
*, const SwDBData
& rDBData
, ULONG nFmt
= 0);
296 virtual String
Expand() const;
297 virtual SwField
* Copy() const;
298 virtual BOOL
QueryValue( ::com::sun::star::uno::Any
& rVal
, BYTE nMId
) const;
299 virtual BOOL
PutValue( const ::com::sun::star::uno::Any
& rVal
, BYTE nMId
);
302 /*--------------------------------------------------------------------
303 Beschreibung: Datensatznummer
304 --------------------------------------------------------------------*/
306 class SwDBSetNumberFieldType
: public SwFieldType
309 SwDBSetNumberFieldType();
311 virtual SwFieldType
* Copy() const;
314 /*--------------------------------------------------------------------
315 Beschreibung: Datenbankfeld
316 --------------------------------------------------------------------*/
318 class SwDBSetNumberField
: public SwDBNameInfField
323 SwDBSetNumberField(SwDBSetNumberFieldType
*, const SwDBData
& rDBData
, ULONG nFmt
= 0);
325 virtual String
Expand() const;
326 virtual SwField
* Copy() const;
327 void Evaluate(SwDoc
*);
329 inline long GetSetNumber() const;
330 inline void SetSetNumber(long nNum
);
331 virtual BOOL
QueryValue( ::com::sun::star::uno::Any
& rVal
, BYTE nMId
) const;
332 virtual BOOL
PutValue( const ::com::sun::star::uno::Any
& rVal
, BYTE nMId
);
335 inline long SwDBSetNumberField::GetSetNumber() const
338 inline void SwDBSetNumberField::SetSetNumber(long nNum
)
342 } //namespace binfilter