LCOV - code coverage report
Current view: top level - sw/inc - fldbas.hxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 30 0.0 %
Date: 2014-04-14 Functions: 0 24 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_FLDBAS_HXX
      20             : #define INCLUDED_SW_INC_FLDBAS_HXX
      21             : 
      22             : #include <i18nlangtag/lang.h>
      23             : #include "swdllapi.h"
      24             : #include <calbck.hxx>
      25             : #include <com/sun/star/beans/XPropertySet.hpp>
      26             : #include <com/sun/star/uno/Any.hxx>
      27             : #include <cppuhelper/weakref.hxx>
      28             : #include <vector>
      29             : #include <toxe.hxx>
      30             : class SwDoc;
      31             : class SvNumberFormatter;
      32             : 
      33             : enum RES_FIELDS
      34             : {
      35             :  /// For old documents the Field-Which IDs must be preserved !!!
      36             :     RES_FIELDS_BEGIN,
      37             :     RES_DBFLD = RES_FIELDS_BEGIN,
      38             :     RES_USERFLD,
      39             :     RES_FILENAMEFLD,
      40             :     RES_DBNAMEFLD,
      41             :     RES_DATEFLD,
      42             :     RES_TIMEFLD,
      43             :     RES_PAGENUMBERFLD,
      44             :     RES_AUTHORFLD,
      45             :     RES_CHAPTERFLD,
      46             :     RES_DOCSTATFLD,
      47             :     RES_GETEXPFLD,
      48             :     RES_SETEXPFLD,
      49             :     RES_GETREFFLD,
      50             :     RES_HIDDENTXTFLD,
      51             :     RES_POSTITFLD,
      52             :     RES_FIXDATEFLD,
      53             :     RES_FIXTIMEFLD,
      54             :     RES_REGFLD,
      55             :     RES_VARREGFLD,
      56             :     RES_SETREFFLD,
      57             :     RES_INPUTFLD,
      58             :     RES_MACROFLD,
      59             :     RES_DDEFLD,
      60             :     RES_TABLEFLD,
      61             :     RES_HIDDENPARAFLD,
      62             :     RES_DOCINFOFLD,
      63             :     RES_TEMPLNAMEFLD,
      64             :     RES_DBNEXTSETFLD,
      65             :     RES_DBNUMSETFLD,
      66             :     RES_DBSETNUMBERFLD,
      67             :     RES_EXTUSERFLD,
      68             :     RES_REFPAGESETFLD,
      69             :     RES_REFPAGEGETFLD,
      70             :     RES_INTERNETFLD,
      71             :     RES_JUMPEDITFLD,
      72             :     RES_SCRIPTFLD,
      73             :     RES_DATETIMEFLD,
      74             :     RES_AUTHORITY,  ///< Table of authorities
      75             :     RES_COMBINED_CHARS,
      76             :     RES_DROPDOWN,
      77             :     RES_FIELDS_END
      78             : };
      79             : 
      80             :  /// List of FieldTypes at UI.
      81             : enum SwFldTypesEnum
      82             : {
      83             :     TYP_BEGIN,
      84             :     TYP_DATEFLD = TYP_BEGIN,    // 0
      85             :     TYP_TIMEFLD,
      86             :     TYP_FILENAMEFLD,
      87             :     TYP_DBNAMEFLD,
      88             :     TYP_CHAPTERFLD,
      89             :     TYP_PAGENUMBERFLD,
      90             :     TYP_DOCSTATFLD,
      91             :     TYP_AUTHORFLD,
      92             :     TYP_SETFLD,
      93             :     TYP_GETFLD,
      94             :     TYP_FORMELFLD,              // 10
      95             :     TYP_HIDDENTXTFLD,
      96             :     TYP_SETREFFLD,
      97             :     TYP_GETREFFLD,
      98             :     TYP_DDEFLD,
      99             :     TYP_MACROFLD,
     100             :     TYP_INPUTFLD,
     101             :     TYP_HIDDENPARAFLD,
     102             :     TYP_DOCINFOFLD,
     103             :     TYP_DBFLD,
     104             :     TYP_USERFLD,                // 20
     105             :     TYP_POSTITFLD,
     106             :     TYP_TEMPLNAMEFLD,
     107             :     TYP_SEQFLD,
     108             :     TYP_DBNEXTSETFLD,
     109             :     TYP_DBNUMSETFLD,
     110             :     TYP_DBSETNUMBERFLD,
     111             :     TYP_CONDTXTFLD,
     112             :     TYP_NEXTPAGEFLD,
     113             :     TYP_PREVPAGEFLD,
     114             :     TYP_EXTUSERFLD,             // 30
     115             :     TYP_FIXDATEFLD,
     116             :     TYP_FIXTIMEFLD,
     117             :     TYP_SETINPFLD,
     118             :     TYP_USRINPFLD,
     119             :     TYP_SETREFPAGEFLD,
     120             :     TYP_GETREFPAGEFLD,
     121             :     TYP_INTERNETFLD,
     122             :     TYP_JUMPEDITFLD,
     123             :     TYP_SCRIPTFLD,
     124             :     TYP_AUTHORITY,              // 40
     125             :     TYP_COMBINED_CHARS,
     126             :     TYP_DROPDOWN,
     127             :     TYP_END
     128             : };
     129             : enum SwAttrFieldTYpe
     130             : {
     131             :     ATTR_NONE,
     132             :     ATTR_DATEFLD,
     133             :     ATTR_TIMEFLD,
     134             :     ATTR_PAGENUMBERFLD,
     135             :     ATTR_PAGECOOUNTFLD,
     136             :     ATTR_BOOKMARKFLD,
     137             :     ATTR_SETREFATTRFLD
     138             : };
     139             : enum SwFileNameFormat
     140             : {
     141             :     FF_BEGIN,
     142             :     FF_NAME = FF_BEGIN,
     143             :     FF_PATHNAME,
     144             :     FF_PATH,
     145             :     FF_NAME_NOEXT,
     146             :     FF_UI_NAME,
     147             :     FF_UI_RANGE,
     148             :     FF_END,
     149             :     FF_FIXED = 0x8000
     150             : };
     151             : 
     152             : enum SwVarFormat
     153             : {
     154             :     VVF_CMD         = 0x0010,   ///< Show command.
     155             :     VVF_INVISIBLE   = 0x0040,   ///< Invisible.
     156             :     VVF_XXP         = 0x0400,   ///< 1234%
     157             :     VVF_XX_XXP      = 0x0800,   ///< 1.234,56%
     158             :     VVF_CLEAR       = 0x000f,
     159             : 
     160             : // From here new formats:
     161             :     VVF_SYS         = 0x2000,   ///< Format for numbers from system.
     162             :     VVF_X           = 0x2100,   ///< 1234
     163             :     VVF_X_X         = 0x2200,   ///< 1234.5
     164             :     VVF_X_XX        = 0x2300,   ///< 1245.56
     165             :     VVF_XX_X        = 0x2400,   ///< 1.234.5
     166             :     VVF_XX_XX       = 0x2500,   ///< 1.234.56
     167             :     VVF_XX_XXX      = 0x2600,   ///< 1.234.567
     168             :     VVF_SYS_CUR     = 0x2700,   ///< Format for currency from system.
     169             :     VVF_CUR_X       = 0x2800,   ///< EUR 1234
     170             :     VVF_CUR_XX_XX   = 0x2900,   ///< EUR 1234.56 EUR 1234.00
     171             :     VVF_CUR_XX_X0   = 0x2a00,   ///< EUR 1234.56 EUR 1234.--
     172             :     VVF_X_CUR       = 0x2b00,   ///< 1234 EUR
     173             :     VVF_XX_XX_CUR   = 0x2c00,   ///< 1234.56 EUR 1234.00 EUR
     174             :     VVF_XX_X0_CUR   = 0x2d00,   ///< 1234.56 EUR 1234.-- EUR
     175             : /// Compatibility:
     176             :     VF_CMD          = VVF_CMD,
     177             :     VF_INVISIBLE    = VVF_INVISIBLE,
     178             :     VF_XXP          = VVF_XXP,
     179             :     VF_XX_XXP       = VVF_XX_XXP,
     180             :     VF_VISIBLE      = VVF_SYS,
     181             :     VF_XX           = VVF_X,
     182             :     VF_XX_XX        = VVF_XX_XX,
     183             :     VF_XX_XX_CUR    = VVF_SYS_CUR,
     184             :     VF_CLEAR        = VVF_CLEAR
     185             : 
     186             : };
     187             : 
     188             : typedef sal_uInt16 SwGetSetExpType;
     189             : namespace nsSwGetSetExpType
     190             : {
     191             :     const SwGetSetExpType GSE_STRING  = 0x0001; ///< String
     192             :     const SwGetSetExpType GSE_EXPR    = 0x0002; ///< Expression
     193             :     const SwGetSetExpType GSE_INP     = 0x0004; ///< InputField
     194             :     const SwGetSetExpType GSE_SEQ     = 0x0008; ///< Sequence
     195             :     const SwGetSetExpType GSE_FORMULA = 0x0010; ///< Formula
     196             : }
     197             : 
     198             : typedef sal_uInt16 SwExtendedSubType;
     199             : namespace nsSwExtendedSubType
     200             : {
     201             :     const SwExtendedSubType SUB_CMD         = 0x0100;   ///< Show command.
     202             :     const SwExtendedSubType SUB_INVISIBLE   = 0x0200;   ///< Invisible.
     203             :     const SwExtendedSubType SUB_OWN_FMT     = 0x0400;   ///< SwDBField: Don't accept formatting from database.
     204             : }
     205             : 
     206             : enum SwInputFieldSubType
     207             : {
     208             :     INP_TXT     = 0x01,
     209             :     INP_USR     = 0x02,
     210             :     INP_VAR     = 0x03
     211             : };
     212             : 
     213             : enum SwUserType
     214             : {
     215             :     UF_STRING   = 0x01,
     216             :     UF_EXPR     = 0x02
     217             : };
     218             : 
     219             : enum SwDateTimeSubType
     220             : {
     221             :     FIXEDFLD = 1,
     222             :     DATEFLD  = 2,
     223             :     TIMEFLD  = 4
     224             : };
     225             : 
     226             : /// General tools.
     227             : OUString  GetResult(double nVal, sal_uInt32 nNumFmt, sal_uInt16 nLang = LANGUAGE_SYSTEM);
     228             : void      SetErrorStr(const OUString& rStr);
     229             : OUString  FormatNumber(sal_uInt32 nNum, sal_uInt32 nFormat);
     230             : 
     231             : /** Instances of SwFields and those derived from it occur 0 to n times.
     232             :  For each class there is one instance of the associated type class.
     233             :  Base class of all field types is SwFieldType. */
     234             : 
     235           0 : class SW_DLLPUBLIC SwFieldType : public SwModify
     236             : {
     237             :     ::com::sun::star::uno::WeakReference<
     238             :         ::com::sun::star::beans::XPropertySet> m_wXFieldMaster;
     239             : 
     240             :     sal_uInt16 nWhich;
     241             : 
     242             :     friend void _FinitUI();     ///< In order to delete pointer!
     243             :     static  std::vector<OUString>* pFldNames;
     244             : 
     245             :     static void _GetFldName();  ///< Sets up FldNames; fldmgr.cxx!
     246             : 
     247             : protected:
     248             :     /// Single argument ctors shall be explicit.
     249             :     explicit SwFieldType( sal_uInt16 nWhichId );
     250             : 
     251             : public:
     252             : 
     253             :     SAL_DLLPRIVATE ::com::sun::star::uno::WeakReference<
     254           0 :         ::com::sun::star::beans::XPropertySet> const& GetXObject() const
     255           0 :             { return m_wXFieldMaster; }
     256           0 :     SAL_DLLPRIVATE void SetXObject(::com::sun::star::uno::Reference<
     257             :                     ::com::sun::star::beans::XPropertySet> const& xFieldMaster)
     258           0 :             { m_wXFieldMaster = xFieldMaster; }
     259             : 
     260             :     static OUString    GetTypeStr( sal_uInt16 nTypeId );
     261             : 
     262             :     /// Only in derived classes.
     263             :     virtual OUString        GetName() const;
     264             :     virtual SwFieldType*    Copy()    const = 0;
     265             :     virtual bool QueryValue( com::sun::star::uno::Any& rVal, sal_uInt16 nWhich ) const;
     266             :     virtual bool PutValue( const com::sun::star::uno::Any& rVal, sal_uInt16 nWhich );
     267             : 
     268           0 :             sal_uInt16          Which() const { return nWhich; }
     269             : 
     270             :     inline  void            UpdateFlds() const;
     271             : };
     272             : 
     273           0 : inline void SwFieldType::UpdateFlds() const
     274             : {
     275           0 :     ((SwFieldType*)this)->ModifyNotification( 0, 0 );
     276           0 : }
     277             : 
     278             : /** Base class of all fields.
     279             :  Type of field is queried via Which.
     280             :  Expanded content of field is queried via Expand(). */
     281           0 : class SW_DLLPUBLIC SwField
     282             : {
     283             : private:
     284             :     mutable OUString    m_Cache;     ///< Cached expansion (for clipboard).
     285             :     bool m_bUseFieldValueCache; /// control the usage of the cached field value
     286             : 
     287             :     sal_uInt16              nLang;   ///< Always change via SetLanguage!
     288             :     sal_Bool                bIsAutomaticLanguage;
     289             :     sal_uInt32          nFormat;
     290             : 
     291             :     SwFieldType*        pType;
     292             : 
     293             :     virtual OUString    Expand() const = 0;
     294             :     virtual SwField*    Copy() const = 0;
     295             : 
     296             : protected:
     297           0 :     void                SetFormat(sal_uInt32 nSet) {nFormat = nSet;}
     298             : 
     299             :     SwField( SwFieldType* pTyp,
     300             :              sal_uInt32 nFmt = 0,
     301             :              sal_uInt16 nLang = LANGUAGE_SYSTEM,
     302             :              bool m_bUseFieldValueCache = true );
     303             : 
     304             : public:
     305             :     virtual             ~SwField();
     306             : 
     307             :     inline SwFieldType* GetTyp() const;
     308             : 
     309             :     /// Set new type (used for copying among documents).
     310             :     virtual SwFieldType* ChgTyp( SwFieldType* );
     311             : 
     312             :     /** expand the field.
     313             :         @param  bCached     return cached field value.
     314             :         @remark     most callers should use the cached field value.
     315             :                     this is because various fields need special handing
     316             :                     (ChangeExpansion()) to return correct values, and only
     317             :                     SwTxtFormatter::NewFldPortion() sets things up properly.
     318             :         @return     the generated text (suitable for display)
     319             :       */
     320             :     OUString            ExpandField(bool const bCached, ToxAuthorityField eField = AUTH_FIELD_IDENTIFIER) const;
     321             : 
     322             :     /// @return name or content.
     323             :     virtual OUString    GetFieldName() const;
     324             : 
     325             :     SwField *           CopyField() const;
     326             : 
     327             :     /// ResId
     328           0 :     sal_uInt16              Which() const
     329             : #ifdef DBG_UTIL
     330             :         ;       // implemented in fldbas.cxx
     331             : #else
     332           0 :         { return pType->Which(); }
     333             : #endif
     334             : 
     335             :     // TYP_ID
     336             :             sal_uInt16      GetTypeId() const;
     337             :     virtual sal_uInt16      GetSubType() const;
     338             :     virtual void        SetSubType(sal_uInt16);
     339             : 
     340             :     /// Language at field position.
     341             :     inline sal_uInt16       GetLanguage() const;
     342             :     virtual void        SetLanguage(sal_uInt16 nLng);
     343             : 
     344             :     /// Query parameters for dialog and for BASIC.
     345             :     inline sal_uInt32   GetFormat() const;
     346             :     virtual OUString GetPar1() const;
     347             :     virtual OUString GetPar2() const;
     348             : 
     349             :     virtual OUString    GetFormula() const;
     350             : 
     351             :     virtual void        ChangeFormat(sal_uInt32 n);
     352             :     virtual void        SetPar1(const OUString& rStr);
     353             :     virtual void        SetPar2(const OUString& rStr);
     354             : 
     355             :     virtual bool        QueryValue( com::sun::star::uno::Any& rVal, sal_uInt16 nWhichId ) const;
     356             :     virtual bool        PutValue( const com::sun::star::uno::Any& rVal, sal_uInt16 nWhichId );
     357             : 
     358             :     /// Does the field possess an action on its ClickHandler? (e.g. INetFields, ...).
     359             :     sal_Bool            HasClickHdl() const;
     360             :     sal_Bool            IsFixed() const;
     361             : 
     362           0 :     sal_Bool                IsAutomaticLanguage() const { return bIsAutomaticLanguage;}
     363           0 :     void                SetAutomaticLanguage(sal_Bool bSet){bIsAutomaticLanguage = bSet;}
     364             : 
     365             :     virtual OUString    GetDescription() const;
     366             :     /// Is this field clickable?
     367             :     bool IsClickable() const;
     368             : };
     369             : 
     370           0 : inline SwFieldType* SwField::GetTyp() const
     371           0 :     { return pType;     }
     372             : 
     373           0 : inline sal_uInt32 SwField::GetFormat() const
     374           0 :     { return nFormat;   }
     375             : 
     376           0 : inline sal_uInt16 SwField::GetLanguage() const
     377           0 :     { return nLang;     }
     378             : 
     379             :  /// Fields containing values that have to be formated via number formatter.
     380           0 : class SwValueFieldType : public SwFieldType
     381             : {
     382             :     SwDoc*  pDoc;
     383             :     sal_Bool    bUseFormat; ///< Use number formatter.
     384             : 
     385             : protected:
     386             :     SwValueFieldType( SwDoc* pDocPtr, sal_uInt16 nWhichId );
     387             :     SwValueFieldType( const SwValueFieldType& rTyp );
     388             : 
     389             : public:
     390           0 :     inline SwDoc*   GetDoc() const                      { return pDoc; }
     391           0 :     inline void     SetDoc(SwDoc* pNewDoc)              { pDoc = pNewDoc; }
     392             : 
     393           0 :     inline sal_Bool     UseFormat() const                   { return bUseFormat; }
     394           0 :     inline void     EnableFormat(sal_Bool bFormat = sal_True)   { bUseFormat = bFormat; }
     395             : 
     396             :     OUString        ExpandValue(const double& rVal, sal_uInt32 nFmt, sal_uInt16 nLng=0) const;
     397             :     OUString        DoubleToString(const double &rVal, LanguageType eLng) const;
     398             :     OUString        DoubleToString(const double &rVal, sal_uInt32 nFmt) const;
     399             : };
     400             : 
     401             : class SW_DLLPUBLIC SwValueField : public SwField
     402             : {
     403             :     double fValue;
     404             : 
     405             : protected:
     406             :     SwValueField( SwValueFieldType* pFldType, sal_uInt32 nFmt = 0, sal_uInt16 nLang = LANGUAGE_SYSTEM, const double fVal = 0.0 );
     407             :     SwValueField( const SwValueField& rFld );
     408             : 
     409             : public:
     410             :     virtual                 ~SwValueField();
     411             : 
     412             :     virtual SwFieldType*    ChgTyp( SwFieldType* ) SAL_OVERRIDE;
     413             :     virtual void            SetLanguage(sal_uInt16 nLng) SAL_OVERRIDE;
     414             : 
     415           0 :     inline SwDoc*           GetDoc() const          { return ((SwValueFieldType*)GetTyp())->GetDoc(); }
     416             : 
     417             :     virtual double          GetValue() const;
     418             :     virtual void            SetValue( const double& rVal );
     419             : 
     420           0 :     inline OUString ExpandValue(const double& rVal, sal_uInt32 nFmt, sal_uInt16 nLng=0) const
     421           0 :         { return ((SwValueFieldType*)GetTyp())->ExpandValue(rVal, nFmt, nLng); }
     422             : 
     423             :     static sal_uInt32       GetSystemFormat(SvNumberFormatter* pFormatter, sal_uInt32 nFmt);
     424             : };
     425             : 
     426           0 : class SW_DLLPUBLIC SwFormulaField : public SwValueField
     427             : {
     428             :     OUString sFormula;
     429             : 
     430             : protected:
     431             :     SwFormulaField( SwValueFieldType* pFldType, sal_uInt32 nFmt = 0, const double fVal = 0.0 );
     432             :     SwFormulaField( const SwFormulaField& rFld );
     433             : 
     434             : public:
     435             :     virtual OUString        GetFormula() const SAL_OVERRIDE;
     436             :     void                    SetFormula(const OUString& rStr);
     437             : 
     438             :     void                    SetExpandedFormula(const OUString& rStr);
     439             :     OUString                GetExpandedFormula() const;
     440             : };
     441             : 
     442             : #endif // INCLUDED_SW_INC_FLDBAS_HXX
     443             : 
     444             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10