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