Update ooo320-m1
[ooovba.git] / binfilter / inc / bf_sw / dbfld.hxx
bloba79a37ee6e72c8ea89a867155973258534804278
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.6 $
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 "fldbas.hxx"
34 #ifndef _SWDBDATA_HXX
35 #include <swdbdata.hxx>
36 #endif
37 namespace binfilter {
39 class SwDoc;
40 class SwTxtFld;
41 class SwFrm;
43 /*--------------------------------------------------------------------
44 Beschreibung: Datenbankfeld
45 --------------------------------------------------------------------*/
47 class SwDBFieldType : public SwValueFieldType
49 SwDBData aDBData; //
50 String sName; // only used in ::GetName() !
51 String sColumn;
52 long nRefCnt;
54 public:
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++; }
62 void ReleaseRef();
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 /*--------------------------------------------------------------------
73 Beschreibung:
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
80 String aContent;
81 USHORT nSubType;
82 BOOL bIsInBodyTxt : 1;
83 BOOL bValidValue : 1;
84 BOOL bInitialized : 1;
86 public:
87 SwDBField(SwDBFieldType*, ULONG nFmt = 0);
88 virtual ~SwDBField();
90 virtual SwFieldType* ChgTyp( SwFieldType* );
92 // Der aktuelle Text
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);
100 // Name oder Inhalt
102 // fuer Berechnungen in Ausdruecken
103 void ChgValue( double d, BOOL bVal );
105 // Evaluierung ueber den DBMgr String rauspulen
106 void Evaluate();
108 // Evaluierung fuer Kopf und Fusszeilen
109 void ChangeExpansion( const SwFrm*, const SwTxtFld* );
110 void InitContent();
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; }
123 // Name erfragen
124 virtual const String& GetPar1() const;
126 // DBName
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)
133 { aContent = 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
149 SwDBData aDBData;
150 USHORT nSubType;
152 protected:
153 const SwDBData& GetDBData() const {return aDBData;}
154 SwDBData& GetDBData() {return aDBData;}
156 SwDBNameInfField(SwFieldType* pTyp, const SwDBData& rDBData, ULONG nFmt = 0);
158 public:
159 // DBName
160 inline const SwDBData& GetRealDBData() { return aDBData; }
162 SwDBData GetDBData(SwDoc* pDoc);
163 inline void SetDBData(const SwDBData& rDBData) { aDBData = rDBData; }
165 // Name oder Inhalt
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
179 public:
180 SwDBNextSetFieldType();
182 virtual SwFieldType* Copy() const;
186 /*--------------------------------------------------------------------
187 Beschreibung: Naechsten Datensatz mit Bedingung
188 --------------------------------------------------------------------*/
190 class SwDBNextSetField : public SwDBNameInfField
192 String aCond;
193 BOOL bCondValid;
195 public:
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;
206 // Condition
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
225 public:
226 SwDBNumSetFieldType();
228 virtual SwFieldType* Copy() const;
232 /*--------------------------------------------------------------------
233 Beschreibung: Datensatz mit Nummer xxx
234 Die Nummer steht in nFormat
235 ! kleiner Missbrauch
236 --------------------------------------------------------------------*/
238 class SwDBNumSetField : public SwDBNameInfField
240 String aCond;
241 String aPar2;
242 BOOL bCondValid;
244 public:
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*);
254 // Condition
255 virtual const String& GetPar1() const;
256 virtual void SetPar1(const String& rStr);
258 // Datensatznummer
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
279 SwDoc *pDoc;
280 public:
281 SwDBNameFieldType(SwDoc*);
283 String Expand(ULONG) const;
284 virtual SwFieldType* Copy() const;
287 /*--------------------------------------------------------------------
288 Beschreibung: Datenbankfeld
289 --------------------------------------------------------------------*/
291 class SwDBNameField : public SwDBNameInfField
293 public:
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
308 public:
309 SwDBSetNumberFieldType();
311 virtual SwFieldType* Copy() const;
314 /*--------------------------------------------------------------------
315 Beschreibung: Datenbankfeld
316 --------------------------------------------------------------------*/
318 class SwDBSetNumberField : public SwDBNameInfField
320 long nNumber;
322 public:
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
336 { return nNumber; }
338 inline void SwDBSetNumberField::SetSetNumber(long nNum)
339 { nNumber = nNum; }
342 } //namespace binfilter
343 #endif // _DBFLD_HXX