1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 #ifndef SW_DBFLD_HXX 28 #define SW_DBFLD_HXX 29 30 #include "swdllapi.h" 31 #include "fldbas.hxx" 32 #include "swdbdata.hxx" 33 34 class SwDoc; 35 class SwTxtFld; 36 class SwFrm; 37 38 /*-------------------------------------------------------------------- 39 Beschreibung: Datenbankfeld 40 --------------------------------------------------------------------*/ 41 42 class SW_DLLPUBLIC SwDBFieldType : public SwValueFieldType 43 { 44 SwDBData aDBData; // 45 String sName; // only used in ::GetName() ! 46 String sColumn; 47 long nRefCnt; 48 49 public: 50 51 SwDBFieldType(SwDoc* pDocPtr, const String& rColumnName, const SwDBData& rDBData); 52 ~SwDBFieldType(); 53 54 virtual const String& GetName() const; 55 virtual SwFieldType* Copy() const; 56 57 inline void AddRef() { nRefCnt++; } 58 void ReleaseRef(); 59 60 const String& GetColumnName() const {return sColumn;} 61 const SwDBData& GetDBData() const {return aDBData;} 62 63 virtual sal_Bool QueryValue( com::sun::star::uno::Any& rVal, sal_uInt16 nWhich ) const; 64 virtual sal_Bool PutValue( const com::sun::star::uno::Any& rVal, sal_uInt16 nWhich ); 65 }; 66 67 /*-------------------------------------------------------------------- 68 Beschreibung: 69 von SwFields abgeleitete Klassen. Sie ueberlagern die Expand-Funktion. 70 Der Inhalt wird entsprechend dem Format, soweit vorhanden, formatiert. 71 --------------------------------------------------------------------*/ 72 73 class SW_DLLPUBLIC SwDBField : public SwValueField 74 { 75 String aContent; 76 String sFieldCode; // contains Word's field code 77 sal_uInt16 nSubType; 78 sal_Bool bIsInBodyTxt : 1; 79 sal_Bool bValidValue : 1; 80 sal_Bool bInitialized : 1; 81 82 virtual String Expand() const; 83 virtual SwField* Copy() const; 84 85 public: 86 SwDBField(SwDBFieldType*, sal_uLong nFmt = 0); 87 virtual ~SwDBField(); 88 89 virtual SwFieldType* ChgTyp( SwFieldType* ); 90 91 // Der aktuelle Text 92 inline void SetExpansion(const String& rStr); 93 94 virtual sal_uInt16 GetSubType() const; 95 virtual void SetSubType(sal_uInt16 nType); 96 97 virtual String GetFieldName() const; 98 99 // fuer Berechnungen in Ausdruecken 100 void ChgValue( double d, sal_Bool bVal ); 101 102 // Evaluierung ueber den DBMgr String rauspulen 103 void Evaluate(); 104 105 // Evaluierung fuer Kopf und Fusszeilen 106 void ChangeExpansion( const SwFrm*, const SwTxtFld* ); 107 void InitContent(); 108 void InitContent(const String& rExpansion); 109 110 inline void ChgBodyTxtFlag( sal_Bool bIsInBody ); 111 112 inline sal_Bool IsInitialized() const { return bInitialized; } 113 inline void ClearInitialized() { bInitialized = sal_False; } 114 inline void SetInitialized() { bInitialized = sal_True; } 115 116 // Name erfragen 117 virtual const String& GetPar1() const; 118 119 // access to the command string 120 const String& GetFieldCode() const 121 { return sFieldCode;} 122 void SetFieldCode(const String& rStr) 123 { sFieldCode = rStr; } 124 125 // DBName 126 inline const SwDBData& GetDBData() const { return ((SwDBFieldType*)GetTyp())->GetDBData(); } 127 virtual sal_Bool QueryValue( com::sun::star::uno::Any& rVal, sal_uInt16 nWhich ) const; 128 virtual sal_Bool PutValue( const com::sun::star::uno::Any& rVal, sal_uInt16 nWhich ); 129 }; 130 131 inline void SwDBField::SetExpansion(const String& rStr) 132 { aContent = rStr; } 133 134 // wird von UpdateExpFlds gesetzt (dort ist die Node-Position bekannt) 135 inline void SwDBField::ChgBodyTxtFlag( sal_Bool bIsInBody ) 136 { bIsInBodyTxt = bIsInBody; } 137 138 /*-------------------------------------------------------------------- 139 Beschreibung: Basisklasse fuer alle weiteren Datenbankfelder 140 --------------------------------------------------------------------*/ 141 142 class SW_DLLPUBLIC SwDBNameInfField : public SwField 143 { 144 SwDBData aDBData; 145 sal_uInt16 nSubType; 146 147 protected: 148 const SwDBData& GetDBData() const {return aDBData;} 149 SwDBData& GetDBData() {return aDBData;} 150 151 SwDBNameInfField(SwFieldType* pTyp, const SwDBData& rDBData, sal_uLong nFmt = 0); 152 153 public: 154 // DBName 155 inline const SwDBData& GetRealDBData() { return aDBData; } 156 157 SwDBData GetDBData(SwDoc* pDoc); 158 void SetDBData(const SwDBData& rDBData); // #111840# 159 160 virtual String GetFieldName() const; 161 162 virtual sal_Bool QueryValue( com::sun::star::uno::Any& rVal, sal_uInt16 nWhich ) const; 163 virtual sal_Bool PutValue( const com::sun::star::uno::Any& rVal, sal_uInt16 nWhich ); 164 virtual sal_uInt16 GetSubType() const; 165 virtual void SetSubType(sal_uInt16 nType); 166 }; 167 168 169 /*-------------------------------------------------------------------- 170 Beschreibung: Datenbankfeld Naechster Satz 171 --------------------------------------------------------------------*/ 172 173 class SW_DLLPUBLIC SwDBNextSetFieldType : public SwFieldType 174 { 175 public: 176 SwDBNextSetFieldType(); 177 178 virtual SwFieldType* Copy() const; 179 }; 180 181 182 /*-------------------------------------------------------------------- 183 Beschreibung: Naechsten Datensatz mit Bedingung 184 --------------------------------------------------------------------*/ 185 186 class SW_DLLPUBLIC SwDBNextSetField : public SwDBNameInfField 187 { 188 String aCond; 189 sal_Bool bCondValid; 190 191 public: 192 SwDBNextSetField( SwDBNextSetFieldType*, 193 const String& rCond, const String& rDummy, const SwDBData& rDBData); 194 195 virtual String Expand() const; 196 virtual SwField* Copy() const; 197 198 void Evaluate(SwDoc*); 199 inline void SetCondValid(sal_Bool bCond); 200 inline sal_Bool IsCondValid() const; 201 202 // Condition 203 virtual const String& GetPar1() const; 204 virtual void SetPar1(const String& rStr); 205 virtual sal_Bool QueryValue( com::sun::star::uno::Any& rVal, sal_uInt16 nWhich ) const; 206 virtual sal_Bool PutValue( const com::sun::star::uno::Any& rVal, sal_uInt16 nWhich ); 207 }; 208 209 inline sal_Bool SwDBNextSetField::IsCondValid() const 210 { return bCondValid; } 211 212 inline void SwDBNextSetField::SetCondValid(sal_Bool bCond) 213 { bCondValid = bCond; } 214 215 /*-------------------------------------------------------------------- 216 Beschreibung: Datenbankfeld Naechster Satz 217 --------------------------------------------------------------------*/ 218 219 class SwDBNumSetFieldType : public SwFieldType 220 { 221 public: 222 SwDBNumSetFieldType(); 223 224 virtual SwFieldType* Copy() const; 225 }; 226 227 228 /*-------------------------------------------------------------------- 229 Beschreibung: Datensatz mit Nummer xxx 230 Die Nummer steht in nFormat 231 ! kleiner Missbrauch 232 --------------------------------------------------------------------*/ 233 234 class SwDBNumSetField : public SwDBNameInfField 235 { 236 String aCond; 237 String aPar2; 238 sal_Bool bCondValid; 239 240 public: 241 SwDBNumSetField(SwDBNumSetFieldType*, const String& rCond, const String& rDBNum, const SwDBData& rDBData); 242 243 virtual String Expand() const; 244 virtual SwField* Copy() const; 245 246 inline sal_Bool IsCondValid() const; 247 inline void SetCondValid(sal_Bool bCond); 248 void Evaluate(SwDoc*); 249 250 // Condition 251 virtual const String& GetPar1() const; 252 virtual void SetPar1(const String& rStr); 253 254 // Datensatznummer 255 virtual String GetPar2() const; 256 virtual void SetPar2(const String& rStr); 257 258 // Die Datensatznummer steht in nFormat !! 259 virtual sal_Bool QueryValue( com::sun::star::uno::Any& rVal, sal_uInt16 nWhich ) const; 260 virtual sal_Bool PutValue( const com::sun::star::uno::Any& rVal, sal_uInt16 nWhich ); 261 }; 262 263 inline sal_Bool SwDBNumSetField::IsCondValid() const 264 { return bCondValid; } 265 266 inline void SwDBNumSetField::SetCondValid(sal_Bool bCond) 267 { bCondValid = bCond; } 268 269 /*-------------------------------------------------------------------- 270 Beschreibung: Datenbankname 271 --------------------------------------------------------------------*/ 272 273 class SwDBNameFieldType : public SwFieldType 274 { 275 SwDoc *pDoc; 276 public: 277 SwDBNameFieldType(SwDoc*); 278 279 String Expand(sal_uLong) const; 280 virtual SwFieldType* Copy() const; 281 }; 282 283 /*-------------------------------------------------------------------- 284 Beschreibung: Datenbankfeld 285 --------------------------------------------------------------------*/ 286 287 class SW_DLLPUBLIC SwDBNameField : public SwDBNameInfField 288 { 289 public: 290 SwDBNameField(SwDBNameFieldType*, const SwDBData& rDBData, sal_uLong nFmt = 0); 291 292 virtual String Expand() const; 293 virtual SwField* Copy() const; 294 virtual sal_Bool QueryValue( com::sun::star::uno::Any& rVal, sal_uInt16 nWhich ) const; 295 virtual sal_Bool PutValue( const com::sun::star::uno::Any& rVal, sal_uInt16 nWhich ); 296 }; 297 298 /*-------------------------------------------------------------------- 299 Beschreibung: Datensatznummer 300 --------------------------------------------------------------------*/ 301 302 class SW_DLLPUBLIC SwDBSetNumberFieldType : public SwFieldType 303 { 304 public: 305 SwDBSetNumberFieldType(); 306 307 virtual SwFieldType* Copy() const; 308 }; 309 310 /*-------------------------------------------------------------------- 311 Beschreibung: Datenbankfeld 312 --------------------------------------------------------------------*/ 313 314 class SW_DLLPUBLIC SwDBSetNumberField : public SwDBNameInfField 315 { 316 long nNumber; 317 318 public: 319 SwDBSetNumberField(SwDBSetNumberFieldType*, const SwDBData& rDBData, sal_uLong nFmt = 0); 320 321 virtual String Expand() const; 322 virtual SwField* Copy() const; 323 void Evaluate(SwDoc*); 324 325 inline long GetSetNumber() const; 326 inline void SetSetNumber(long nNum); 327 virtual sal_Bool QueryValue( com::sun::star::uno::Any& rVal, sal_uInt16 nWhich ) const; 328 virtual sal_Bool PutValue( const com::sun::star::uno::Any& rVal, sal_uInt16 nWhich ); 329 }; 330 331 inline long SwDBSetNumberField::GetSetNumber() const 332 { return nNumber; } 333 334 inline void SwDBSetNumberField::SetSetNumber(long nNum) 335 { nNumber = nNum; } 336 337 338 #endif // SW_DBFLD_HXX 339