LCOV - code coverage report
Current view: top level - sw/inc - expfld.hxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 29 65 44.6 %
Date: 2012-08-25 Functions: 26 51 51.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 15 36 41.7 %

           Branch data     Line data    Source code
       1                 :            : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2                 :            : /*************************************************************************
       3                 :            :  *
       4                 :            :  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
       5                 :            :  *
       6                 :            :  * Copyright 2000, 2010 Oracle and/or its affiliates.
       7                 :            :  *
       8                 :            :  * OpenOffice.org - a multi-platform office productivity suite
       9                 :            :  *
      10                 :            :  * This file is part of OpenOffice.org.
      11                 :            :  *
      12                 :            :  * OpenOffice.org is free software: you can redistribute it and/or modify
      13                 :            :  * it under the terms of the GNU Lesser General Public License version 3
      14                 :            :  * only, as published by the Free Software Foundation.
      15                 :            :  *
      16                 :            :  * OpenOffice.org is distributed in the hope that it will be useful,
      17                 :            :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      18                 :            :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      19                 :            :  * GNU Lesser General Public License version 3 for more details
      20                 :            :  * (a copy is included in the LICENSE file that accompanied this code).
      21                 :            :  *
      22                 :            :  * You should have received a copy of the GNU Lesser General Public License
      23                 :            :  * version 3 along with OpenOffice.org.  If not, see
      24                 :            :  * <http://www.openoffice.org/license.html>
      25                 :            :  * for a copy of the LGPLv3 License.
      26                 :            :  *
      27                 :            :  ************************************************************************/
      28                 :            : #ifndef SW_EXPFLD_HXX
      29                 :            : #define SW_EXPFLD_HXX
      30                 :            : 
      31                 :            : #include "swdllapi.h"
      32                 :            : #include <fldbas.hxx>
      33                 :            : #include <cellfml.hxx>
      34                 :            : #include <set>
      35                 :            : #include <vector>
      36                 :            : 
      37                 :            : class SfxPoolItem;
      38                 :            : class SwTxtNode;
      39                 :            : class SwFrm;
      40                 :            : struct SwPosition;
      41                 :            : class SwTxtFld;
      42                 :            : class SwDoc;
      43                 :            : class SwFmtFld;
      44                 :            : class _SetGetExpFlds;
      45                 :            : class SwEditShell;
      46                 :            : 
      47                 :            : // Forward declaration: get "BodyTxtNode" for exp.fld in Fly's headers/footers/footnotes.
      48                 :            : const SwTxtNode* GetBodyTxtNode( const SwDoc& pDoc, SwPosition& rPos,
      49                 :            :                                  const SwFrm& rFrm );
      50                 :            : 
      51                 :            : void ReplacePoint(String& sTmpName, sal_Bool bWithCommandType = sal_False);
      52                 :            : 
      53                 :          0 : struct _SeqFldLstElem
      54                 :            : {
      55                 :            :     String sDlgEntry;
      56                 :            :     sal_uInt16 nSeqNo;
      57                 :            : 
      58                 :          0 :     _SeqFldLstElem( const String& rStr, sal_uInt16 nNo )
      59                 :          0 :         : sDlgEntry( rStr ), nSeqNo( nNo )
      60                 :          0 :     {}
      61                 :            : };
      62                 :            : 
      63                 :          0 : class SW_DLLPUBLIC SwSeqFldList
      64                 :            : {
      65                 :            :     std::vector<_SeqFldLstElem*> maData;
      66                 :            : public:
      67                 :          0 :     ~SwSeqFldList()
      68                 :          0 :     {
      69                 :          0 :         for( std::vector<_SeqFldLstElem*>::const_iterator it = maData.begin(); it != maData.end(); ++it )
      70                 :          0 :             delete *it;
      71                 :          0 :     }
      72                 :            : 
      73                 :            :     bool InsertSort(_SeqFldLstElem* pNew);
      74                 :            :     bool SeekEntry(const _SeqFldLstElem& rNew, sal_uInt16* pPos) const;
      75                 :            : 
      76                 :          0 :     sal_uInt16 Count() { return maData.size(); }
      77                 :          0 :     _SeqFldLstElem* operator[](sal_uInt16 nIndex) { return maData[nIndex]; }
      78                 :            :     const _SeqFldLstElem* operator[](sal_uInt16 nIndex) const { return maData[nIndex]; }
      79                 :          0 :     void Clear() { maData.clear(); }
      80                 :            : };
      81                 :            : 
      82         [ -  + ]:       2916 : class SwGetExpFieldType : public SwValueFieldType
      83                 :            : {
      84                 :            : public:
      85                 :            :         SwGetExpFieldType(SwDoc* pDoc);
      86                 :            :         virtual SwFieldType*    Copy() const;
      87                 :            : 
      88                 :            :         // Overlay, because get-field cannot be changed and therefore
      89                 :            :         // does not need to be updated. Update at changing of set-values!
      90                 :            : protected:
      91                 :            :    virtual void Modify( const SfxPoolItem* pOld, const SfxPoolItem *pNew );
      92                 :            : };
      93                 :            : 
      94 [ +  - ][ -  + ]:         30 : class SW_DLLPUBLIC SwGetExpField : public SwFormulaField
      95                 :            : {
      96                 :            :     String          sExpand;
      97                 :            :     sal_Bool            bIsInBodyTxt;
      98                 :            :     sal_uInt16          nSubType;
      99                 :            : 
     100                 :            :     bool            bLateInitialization; // #i82544#
     101                 :            : 
     102                 :            :     virtual String              Expand() const;
     103                 :            :     virtual SwField*            Copy() const;
     104                 :            : 
     105                 :            : public:
     106                 :            :     SwGetExpField( SwGetExpFieldType*, const String& rFormel,
     107                 :            :                    sal_uInt16 nSubType = nsSwGetSetExpType::GSE_EXPR, sal_uLong nFmt = 0);
     108                 :            : 
     109                 :            :     virtual void                SetValue( const double& rVal );
     110                 :            :     virtual void                SetLanguage(sal_uInt16 nLng);
     111                 :            : 
     112                 :            :     inline const String&        GetExpStr() const;
     113                 :            :     inline void                 ChgExpStr(const String& rExpand);
     114                 :            : 
     115                 :            :     // Called by formating.
     116                 :            :     inline sal_Bool                 IsInBodyTxt() const;
     117                 :            : 
     118                 :            :     // Set by UpdateExpFlds where node position is known.
     119                 :            :     inline void                 ChgBodyTxtFlag( sal_Bool bIsInBody );
     120                 :            : 
     121                 :            :     // For fields in header/footer/footnotes/flys:
     122                 :            :     // Only called by formating!!
     123                 :            :     void                        ChangeExpansion( const SwFrm&, const SwTxtFld& );
     124                 :            : 
     125                 :            :     virtual String      GetFieldName() const;
     126                 :            : 
     127                 :            :     // Change formula.
     128                 :            :     virtual rtl::OUString GetPar2() const;
     129                 :            :     virtual void        SetPar2(const rtl::OUString& rStr);
     130                 :            : 
     131                 :            :     virtual sal_uInt16  GetSubType() const;
     132                 :            :     virtual void        SetSubType(sal_uInt16 nType);
     133                 :            :     virtual bool        QueryValue( com::sun::star::uno::Any& rVal, sal_uInt16 nWhich ) const;
     134                 :            :     virtual bool        PutValue( const com::sun::star::uno::Any& rVal, sal_uInt16 nWhich );
     135                 :            : 
     136                 :            :     static sal_uInt16   GetReferenceTextPos( const SwFmtFld& rFmt, SwDoc& rDoc, unsigned nHint = 0);
     137                 :            :     // #i82544#
     138                 :          0 :     void                SetLateInitialization() { bLateInitialization = true;}
     139                 :            : };
     140                 :            : 
     141                 :          3 : inline void SwGetExpField::ChgExpStr(const String& rExpand)
     142                 :          3 :     { sExpand = rExpand;}
     143                 :            : 
     144                 :          3 : inline const String& SwGetExpField::GetExpStr() const
     145                 :          3 :     { return sExpand;   }
     146                 :            : 
     147                 :            : // Called by formating.
     148                 :          3 : inline sal_Bool SwGetExpField::IsInBodyTxt() const
     149                 :          3 :     { return bIsInBodyTxt; }
     150                 :            : 
     151                 :            : // Set by UpdateExpFlds where node position is known.
     152                 :          0 : inline void SwGetExpField::ChgBodyTxtFlag( sal_Bool bIsInBody )
     153                 :          0 :     { bIsInBodyTxt = bIsInBody; }
     154                 :            : 
     155                 :            : class SwSetExpField;
     156                 :            : 
     157 [ +  - ][ -  + ]:      11673 : class SW_DLLPUBLIC SwSetExpFieldType : public SwValueFieldType
     158                 :            : {
     159                 :            :     rtl::OUString sName;
     160                 :            :     const SwNode* pOutlChgNd;
     161                 :            :     String      sDelim;
     162                 :            :     sal_uInt16      nType;
     163                 :            :     sal_uInt8       nLevel;
     164                 :            :     sal_Bool        bDeleted;
     165                 :            : 
     166                 :            : protected:
     167                 :            :    virtual void Modify( const SfxPoolItem* pOld, const SfxPoolItem *pNew );
     168                 :            : 
     169                 :            : public:
     170                 :            :     SwSetExpFieldType( SwDoc* pDoc, const String& rName,
     171                 :            :                         sal_uInt16 nType = nsSwGetSetExpType::GSE_EXPR );
     172                 :            :     virtual SwFieldType*    Copy() const;
     173                 :            :     virtual const rtl::OUString&   GetName() const;
     174                 :            : 
     175                 :            :     inline void             SetType(sal_uInt16 nTyp);
     176                 :            :     inline sal_uInt16       GetType() const;
     177                 :            : 
     178                 :            :     void                    SetSeqFormat(sal_uLong nFormat);
     179                 :            :     sal_uLong               GetSeqFormat();
     180                 :            : 
     181                 :          6 :     sal_Bool                IsDeleted() const       { return bDeleted; }
     182                 :          0 :     void                    SetDeleted( sal_Bool b )    { bDeleted = b; }
     183                 :            : 
     184                 :            :     // Overlay, because set-field takes care for its being updated by itself.
     185                 :            :     inline const rtl::OUString& GetSetRefName() const;
     186                 :            : 
     187                 :            :     sal_uInt16 SetSeqRefNo( SwSetExpField& rFld );
     188                 :            : 
     189                 :            :     sal_uInt16 GetSeqFldList( SwSeqFldList& rList );
     190                 :            :     String MakeSeqName( sal_uInt16 nSeqNo );
     191                 :            : 
     192                 :            :     // Number sequence fields chapterwise if required.
     193                 :          0 :     const String& GetDelimiter() const      { return sDelim; }
     194                 :          0 :     void SetDelimiter( const String& s )    { sDelim = s; }
     195                 :          0 :     sal_uInt8 GetOutlineLvl() const                 { return nLevel; }
     196                 :        252 :     void SetOutlineLvl( sal_uInt8 n )           { nLevel = n; }
     197                 :            :     void SetChapter( SwSetExpField& rFld, const SwNode& rNd );
     198                 :            : 
     199                 :            :     // Member only for SwDoc::UpdateExpFld.
     200                 :            :     // It is needed only at runtime of sequence field types!
     201                 :          0 :     const SwNode* GetOutlineChgNd() const   { return pOutlChgNd; }
     202                 :         36 :     void SetOutlineChgNd( const SwNode* p ) { pOutlChgNd = p; }
     203                 :            : 
     204                 :            :     virtual bool        QueryValue( com::sun::star::uno::Any& rVal, sal_uInt16 nWhich ) const;
     205                 :            :     virtual bool        PutValue( const com::sun::star::uno::Any& rVal, sal_uInt16 nWhich );
     206                 :            : };
     207                 :            : 
     208                 :         18 : inline void SwSetExpFieldType::SetType( sal_uInt16 nTyp )
     209                 :            : {
     210                 :         18 :         nType = nTyp;
     211                 :         18 :         EnableFormat( !(nType & (nsSwGetSetExpType::GSE_SEQ|nsSwGetSetExpType::GSE_STRING)));
     212                 :         18 : }
     213                 :            : 
     214                 :        378 : inline sal_uInt16 SwSetExpFieldType::GetType() const
     215                 :        378 :     { return nType;   }
     216                 :            : 
     217                 :          0 : inline const rtl::OUString& SwSetExpFieldType::GetSetRefName() const
     218                 :          0 :     { return sName; }
     219                 :            : 
     220                 :            : 
     221 [ +  - ][ +  - ]:         30 : class SW_DLLPUBLIC SwSetExpField : public SwFormulaField
         [ +  - ][ -  + ]
     222                 :            : {
     223                 :            :     String          sExpand;
     224                 :            :     String          aPText;
     225                 :            :     String          aSeqText;
     226                 :            :     sal_Bool            bInput;
     227                 :            :     sal_uInt16          nSeqNo;
     228                 :            :     sal_uInt16          nSubType;
     229                 :            : 
     230                 :            :     virtual String              Expand() const;
     231                 :            :     virtual SwField*            Copy() const;
     232                 :            : 
     233                 :            : public:
     234                 :            :     SwSetExpField(SwSetExpFieldType*, const String& rFormel, sal_uLong nFmt = 0);
     235                 :            : 
     236                 :            :     virtual void                SetValue( const double& rVal );
     237                 :            : 
     238                 :            :     inline const String&        GetExpStr() const;
     239                 :            : 
     240                 :            :     inline void                 ChgExpStr( const String& rExpand );
     241                 :            : 
     242                 :            :     inline void                 SetPromptText(const String& rStr);
     243                 :            :     inline const                String& GetPromptText() const;
     244                 :            : 
     245                 :            :     inline void                 SetInputFlag(sal_Bool bInp);
     246                 :            :     inline sal_Bool                 GetInputFlag() const;
     247                 :            : 
     248                 :            :     virtual String              GetFieldName() const;
     249                 :            : 
     250                 :            :     virtual sal_uInt16              GetSubType() const;
     251                 :            :     virtual void                SetSubType(sal_uInt16 nType);
     252                 :            : 
     253                 :            :     inline sal_Bool                 IsSequenceFld() const;
     254                 :            : 
     255                 :            :     // Logical number, sequence fields.
     256                 :          3 :     inline void                 SetSeqNumber( sal_uInt16 n )    { nSeqNo = n; }
     257                 :          0 :     inline sal_uInt16           GetSeqNumber() const        { return nSeqNo; }
     258                 :            : 
     259                 :            :     // Query name only.
     260                 :            :     virtual const rtl::OUString& GetPar1()   const;
     261                 :            : 
     262                 :            :     // Query formula.
     263                 :            :     virtual rtl::OUString       GetPar2()   const;
     264                 :            :     virtual void                SetPar2(const rtl::OUString& rStr);
     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                 :            : 
     269                 :          0 : inline const String& SwSetExpField::GetExpStr() const
     270                 :          0 :     { return sExpand;       }
     271                 :            : 
     272                 :          0 : inline void SwSetExpField::ChgExpStr( const String& rExpand )
     273                 :          0 :     { sExpand = rExpand;    }
     274                 :            : 
     275                 :          3 : inline void  SwSetExpField::SetPromptText(const String& rStr)
     276                 :          3 :     { aPText = rStr;        }
     277                 :            : 
     278                 :          0 : inline const String& SwSetExpField::GetPromptText() const
     279                 :          0 :     { return aPText;        }
     280                 :            : 
     281                 :          3 : inline void SwSetExpField::SetInputFlag(sal_Bool bInp)
     282                 :          3 :     { bInput = bInp; }
     283                 :            : 
     284                 :          0 : inline sal_Bool SwSetExpField::GetInputFlag() const
     285                 :          0 :     { return bInput; }
     286                 :            : 
     287                 :         15 : inline sal_Bool SwSetExpField::IsSequenceFld() const
     288                 :         15 :     { return 0 != (nsSwGetSetExpType::GSE_SEQ & ((SwSetExpFieldType*)GetTyp())->GetType()); }
     289                 :            : 
     290                 :            : 
     291         [ -  + ]:       2916 : class SwInputFieldType : public SwFieldType
     292                 :            : {
     293                 :            :     SwDoc* pDoc;
     294                 :            : public:
     295                 :            :     SwInputFieldType( SwDoc* pDoc );
     296                 :            : 
     297                 :            :     virtual SwFieldType* Copy() const;
     298                 :            : 
     299                 :          0 :     SwDoc* GetDoc() const { return pDoc; }
     300                 :            : };
     301                 :            : 
     302                 :            : 
     303 [ +  - ][ +  - ]:         28 : class SW_DLLPUBLIC SwInputField : public SwField
         [ +  - ][ -  + ]
     304                 :            : {
     305                 :            :     rtl::OUString aContent;
     306                 :            :     String  aPText;
     307                 :            :     String  aHelp;
     308                 :            :     String  aToolTip;
     309                 :            :     sal_uInt16  nSubType;
     310                 :            : 
     311                 :            :     virtual String          Expand() const;
     312                 :            :     virtual SwField*        Copy() const;
     313                 :            : 
     314                 :            : public:
     315                 :            :     // Direct input via dialog; delete old value.
     316                 :            :     SwInputField(SwInputFieldType*, const String& rContent ,
     317                 :            :                  const String& rPrompt, sal_uInt16 nSubType = 0,
     318                 :            :                  sal_uLong nFmt = 0);
     319                 :            : 
     320                 :            :     virtual String          GetFieldName() const;
     321                 :            : 
     322                 :            :     // Content
     323                 :            :     virtual const rtl::OUString&   GetPar1() const;
     324                 :            :     virtual void            SetPar1(const rtl::OUString& rStr);
     325                 :            : 
     326                 :            :     // aPromptText
     327                 :            :     virtual rtl::OUString   GetPar2() const;
     328                 :            :     virtual void            SetPar2(const rtl::OUString& rStr);
     329                 :            : 
     330                 :            :     virtual String          GetHelp() const;
     331                 :            :     virtual void            SetHelp(const String & rStr);
     332                 :            : 
     333                 :            :     virtual String          GetToolTip() const;
     334                 :            :     virtual void            SetToolTip(const String & rStr);
     335                 :            : 
     336                 :            :     virtual sal_Bool            isFormField() const;
     337                 :            : 
     338                 :            :     virtual sal_uInt16          GetSubType() const;
     339                 :            :     virtual void            SetSubType(sal_uInt16 nSub);
     340                 :            :     virtual bool        QueryValue( com::sun::star::uno::Any& rVal, sal_uInt16 nWhich ) const;
     341                 :            :     virtual bool        PutValue( const com::sun::star::uno::Any& rVal, sal_uInt16 nWhich );
     342                 :            : };
     343                 :            : 
     344                 :            : /*--------------------------------------------------------------------
     345                 :            :     Description: Sorted list of input fields and DropDown fields
     346                 :            :  --------------------------------------------------------------------*/
     347                 :            : 
     348                 :            : class SwInputFieldList
     349                 :            : {
     350                 :            : public:
     351                 :            :     SwInputFieldList( SwEditShell* pShell, sal_Bool bBuildTmpLst = sal_False );
     352                 :            :     ~SwInputFieldList();
     353                 :            : 
     354                 :            :     sal_uInt16      Count() const;
     355                 :            :     SwField*    GetField(sal_uInt16 nId);
     356                 :            : 
     357                 :            :     void        GotoFieldPos(sal_uInt16 nId);
     358                 :            :     void        PushCrsr();
     359                 :            :     void        PopCrsr();
     360                 :            : 
     361                 :            :     // Put all that are new into SortLst for updating. Returns count.
     362                 :            :     // (For Glossary: only update its input-fields).
     363                 :            :     // Compare TmpLst with current fields.
     364                 :            :     sal_uInt16      BuildSortLst();
     365                 :            : 
     366                 :            :     void        RemoveUnselectedFlds();
     367                 :            : 
     368                 :            : private:
     369                 :            :     SwEditShell*              pSh;
     370                 :            :     _SetGetExpFlds*           pSrtLst;
     371                 :            :     std::set<const SwTxtFld*> aTmpLst;
     372                 :            : };
     373                 :            : 
     374                 :            : // Implementation in tblcalc.cxx.
     375         [ -  + ]:       2916 : class SwTblFieldType : public SwValueFieldType
     376                 :            : {
     377                 :            : public:
     378                 :            :     SwTblFieldType(SwDoc* pDocPtr);
     379                 :            :     virtual SwFieldType* Copy() const;
     380                 :            : };
     381                 :            : 
     382                 :            : 
     383 [ #  # ][ #  # ]:          0 : class SwTblField : public SwValueField, public SwTableFormula
                 [ #  # ]
     384                 :            : {
     385                 :            :     String      sExpand;
     386                 :            :     sal_uInt16      nSubType;
     387                 :            : 
     388                 :            :     virtual String      Expand() const;
     389                 :            :     virtual SwField*    Copy() const;
     390                 :            : 
     391                 :            :     // Search TextNode containing the field.
     392                 :            :     virtual const SwNode* GetNodeOfFormula() const;
     393                 :            : 
     394                 :            :     String GetCommand();
     395                 :            : 
     396                 :            : public:
     397                 :            :     SwTblField( SwTblFieldType*, const String& rFormel,
     398                 :            :                 sal_uInt16 nSubType = 0, sal_uLong nFmt = 0);
     399                 :            : 
     400                 :            :     virtual void        SetValue( const double& rVal );
     401                 :            :     virtual sal_uInt16      GetSubType() const;
     402                 :            :     virtual void        SetSubType(sal_uInt16 nType);
     403                 :            : 
     404                 :          0 :     const String&       GetExpStr() const               { return sExpand; }
     405                 :          0 :     void                ChgExpStr(const String& rStr)   { sExpand = rStr; }
     406                 :            : 
     407                 :            :     void                CalcField( SwTblCalcPara& rCalcPara );
     408                 :            : 
     409                 :            :     virtual String      GetFieldName() const;
     410                 :            : 
     411                 :            :     // The formula.
     412                 :            :     virtual rtl::OUString GetPar2()   const;
     413                 :            :     virtual void        SetPar2(const rtl::OUString& rStr);
     414                 :            :     virtual bool        QueryValue( com::sun::star::uno::Any& rVal, sal_uInt16 nWhich ) const;
     415                 :            :     virtual bool        PutValue( const com::sun::star::uno::Any& rVal, sal_uInt16 nWhich );
     416                 :            : };
     417                 :            : 
     418                 :            : 
     419                 :            : #endif // SW_EXPFLD_HXX
     420                 :            : 
     421                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10