LCOV - code coverage report
Current view: top level - libreoffice/sw/inc - dbfld.hxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 4 36 11.1 %
Date: 2012-12-27 Functions: 8 37 21.6 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      11             :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12             :  *   contributor license agreements. See the NOTICE file distributed
      13             :  *   with this work for additional information regarding copyright
      14             :  *   ownership. The ASF licenses this file to you under the Apache
      15             :  *   License, Version 2.0 (the "License"); you may not use this file
      16             :  *   except in compliance with the License. You may obtain a copy of
      17             :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18             :  */
      19             : #ifndef SW_DBFLD_HXX
      20             : #define SW_DBFLD_HXX
      21             : 
      22             : #include "swdllapi.h"
      23             : #include "fldbas.hxx"
      24             : #include "swdbdata.hxx"
      25             : 
      26             : class SwDoc;
      27             : class SwTxtFld;
      28             : class SwFrm;
      29             : 
      30             : /*--------------------------------------------------------------------
      31             :     Database field.
      32             :  --------------------------------------------------------------------*/
      33             : 
      34             : class SW_DLLPUBLIC SwDBFieldType : public SwValueFieldType
      35             : {
      36             :     SwDBData    aDBData;        //
      37             :     rtl::OUString sName;          ///< only used in ::GetName() !
      38             :     String      sColumn;
      39             :     long        nRefCnt;
      40             : 
      41             : public:
      42             : 
      43             :     SwDBFieldType(SwDoc* pDocPtr, const String& rColumnName, const SwDBData& rDBData);
      44             :     ~SwDBFieldType();
      45             : 
      46             :     virtual const rtl::OUString& GetName() const;
      47             :     virtual SwFieldType*  Copy() const;
      48             : 
      49           0 :     inline void     AddRef() { nRefCnt++; }
      50             :     void            ReleaseRef();
      51             : 
      52           0 :     const String&   GetColumnName() const {return sColumn;}
      53           0 :     const SwDBData& GetDBData() const {return aDBData;}
      54             : 
      55             :     virtual bool        QueryValue( com::sun::star::uno::Any& rVal, sal_uInt16 nWhich ) const;
      56             :     virtual bool        PutValue( const com::sun::star::uno::Any& rVal, sal_uInt16 nWhich );
      57             : };
      58             : 
      59             : /*--------------------------------------------------------------------
      60             :     Classes derived from SwFields. They overlay the expand-function.
      61             :     Content is formated according to the format (if available).
      62             :  --------------------------------------------------------------------*/
      63             : 
      64             : class SW_DLLPUBLIC SwDBField : public SwValueField
      65             : {
      66             :     rtl::OUString aContent;
      67             :     rtl::OUString sFieldCode; ///< contains Word's field code
      68             :     sal_uInt16  nSubType;
      69             :     bool    bIsInBodyTxt    : 1;
      70             :     bool    bValidValue     : 1;
      71             :     bool    bInitialized    : 1;
      72             : 
      73             :     virtual String      Expand() const;
      74             :     virtual SwField*    Copy() const;
      75             : 
      76             : public:
      77             :     SwDBField(SwDBFieldType*, sal_uLong nFmt = 0);
      78             :     virtual ~SwDBField();
      79             : 
      80             :     virtual SwFieldType*    ChgTyp( SwFieldType* );
      81             : 
      82             :     /// Current text.
      83             :     inline  void        SetExpansion(const String& rStr);
      84             : 
      85             :     virtual sal_uInt16      GetSubType() const;
      86             :     virtual void        SetSubType(sal_uInt16 nType);
      87             : 
      88             :     virtual String      GetFieldName() const;
      89             : 
      90             :     /// For calculations in expressions.
      91             :     void                ChgValue( double d, bool bVal );
      92             : 
      93             :     /// Get the evaluation via DBMgr string.
      94             :     void                Evaluate();
      95             : 
      96             :     /// Evaluation for header and footer.
      97             :     void                ChangeExpansion( const SwFrm*, const SwTxtFld* );
      98             :     void                InitContent();
      99             :     void                InitContent(const String& rExpansion);
     100             : 
     101             :     inline void         ChgBodyTxtFlag( bool bIsInBody );
     102             : 
     103           0 :     inline bool         IsInitialized() const   { return bInitialized; }
     104           0 :     inline void         ClearInitialized()      { bInitialized = false; }
     105           0 :     inline void         SetInitialized()        { bInitialized = true; }
     106             : 
     107             :     /// Get name.
     108             :     virtual const rtl::OUString& GetPar1() const;
     109             : 
     110             :     /// access to the command string
     111             :     const rtl::OUString& GetFieldCode() const { return sFieldCode;}
     112           0 :     void                SetFieldCode(const rtl::OUString& rStr) { sFieldCode = rStr; }
     113             : 
     114             :     /// DBName
     115           0 :     inline const SwDBData&  GetDBData() const { return ((SwDBFieldType*)GetTyp())->GetDBData(); }
     116             :     virtual bool        QueryValue( com::sun::star::uno::Any& rVal, sal_uInt16 nWhich ) const;
     117             :     virtual bool        PutValue( const com::sun::star::uno::Any& rVal, sal_uInt16 nWhich );
     118             : };
     119             : 
     120           0 : inline  void SwDBField::SetExpansion(const String& rStr)
     121           0 :     { aContent = rStr; }
     122             : 
     123             : /// set from UpdateExpFlds (the Node-Position is known there)
     124           0 : inline void SwDBField::ChgBodyTxtFlag( bool bIsInBody )
     125           0 :     { bIsInBodyTxt = bIsInBody; }
     126             : 
     127             : /*--------------------------------------------------------------------
     128             :     Base class for all other database fields.
     129             :  --------------------------------------------------------------------*/
     130             : 
     131           0 : class SW_DLLPUBLIC SwDBNameInfField : public SwField
     132             : {
     133             :     SwDBData    aDBData;
     134             :     sal_uInt16      nSubType;
     135             : 
     136             : protected:
     137           0 :     const SwDBData& GetDBData() const {return aDBData;}
     138           0 :     SwDBData&       GetDBData() {return aDBData;}
     139             : 
     140             :     SwDBNameInfField(SwFieldType* pTyp, const SwDBData& rDBData, sal_uLong nFmt = 0);
     141             : 
     142             : public:
     143             :     /// DBName
     144           0 :     inline const SwDBData&  GetRealDBData() { return aDBData; }
     145             : 
     146             :     SwDBData                GetDBData(SwDoc* pDoc);
     147             :     void                    SetDBData(const SwDBData& rDBData);
     148             : 
     149             :     virtual String          GetFieldName() const;
     150             : 
     151             :     virtual bool            QueryValue( com::sun::star::uno::Any& rVal, sal_uInt16 nWhich ) const;
     152             :     virtual bool            PutValue( const com::sun::star::uno::Any& rVal, sal_uInt16 nWhich );
     153             :     virtual sal_uInt16          GetSubType() const;
     154             :     virtual void            SetSubType(sal_uInt16 nType);
     155             : };
     156             : 
     157             : /*--------------------------------------------------------------------
     158             :     Database field next record.
     159             :  --------------------------------------------------------------------*/
     160             : 
     161         204 : class SW_DLLPUBLIC SwDBNextSetFieldType : public SwFieldType
     162             : {
     163             : public:
     164             :     SwDBNextSetFieldType();
     165             : 
     166             :     virtual SwFieldType*    Copy() const;
     167             : };
     168             : 
     169             : /*--------------------------------------------------------------------
     170             :     Next data record with condition.
     171             :  --------------------------------------------------------------------*/
     172             : 
     173           0 : class SW_DLLPUBLIC SwDBNextSetField : public SwDBNameInfField
     174             : {
     175             :     rtl::OUString  aCond;
     176             :     bool    bCondValid;
     177             : 
     178             : public:
     179             :     SwDBNextSetField( SwDBNextSetFieldType*,
     180             :                       const String& rCond, const String& rDummy, const SwDBData& rDBData);
     181             : 
     182             :     virtual String          Expand() const;
     183             :     virtual SwField*        Copy() const;
     184             : 
     185             :     void                    Evaluate(SwDoc*);
     186             :     inline void             SetCondValid(bool bCond);
     187             :     inline bool             IsCondValid() const;
     188             : 
     189             :     // Condition
     190             :     virtual const rtl::OUString&   GetPar1() const;
     191             :     virtual void        SetPar1(const rtl::OUString& rStr);
     192             :     virtual bool        QueryValue( com::sun::star::uno::Any& rVal, sal_uInt16 nWhich ) const;
     193             :     virtual bool        PutValue( const com::sun::star::uno::Any& rVal, sal_uInt16 nWhich );
     194             : };
     195             : 
     196           0 : inline bool SwDBNextSetField::IsCondValid() const
     197           0 :     { return bCondValid; }
     198             : 
     199           0 : inline void SwDBNextSetField::SetCondValid(bool bCond)
     200           0 :     { bCondValid = bCond; }
     201             : 
     202             : /*--------------------------------------------------------------------
     203             :     Database field next record.
     204             :  --------------------------------------------------------------------*/
     205             : 
     206         204 : class SwDBNumSetFieldType : public SwFieldType
     207             : {
     208             : public:
     209             :     SwDBNumSetFieldType();
     210             : 
     211             :     virtual SwFieldType*    Copy() const;
     212             : };
     213             : 
     214             : /*--------------------------------------------------------------------
     215             :     Data record with number xxx.
     216             :     Number is in nFormat (bit of a misuse!)
     217             :  --------------------------------------------------------------------*/
     218             : 
     219           0 : class SwDBNumSetField : public SwDBNameInfField
     220             : {
     221             :     rtl::OUString  aCond;
     222             :     String  aPar2;
     223             :     bool    bCondValid;
     224             : 
     225             : public:
     226             :     SwDBNumSetField(SwDBNumSetFieldType*, const String& rCond, const String& rDBNum, const SwDBData& rDBData);
     227             : 
     228             :     virtual String          Expand() const;
     229             :     virtual SwField*        Copy() const;
     230             : 
     231             :     inline bool             IsCondValid() const;
     232             :     inline void             SetCondValid(bool bCond);
     233             :     void                    Evaluate(SwDoc*);
     234             : 
     235             :     // Condition
     236             :     virtual const rtl::OUString&   GetPar1() const;
     237             :     virtual void            SetPar1(const rtl::OUString& rStr);
     238             : 
     239             :     // Number of data record.
     240             :     virtual rtl::OUString   GetPar2()   const;
     241             :     virtual void            SetPar2(const rtl::OUString& rStr);
     242             : 
     243             :     // Number of data record is in nFormat!!
     244             :     virtual bool        QueryValue( com::sun::star::uno::Any& rVal, sal_uInt16 nWhich ) const;
     245             :     virtual bool        PutValue( const com::sun::star::uno::Any& rVal, sal_uInt16 nWhich );
     246             : };
     247             : 
     248           0 : inline bool SwDBNumSetField::IsCondValid() const
     249           0 :     { return bCondValid; }
     250             : 
     251           0 : inline void SwDBNumSetField::SetCondValid(bool bCond)
     252           0 :     { bCondValid = bCond; }
     253             : 
     254             : /*--------------------------------------------------------------------
     255             :     Database name.
     256             :  --------------------------------------------------------------------*/
     257             : 
     258         204 : class SwDBNameFieldType : public SwFieldType
     259             : {
     260             :         SwDoc *pDoc;
     261             : public:
     262             :     SwDBNameFieldType(SwDoc*);
     263             : 
     264             :     String                  Expand(sal_uLong) const;
     265             :     virtual SwFieldType*    Copy() const;
     266             : };
     267             : 
     268             : /*--------------------------------------------------------------------
     269             :     Database field.
     270             :  --------------------------------------------------------------------*/
     271             : 
     272           0 : class SW_DLLPUBLIC SwDBNameField : public SwDBNameInfField
     273             : {
     274             : public:
     275             :     SwDBNameField(SwDBNameFieldType*, const SwDBData& rDBData, sal_uLong nFmt = 0);
     276             : 
     277             :     virtual String   Expand() const;
     278             :     virtual SwField* Copy() const;
     279             :     virtual bool        QueryValue( com::sun::star::uno::Any& rVal, sal_uInt16 nWhich ) const;
     280             :     virtual bool        PutValue( const com::sun::star::uno::Any& rVal, sal_uInt16 nWhich );
     281             : };
     282             : 
     283             : /*--------------------------------------------------------------------
     284             :     Number of data record.
     285             :  --------------------------------------------------------------------*/
     286             : 
     287         204 : class SW_DLLPUBLIC SwDBSetNumberFieldType : public SwFieldType
     288             : {
     289             : public:
     290             :     SwDBSetNumberFieldType();
     291             : 
     292             :     virtual SwFieldType*    Copy() const;
     293             : };
     294             : 
     295             : /*--------------------------------------------------------------------
     296             :     Database field.
     297             :  --------------------------------------------------------------------*/
     298             : 
     299           0 : class SW_DLLPUBLIC SwDBSetNumberField : public SwDBNameInfField
     300             : {
     301             :     long    nNumber;
     302             : 
     303             : public:
     304             :     SwDBSetNumberField(SwDBSetNumberFieldType*, const SwDBData& rDBData, sal_uLong nFmt = 0);
     305             : 
     306             :     virtual String  Expand() const;
     307             :     virtual         SwField* Copy() const;
     308             :     void            Evaluate(SwDoc*);
     309             : 
     310             :     inline long     GetSetNumber() const;
     311             :     inline void     SetSetNumber(long nNum);
     312             :     virtual bool        QueryValue( com::sun::star::uno::Any& rVal, sal_uInt16 nWhich ) const;
     313             :     virtual bool        PutValue( const com::sun::star::uno::Any& rVal, sal_uInt16 nWhich );
     314             : };
     315             : 
     316           0 : inline long SwDBSetNumberField::GetSetNumber() const
     317           0 :     { return nNumber; }
     318             : 
     319           0 : inline void SwDBSetNumberField::SetSetNumber(long nNum)
     320           0 :     { nNumber = nNum; }
     321             : 
     322             : #endif // SW_DBFLD_HXX
     323             : 
     324             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10