merge the formfield patch from ooo-build
[ooovba.git] / sw / inc / dbfld.hxx
blob8f3bf051aab65c970652aa61afe172f90a0b972b
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: dbfld.hxx,v $
10 * $Revision: 1.12 $
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 ************************************************************************/
30 #ifndef _DBFLD_HXX
31 #define _DBFLD_HXX
33 #include "swdllapi.h"
34 #include "fldbas.hxx"
35 #include "swdbdata.hxx"
37 class SwDoc;
38 class SwTxtFld;
39 class SwFrm;
41 /*--------------------------------------------------------------------
42 Beschreibung: Datenbankfeld
43 --------------------------------------------------------------------*/
45 class SW_DLLPUBLIC SwDBFieldType : public SwValueFieldType
47 SwDBData aDBData; //
48 String sName; // only used in ::GetName() !
49 String sColumn;
50 long nRefCnt;
52 public:
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++; }
60 void ReleaseRef();
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 /*--------------------------------------------------------------------
70 Beschreibung:
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
77 String aContent;
78 String sFieldCode; // contains Word's field code
79 USHORT nSubType;
80 BOOL bIsInBodyTxt : 1;
81 BOOL bValidValue : 1;
82 BOOL bInitialized : 1;
84 public:
85 SwDBField(SwDBFieldType*, ULONG nFmt = 0);
86 virtual ~SwDBField();
88 virtual SwFieldType* ChgTyp( SwFieldType* );
90 // Der aktuelle Text
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);
98 // Name oder Inhalt
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
105 void Evaluate();
107 // Evaluierung fuer Kopf und Fusszeilen
108 void ChangeExpansion( const SwFrm*, const SwTxtFld* );
109 void InitContent();
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; }
118 // Name erfragen
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; }
127 // DBName
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)
134 { aContent = 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
146 SwDBData aDBData;
147 USHORT nSubType;
149 protected:
150 const SwDBData& GetDBData() const {return aDBData;}
151 SwDBData& GetDBData() {return aDBData;}
153 SwDBNameInfField(SwFieldType* pTyp, const SwDBData& rDBData, ULONG nFmt = 0);
155 public:
156 // DBName
157 inline const SwDBData& GetRealDBData() { return aDBData; }
159 SwDBData GetDBData(SwDoc* pDoc);
160 void SetDBData(const SwDBData& rDBData); // #111840#
162 // Name oder Inhalt
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
177 public:
178 SwDBNextSetFieldType();
180 virtual SwFieldType* Copy() const;
184 /*--------------------------------------------------------------------
185 Beschreibung: Naechsten Datensatz mit Bedingung
186 --------------------------------------------------------------------*/
188 class SW_DLLPUBLIC SwDBNextSetField : public SwDBNameInfField
190 String aCond;
191 BOOL bCondValid;
193 public:
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;
204 // Condition
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
223 public:
224 SwDBNumSetFieldType();
226 virtual SwFieldType* Copy() const;
230 /*--------------------------------------------------------------------
231 Beschreibung: Datensatz mit Nummer xxx
232 Die Nummer steht in nFormat
233 ! kleiner Missbrauch
234 --------------------------------------------------------------------*/
236 class SwDBNumSetField : public SwDBNameInfField
238 String aCond;
239 String aPar2;
240 BOOL bCondValid;
242 public:
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*);
252 // Condition
253 virtual const String& GetPar1() const;
254 virtual void SetPar1(const String& rStr);
256 // Datensatznummer
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
277 SwDoc *pDoc;
278 public:
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
291 public:
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
306 public:
307 SwDBSetNumberFieldType();
309 virtual SwFieldType* Copy() const;
312 /*--------------------------------------------------------------------
313 Beschreibung: Datenbankfeld
314 --------------------------------------------------------------------*/
316 class SW_DLLPUBLIC SwDBSetNumberField : public SwDBNameInfField
318 long nNumber;
320 public:
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
334 { return nNumber; }
336 inline void SwDBSetNumberField::SetSetNumber(long nNum)
337 { nNumber = nNum; }
340 #endif // _DBFLD_HXX