LCOV - code coverage report
Current view: top level - sw/inc - dbfld.hxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 36 0.0 %
Date: 2014-04-14 Functions: 0 37 0.0 %
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 INCLUDED_SW_INC_DBFLD_HXX
      20             : #define INCLUDED_SW_INC_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             :     OUString sName;          ///< only used in ::GetName() !
      38             :     OUString sColumn;
      39             :     long        nRefCnt;
      40             : 
      41             : public:
      42             : 
      43             :     SwDBFieldType(SwDoc* pDocPtr, const OUString& rColumnName, const SwDBData& rDBData);
      44             :     virtual ~SwDBFieldType();
      45             : 
      46             :     virtual OUString GetName() const SAL_OVERRIDE;
      47             :     virtual SwFieldType*  Copy() const SAL_OVERRIDE;
      48             : 
      49           0 :     inline void     AddRef() { nRefCnt++; }
      50             :     void            ReleaseRef();
      51             : 
      52           0 :     OUString        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 SAL_OVERRIDE;
      56             :     virtual bool        PutValue( const com::sun::star::uno::Any& rVal, sal_uInt16 nWhich ) SAL_OVERRIDE;
      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             :     OUString aContent;
      67             :     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 OUString    Expand() const SAL_OVERRIDE;
      74             :     virtual SwField*    Copy() const SAL_OVERRIDE;
      75             : 
      76             : public:
      77             :     SwDBField(SwDBFieldType*, sal_uLong nFmt = 0);
      78             :     virtual ~SwDBField();
      79             : 
      80             :     virtual SwFieldType*    ChgTyp( SwFieldType* ) SAL_OVERRIDE;
      81             : 
      82             :     /// Current text.
      83             :     inline  void        SetExpansion(const OUString& rStr);
      84             : 
      85             :     virtual sal_uInt16      GetSubType() const SAL_OVERRIDE;
      86             :     virtual void        SetSubType(sal_uInt16 nType) SAL_OVERRIDE;
      87             : 
      88             :     virtual OUString    GetFieldName() const SAL_OVERRIDE;
      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 OUString& 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 OUString    GetPar1() const SAL_OVERRIDE;
     109             : 
     110             :     /// access to the command string
     111             :     OUString            GetFieldCode() const { return sFieldCode;}
     112           0 :     void                SetFieldCode(const 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 SAL_OVERRIDE;
     117             :     virtual bool        PutValue( const com::sun::star::uno::Any& rVal, sal_uInt16 nWhich ) SAL_OVERRIDE;
     118             : };
     119             : 
     120           0 : inline  void SwDBField::SetExpansion(const OUString& 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 OUString        GetFieldName() const SAL_OVERRIDE;
     150             : 
     151             :     virtual bool            QueryValue( com::sun::star::uno::Any& rVal, sal_uInt16 nWhich ) const SAL_OVERRIDE;
     152             :     virtual bool            PutValue( const com::sun::star::uno::Any& rVal, sal_uInt16 nWhich ) SAL_OVERRIDE;
     153             :     virtual sal_uInt16          GetSubType() const SAL_OVERRIDE;
     154             :     virtual void            SetSubType(sal_uInt16 nType) SAL_OVERRIDE;
     155             : };
     156             : 
     157             : /*--------------------------------------------------------------------
     158             :     Database field next record.
     159             :  --------------------------------------------------------------------*/
     160             : 
     161           0 : class SW_DLLPUBLIC SwDBNextSetFieldType : public SwFieldType
     162             : {
     163             : public:
     164             :     SwDBNextSetFieldType();
     165             : 
     166             :     virtual SwFieldType*    Copy() const SAL_OVERRIDE;
     167             : };
     168             : 
     169             : /*--------------------------------------------------------------------
     170             :     Next data record with condition.
     171             :  --------------------------------------------------------------------*/
     172             : 
     173           0 : class SW_DLLPUBLIC SwDBNextSetField : public SwDBNameInfField
     174             : {
     175             :     OUString  aCond;
     176             :     bool    bCondValid;
     177             : 
     178             : public:
     179             :     SwDBNextSetField( SwDBNextSetFieldType*,
     180             :                       const OUString& rCond, const OUString& rDummy, const SwDBData& rDBData);
     181             : 
     182             :     virtual OUString        Expand() const SAL_OVERRIDE;
     183             :     virtual SwField*        Copy() const SAL_OVERRIDE;
     184             : 
     185             :     void                    Evaluate(SwDoc*);
     186             :     inline void             SetCondValid(bool bCond);
     187             :     inline bool             IsCondValid() const;
     188             : 
     189             :     // Condition
     190             :     virtual OUString    GetPar1() const SAL_OVERRIDE;
     191             :     virtual void        SetPar1(const OUString& rStr) SAL_OVERRIDE;
     192             :     virtual bool        QueryValue( com::sun::star::uno::Any& rVal, sal_uInt16 nWhich ) const SAL_OVERRIDE;
     193             :     virtual bool        PutValue( const com::sun::star::uno::Any& rVal, sal_uInt16 nWhich ) SAL_OVERRIDE;
     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           0 : class SwDBNumSetFieldType : public SwFieldType
     207             : {
     208             : public:
     209             :     SwDBNumSetFieldType();
     210             : 
     211             :     virtual SwFieldType*    Copy() const SAL_OVERRIDE;
     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             :     OUString  aCond;
     222             :     OUString  aPar2;
     223             :     bool    bCondValid;
     224             : 
     225             : public:
     226             :     SwDBNumSetField(SwDBNumSetFieldType*, const OUString& rCond, const OUString& rDBNum, const SwDBData& rDBData);
     227             : 
     228             :     virtual OUString        Expand() const SAL_OVERRIDE;
     229             :     virtual SwField*        Copy() const SAL_OVERRIDE;
     230             : 
     231             :     inline bool             IsCondValid() const;
     232             :     inline void             SetCondValid(bool bCond);
     233             :     void                    Evaluate(SwDoc*);
     234             : 
     235             :     // Condition
     236             :     virtual OUString        GetPar1() const SAL_OVERRIDE;
     237             :     virtual void            SetPar1(const OUString& rStr) SAL_OVERRIDE;
     238             : 
     239             :     // Number of data record.
     240             :     virtual OUString   GetPar2()   const SAL_OVERRIDE;
     241             :     virtual void            SetPar2(const OUString& rStr) SAL_OVERRIDE;
     242             : 
     243             :     // Number of data record is in nFormat!!
     244             :     virtual bool        QueryValue( com::sun::star::uno::Any& rVal, sal_uInt16 nWhich ) const SAL_OVERRIDE;
     245             :     virtual bool        PutValue( const com::sun::star::uno::Any& rVal, sal_uInt16 nWhich ) SAL_OVERRIDE;
     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           0 : class SwDBNameFieldType : public SwFieldType
     259             : {
     260             :         SwDoc *pDoc;
     261             : public:
     262             :     SwDBNameFieldType(SwDoc*);
     263             : 
     264             :     OUString                Expand(sal_uLong) const;
     265             :     virtual SwFieldType*    Copy() const SAL_OVERRIDE;
     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 OUString Expand() const SAL_OVERRIDE;
     278             :     virtual SwField* Copy() const SAL_OVERRIDE;
     279             :     virtual bool        QueryValue( com::sun::star::uno::Any& rVal, sal_uInt16 nWhich ) const SAL_OVERRIDE;
     280             :     virtual bool        PutValue( const com::sun::star::uno::Any& rVal, sal_uInt16 nWhich ) SAL_OVERRIDE;
     281             : };
     282             : 
     283             : /*--------------------------------------------------------------------
     284             :     Number of data record.
     285             :  --------------------------------------------------------------------*/
     286             : 
     287           0 : class SW_DLLPUBLIC SwDBSetNumberFieldType : public SwFieldType
     288             : {
     289             : public:
     290             :     SwDBSetNumberFieldType();
     291             : 
     292             :     virtual SwFieldType*    Copy() const SAL_OVERRIDE;
     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 OUString Expand() const SAL_OVERRIDE;
     307             :     virtual         SwField* Copy() const SAL_OVERRIDE;
     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 SAL_OVERRIDE;
     313             :     virtual bool        PutValue( const com::sun::star::uno::Any& rVal, sal_uInt16 nWhich ) SAL_OVERRIDE;
     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 // INCLUDED_SW_INC_DBFLD_HXX
     323             : 
     324             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10