LCOV - code coverage report
Current view: top level - sw/inc - dbfld.hxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 13 37 35.1 %
Date: 2015-06-13 12:38:46 Functions: 15 38 39.5 %
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 SwTextField;
      28             : class SwFrm;
      29             : 
      30             : // Database field.
      31             : class SW_DLLPUBLIC SwDBFieldType : public SwValueFieldType
      32             : {
      33             :     SwDBData    aDBData;
      34             :     OUString sName;          ///< only used in ::GetName() !
      35             :     OUString sColumn;
      36             :     long        nRefCnt;
      37             : 
      38             : public:
      39             : 
      40             :     SwDBFieldType(SwDoc* pDocPtr, const OUString& rColumnName, const SwDBData& rDBData);
      41             :     virtual ~SwDBFieldType();
      42             : 
      43             :     virtual OUString GetName() const SAL_OVERRIDE;
      44             :     virtual SwFieldType*  Copy() const SAL_OVERRIDE;
      45             : 
      46         562 :     inline void     AddRef() { nRefCnt++; }
      47             :     void            ReleaseRef();
      48             : 
      49         551 :     OUString        GetColumnName() const {return sColumn;}
      50         239 :     const SwDBData& GetDBData() const {return aDBData;}
      51             : 
      52             :     virtual bool        QueryValue( com::sun::star::uno::Any& rVal, sal_uInt16 nWhich ) const SAL_OVERRIDE;
      53             :     virtual bool        PutValue( const com::sun::star::uno::Any& rVal, sal_uInt16 nWhich ) SAL_OVERRIDE;
      54             : };
      55             : 
      56             : // Classes derived from SwFields. They overlay the expand-function.
      57             : // Content is formatted according to the format (if available).
      58             : class SW_DLLPUBLIC SwDBField : public SwValueField
      59             : {
      60             :     OUString aContent;
      61             :     OUString sFieldCode; ///< contains Word's field code
      62             :     sal_uInt16  nSubType;
      63             :     bool    bIsInBodyText    : 1;
      64             :     bool    bValidValue     : 1;
      65             :     bool    bInitialized    : 1;
      66             : 
      67             :     virtual OUString    Expand() const SAL_OVERRIDE;
      68             :     virtual SwField*    Copy() const SAL_OVERRIDE;
      69             : 
      70             : public:
      71             :     SwDBField(SwDBFieldType*, sal_uLong nFormat = 0);
      72             :     virtual ~SwDBField();
      73             : 
      74             :     virtual SwFieldType*    ChgTyp( SwFieldType* ) SAL_OVERRIDE;
      75             : 
      76             :     /// Current text.
      77             :     inline  void        SetExpansion(const OUString& rStr);
      78             : 
      79             :     virtual sal_uInt16      GetSubType() const SAL_OVERRIDE;
      80             :     virtual void        SetSubType(sal_uInt16 nType) SAL_OVERRIDE;
      81             : 
      82             :     virtual OUString    GetFieldName() const SAL_OVERRIDE;
      83             : 
      84             :     /// For calculations in expressions.
      85             :     void                ChgValue( double d, bool bVal );
      86             : 
      87             :     /// Get the evaluation via DBManager string.
      88             :     void                Evaluate();
      89             : 
      90             :     /// Evaluation for header and footer.
      91             :     void                ChangeExpansion( const SwFrm*, const SwTextField* );
      92             :     void                InitContent();
      93             :     void                InitContent(const OUString& rExpansion);
      94             : 
      95             :     inline void         ChgBodyTextFlag( bool bIsInBody );
      96             : 
      97         521 :     inline bool         IsInitialized() const   { return bInitialized; }
      98           0 :     inline void         ClearInitialized()      { bInitialized = false; }
      99           0 :     inline void         SetInitialized()        { bInitialized = true; }
     100             : 
     101             :     /// Get name.
     102             :     virtual OUString    GetPar1() const SAL_OVERRIDE;
     103             : 
     104             :     /// access to the command string
     105             :     OUString            GetFieldCode() const { return sFieldCode;}
     106           0 :     void                SetFieldCode(const OUString& rStr) { sFieldCode = rStr; }
     107             : 
     108             :     /// DBName
     109         236 :     inline const SwDBData&  GetDBData() const { return static_cast<SwDBFieldType*>(GetTyp())->GetDBData(); }
     110             :     virtual bool        QueryValue( com::sun::star::uno::Any& rVal, sal_uInt16 nWhich ) const SAL_OVERRIDE;
     111             :     virtual bool        PutValue( const com::sun::star::uno::Any& rVal, sal_uInt16 nWhich ) SAL_OVERRIDE;
     112             : 
     113             :     static bool FormatValue( SvNumberFormatter* pDocFormatter, OUString &aString, sal_uInt32 nFormat,
     114             :                              double &aNumber, sal_Int32 nColumnType, SwDBField *pField = NULL );
     115             : };
     116             : 
     117          72 : inline  void SwDBField::SetExpansion(const OUString& rStr)
     118          72 :     { aContent = rStr; }
     119             : 
     120             : /// set from UpdateExpFields (the Node-Position is known there)
     121         301 : inline void SwDBField::ChgBodyTextFlag( bool bIsInBody )
     122         301 :     { bIsInBodyText = bIsInBody; }
     123             : 
     124             : // Base class for all other database fields.
     125           0 : class SW_DLLPUBLIC SwDBNameInfField : public SwField
     126             : {
     127             :     SwDBData        aDBData;
     128             :     sal_uInt16      nSubType;
     129             : 
     130             : protected:
     131           0 :     const SwDBData& GetDBData() const {return aDBData;}
     132           0 :     SwDBData&       GetDBData() {return aDBData;}
     133             : 
     134             :     SwDBNameInfField(SwFieldType* pTyp, const SwDBData& rDBData, sal_uLong nFormat = 0);
     135             : 
     136             : public:
     137             :     /// DBName
     138           0 :     inline const SwDBData&  GetRealDBData() const { return aDBData; }
     139           0 :     inline SwDBData&        GetRealDBData() { return aDBData; }
     140             : 
     141             :     SwDBData                GetDBData(SwDoc* pDoc);
     142             :     void                    SetDBData(const SwDBData& rDBData);
     143             : 
     144             :     virtual OUString        GetFieldName() const SAL_OVERRIDE;
     145             : 
     146             :     virtual bool            QueryValue( com::sun::star::uno::Any& rVal, sal_uInt16 nWhich ) const SAL_OVERRIDE;
     147             :     virtual bool            PutValue( const com::sun::star::uno::Any& rVal, sal_uInt16 nWhich ) SAL_OVERRIDE;
     148             :     virtual sal_uInt16      GetSubType() const SAL_OVERRIDE;
     149             :     virtual void            SetSubType(sal_uInt16 nType) SAL_OVERRIDE;
     150             : };
     151             : 
     152             : // Database field next record.
     153        5898 : class SW_DLLPUBLIC SwDBNextSetFieldType : public SwFieldType
     154             : {
     155             : public:
     156             :     SwDBNextSetFieldType();
     157             : 
     158             :     virtual SwFieldType*    Copy() const SAL_OVERRIDE;
     159             : };
     160             : 
     161             : // Next data record with condition.
     162           0 : class SW_DLLPUBLIC SwDBNextSetField : public SwDBNameInfField
     163             : {
     164             :     OUString  aCond;
     165             :     bool    bCondValid;
     166             : 
     167             : public:
     168             :     SwDBNextSetField( SwDBNextSetFieldType*,
     169             :                       const OUString& rCond, const OUString& rDummy, const SwDBData& rDBData);
     170             : 
     171             :     virtual OUString        Expand() const SAL_OVERRIDE;
     172             :     virtual SwField*        Copy() const SAL_OVERRIDE;
     173             : 
     174             :     void                    Evaluate(SwDoc*);
     175             :     inline void             SetCondValid(bool bCond);
     176             :     inline bool             IsCondValid() const;
     177             : 
     178             :     // Condition
     179             :     virtual OUString    GetPar1() const SAL_OVERRIDE;
     180             :     virtual void        SetPar1(const OUString& rStr) SAL_OVERRIDE;
     181             :     virtual bool        QueryValue( com::sun::star::uno::Any& rVal, sal_uInt16 nWhich ) const SAL_OVERRIDE;
     182             :     virtual bool        PutValue( const com::sun::star::uno::Any& rVal, sal_uInt16 nWhich ) SAL_OVERRIDE;
     183             : };
     184             : 
     185           0 : inline bool SwDBNextSetField::IsCondValid() const
     186           0 :     { return bCondValid; }
     187             : 
     188           0 : inline void SwDBNextSetField::SetCondValid(bool bCond)
     189           0 :     { bCondValid = bCond; }
     190             : 
     191             : // Database field next record.
     192        5898 : class SwDBNumSetFieldType : public SwFieldType
     193             : {
     194             : public:
     195             :     SwDBNumSetFieldType();
     196             : 
     197             :     virtual SwFieldType*    Copy() const SAL_OVERRIDE;
     198             : };
     199             : 
     200             : // Data record with number xxx.
     201             : // Number is in nFormat (bit of a misuse!)
     202           0 : class SwDBNumSetField : public SwDBNameInfField
     203             : {
     204             :     OUString  aCond;
     205             :     OUString  aPar2;
     206             :     bool    bCondValid;
     207             : 
     208             : public:
     209             :     SwDBNumSetField(SwDBNumSetFieldType*, const OUString& rCond, const OUString& rDBNum, const SwDBData& rDBData);
     210             : 
     211             :     virtual OUString        Expand() const SAL_OVERRIDE;
     212             :     virtual SwField*        Copy() const SAL_OVERRIDE;
     213             : 
     214             :     inline bool             IsCondValid() const;
     215             :     inline void             SetCondValid(bool bCond);
     216             :     void                    Evaluate(SwDoc*);
     217             : 
     218             :     // Condition
     219             :     virtual OUString        GetPar1() const SAL_OVERRIDE;
     220             :     virtual void            SetPar1(const OUString& rStr) SAL_OVERRIDE;
     221             : 
     222             :     // Number of data record.
     223             :     virtual OUString   GetPar2()   const SAL_OVERRIDE;
     224             :     virtual void            SetPar2(const OUString& rStr) SAL_OVERRIDE;
     225             : 
     226             :     // Number of data record is in nFormat!!
     227             :     virtual bool        QueryValue( com::sun::star::uno::Any& rVal, sal_uInt16 nWhich ) const SAL_OVERRIDE;
     228             :     virtual bool        PutValue( const com::sun::star::uno::Any& rVal, sal_uInt16 nWhich ) SAL_OVERRIDE;
     229             : };
     230             : 
     231           0 : inline bool SwDBNumSetField::IsCondValid() const
     232           0 :     { return bCondValid; }
     233             : 
     234           0 : inline void SwDBNumSetField::SetCondValid(bool bCond)
     235           0 :     { bCondValid = bCond; }
     236             : 
     237             : // Database name.
     238        5898 : class SwDBNameFieldType : public SwFieldType
     239             : {
     240             :         SwDoc *pDoc;
     241             : public:
     242             :     SwDBNameFieldType(SwDoc*);
     243             : 
     244             :     OUString                Expand(sal_uLong) const;
     245             :     virtual SwFieldType*    Copy() const SAL_OVERRIDE;
     246             : };
     247             : 
     248             : // Database field.
     249           0 : class SW_DLLPUBLIC SwDBNameField : public SwDBNameInfField
     250             : {
     251             : public:
     252             :     SwDBNameField(SwDBNameFieldType*, const SwDBData& rDBData, sal_uLong nFormat = 0);
     253             : 
     254             :     virtual OUString Expand() const SAL_OVERRIDE;
     255             :     virtual SwField* Copy() const SAL_OVERRIDE;
     256             :     virtual bool        QueryValue( com::sun::star::uno::Any& rVal, sal_uInt16 nWhich ) const SAL_OVERRIDE;
     257             :     virtual bool        PutValue( const com::sun::star::uno::Any& rVal, sal_uInt16 nWhich ) SAL_OVERRIDE;
     258             : };
     259             : 
     260             : // Number of data record.
     261        5898 : class SW_DLLPUBLIC SwDBSetNumberFieldType : public SwFieldType
     262             : {
     263             : public:
     264             :     SwDBSetNumberFieldType();
     265             : 
     266             :     virtual SwFieldType*    Copy() const SAL_OVERRIDE;
     267             : };
     268             : 
     269             : // Database field.
     270           0 : class SW_DLLPUBLIC SwDBSetNumberField : public SwDBNameInfField
     271             : {
     272             :     long    nNumber;
     273             : public:
     274             :     SwDBSetNumberField(SwDBSetNumberFieldType*, const SwDBData& rDBData, sal_uLong nFormat = 0);
     275             : 
     276             :     virtual OUString Expand() const SAL_OVERRIDE;
     277             :     virtual         SwField* Copy() const SAL_OVERRIDE;
     278             :     void            Evaluate(SwDoc*);
     279             : 
     280             :     inline long     GetSetNumber() const;
     281             :     inline void     SetSetNumber(long nNum);
     282             :     virtual bool        QueryValue( com::sun::star::uno::Any& rVal, sal_uInt16 nWhich ) const SAL_OVERRIDE;
     283             :     virtual bool        PutValue( const com::sun::star::uno::Any& rVal, sal_uInt16 nWhich ) SAL_OVERRIDE;
     284             : };
     285             : 
     286           0 : inline long SwDBSetNumberField::GetSetNumber() const
     287           0 :     { return nNumber; }
     288             : 
     289           0 : inline void SwDBSetNumberField::SetSetNumber(long nNum)
     290           0 :     { nNumber = nNum; }
     291             : 
     292             : #endif // INCLUDED_SW_INC_DBFLD_HXX
     293             : 
     294             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11