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"
41 /*--------------------------------------------------------------------
42 Beschreibung: Datenbankfeld
43 --------------------------------------------------------------------*/
45 class SW_DLLPUBLIC SwDBFieldType
: public SwValueFieldType
48 String sName
; // only used in ::GetName() !
54 SwDBFieldType(SwDoc
* pDocPtr
, const String
& rColumnName
, const SwDBData
& rDBData
);
56 virtual const String
& GetName() const;
57 virtual SwFieldType
* Copy() const;
59 inline void AddRef() { nRefCnt
++; }
62 const String
& GetColumnName() const {return sColumn
;}
63 const SwDBData
& GetDBData() const {return aDBData
;}
65 virtual BOOL
QueryValue( com::sun::star::uno::Any
& rVal
, USHORT nWhich
) const;
66 virtual BOOL
PutValue( const com::sun::star::uno::Any
& rVal
, USHORT nWhich
);
69 /*--------------------------------------------------------------------
71 von SwFields abgeleitete Klassen. Sie ueberlagern die Expand-Funktion.
72 Der Inhalt wird entsprechend dem Format, soweit vorhanden, formatiert.
73 --------------------------------------------------------------------*/
75 class SW_DLLPUBLIC SwDBField
: public SwValueField
78 String sFieldCode
; // contains Word's field code
80 BOOL bIsInBodyTxt
: 1;
82 BOOL bInitialized
: 1;
85 SwDBField(SwDBFieldType
*, ULONG nFmt
= 0);
88 virtual SwFieldType
* ChgTyp( SwFieldType
* );
91 inline void SetExpansion(const String
& rStr
);
92 virtual String
Expand() const;
93 virtual SwField
* Copy() const;
95 virtual USHORT
GetSubType() const;
96 virtual void SetSubType(USHORT nType
);
99 virtual String
GetCntnt(BOOL bName
= FALSE
) const;
101 // fuer Berechnungen in Ausdruecken
102 void ChgValue( double d
, BOOL bVal
);
104 // Evaluierung ueber den DBMgr String rauspulen
107 // Evaluierung fuer Kopf und Fusszeilen
108 void ChangeExpansion( const SwFrm
*, const SwTxtFld
* );
110 void InitContent(const String
& rExpansion
);
112 inline void ChgBodyTxtFlag( BOOL bIsInBody
);
114 inline BOOL
IsInitialized() const { return bInitialized
; }
115 inline void ClearInitialized() { bInitialized
= FALSE
; }
116 inline void SetInitialized() { bInitialized
= TRUE
; }
119 virtual const String
& GetPar1() const;
121 // access to the command string
122 const String
& GetFieldCode() const
123 { return sFieldCode
;}
124 void SetFieldCode(const String
& rStr
)
125 { sFieldCode
= rStr
; }
128 inline const SwDBData
& GetDBData() const { return ((SwDBFieldType
*)GetTyp())->GetDBData(); }
129 virtual BOOL
QueryValue( com::sun::star::uno::Any
& rVal
, USHORT nWhich
) const;
130 virtual BOOL
PutValue( const com::sun::star::uno::Any
& rVal
, USHORT nWhich
);
133 inline void SwDBField::SetExpansion(const String
& rStr
)
136 // wird von UpdateExpFlds gesetzt (dort ist die Node-Position bekannt)
137 inline void SwDBField::ChgBodyTxtFlag( BOOL bIsInBody
)
138 { bIsInBodyTxt
= bIsInBody
; }
140 /*--------------------------------------------------------------------
141 Beschreibung: Basisklasse fuer alle weiteren Datenbankfelder
142 --------------------------------------------------------------------*/
144 class SW_DLLPUBLIC SwDBNameInfField
: public SwField
150 const SwDBData
& GetDBData() const {return aDBData
;}
151 SwDBData
& GetDBData() {return aDBData
;}
153 SwDBNameInfField(SwFieldType
* pTyp
, const SwDBData
& rDBData
, ULONG nFmt
= 0);
157 inline const SwDBData
& GetRealDBData() { return aDBData
; }
159 SwDBData
GetDBData(SwDoc
* pDoc
);
160 void SetDBData(const SwDBData
& rDBData
); // #111840#
163 virtual String
GetCntnt(BOOL bName
= FALSE
) const;
164 virtual BOOL
QueryValue( com::sun::star::uno::Any
& rVal
, USHORT nWhich
) const;
165 virtual BOOL
PutValue( const com::sun::star::uno::Any
& rVal
, USHORT nWhich
);
166 virtual USHORT
GetSubType() const;
167 virtual void SetSubType(USHORT nType
);
171 /*--------------------------------------------------------------------
172 Beschreibung: Datenbankfeld Naechster Satz
173 --------------------------------------------------------------------*/
175 class SW_DLLPUBLIC SwDBNextSetFieldType
: public SwFieldType
178 SwDBNextSetFieldType();
180 virtual SwFieldType
* Copy() const;
184 /*--------------------------------------------------------------------
185 Beschreibung: Naechsten Datensatz mit Bedingung
186 --------------------------------------------------------------------*/
188 class SW_DLLPUBLIC SwDBNextSetField
: public SwDBNameInfField
194 SwDBNextSetField( SwDBNextSetFieldType
*,
195 const String
& rCond
, const String
& rDummy
, const SwDBData
& rDBData
);
197 virtual String
Expand() const;
198 virtual SwField
* Copy() const;
200 void Evaluate(SwDoc
*);
201 inline void SetCondValid(BOOL bCond
);
202 inline BOOL
IsCondValid() const;
205 virtual const String
& GetPar1() const;
206 virtual void SetPar1(const String
& rStr
);
207 virtual BOOL
QueryValue( com::sun::star::uno::Any
& rVal
, USHORT nWhich
) const;
208 virtual BOOL
PutValue( const com::sun::star::uno::Any
& rVal
, USHORT nWhich
);
211 inline BOOL
SwDBNextSetField::IsCondValid() const
212 { return bCondValid
; }
214 inline void SwDBNextSetField::SetCondValid(BOOL bCond
)
215 { bCondValid
= bCond
; }
217 /*--------------------------------------------------------------------
218 Beschreibung: Datenbankfeld Naechster Satz
219 --------------------------------------------------------------------*/
221 class SwDBNumSetFieldType
: public SwFieldType
224 SwDBNumSetFieldType();
226 virtual SwFieldType
* Copy() const;
230 /*--------------------------------------------------------------------
231 Beschreibung: Datensatz mit Nummer xxx
232 Die Nummer steht in nFormat
234 --------------------------------------------------------------------*/
236 class SwDBNumSetField
: public SwDBNameInfField
243 SwDBNumSetField(SwDBNumSetFieldType
*, const String
& rCond
, const String
& rDBNum
, const SwDBData
& rDBData
);
245 virtual String
Expand() const;
246 virtual SwField
* Copy() const;
248 inline BOOL
IsCondValid() const;
249 inline void SetCondValid(BOOL bCond
);
250 void Evaluate(SwDoc
*);
253 virtual const String
& GetPar1() const;
254 virtual void SetPar1(const String
& rStr
);
257 virtual String
GetPar2() const;
258 virtual void SetPar2(const String
& rStr
);
260 // Die Datensatznummer steht in nFormat !!
261 virtual BOOL
QueryValue( com::sun::star::uno::Any
& rVal
, USHORT nWhich
) const;
262 virtual BOOL
PutValue( const com::sun::star::uno::Any
& rVal
, USHORT nWhich
);
265 inline BOOL
SwDBNumSetField::IsCondValid() const
266 { return bCondValid
; }
268 inline void SwDBNumSetField::SetCondValid(BOOL bCond
)
269 { bCondValid
= bCond
; }
271 /*--------------------------------------------------------------------
272 Beschreibung: Datenbankname
273 --------------------------------------------------------------------*/
275 class SwDBNameFieldType
: public SwFieldType
279 SwDBNameFieldType(SwDoc
*);
281 String
Expand(ULONG
) const;
282 virtual SwFieldType
* Copy() const;
285 /*--------------------------------------------------------------------
286 Beschreibung: Datenbankfeld
287 --------------------------------------------------------------------*/
289 class SW_DLLPUBLIC SwDBNameField
: public SwDBNameInfField
292 SwDBNameField(SwDBNameFieldType
*, const SwDBData
& rDBData
, ULONG nFmt
= 0);
294 virtual String
Expand() const;
295 virtual SwField
* Copy() const;
296 virtual BOOL
QueryValue( com::sun::star::uno::Any
& rVal
, USHORT nWhich
) const;
297 virtual BOOL
PutValue( const com::sun::star::uno::Any
& rVal
, USHORT nWhich
);
300 /*--------------------------------------------------------------------
301 Beschreibung: Datensatznummer
302 --------------------------------------------------------------------*/
304 class SW_DLLPUBLIC SwDBSetNumberFieldType
: public SwFieldType
307 SwDBSetNumberFieldType();
309 virtual SwFieldType
* Copy() const;
312 /*--------------------------------------------------------------------
313 Beschreibung: Datenbankfeld
314 --------------------------------------------------------------------*/
316 class SW_DLLPUBLIC SwDBSetNumberField
: public SwDBNameInfField
321 SwDBSetNumberField(SwDBSetNumberFieldType
*, const SwDBData
& rDBData
, ULONG nFmt
= 0);
323 virtual String
Expand() const;
324 virtual SwField
* Copy() const;
325 void Evaluate(SwDoc
*);
327 inline long GetSetNumber() const;
328 inline void SetSetNumber(long nNum
);
329 virtual BOOL
QueryValue( com::sun::star::uno::Any
& rVal
, USHORT nWhich
) const;
330 virtual BOOL
PutValue( const com::sun::star::uno::Any
& rVal
, USHORT nWhich
);
333 inline long SwDBSetNumberField::GetSetNumber() const
336 inline void SwDBSetNumberField::SetSetNumber(long nNum
)