LCOV - code coverage report
Current view: top level - sw/inc - expfld.hxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 64 0.0 %
Date: 2014-04-14 Functions: 0 49 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_EXPFLD_HXX
      20             : #define INCLUDED_SW_INC_EXPFLD_HXX
      21             : 
      22             : #include "swdllapi.h"
      23             : #include <fldbas.hxx>
      24             : #include <cellfml.hxx>
      25             : #include <set>
      26             : #include <vector>
      27             : 
      28             : class SfxPoolItem;
      29             : class SwTxtNode;
      30             : class SwFrm;
      31             : struct SwPosition;
      32             : class SwTxtFld;
      33             : class SwDoc;
      34             : class SwFmtFld;
      35             : class _SetGetExpFlds;
      36             : class SwEditShell;
      37             : 
      38             : /// Forward declaration: get "BodyTxtNode" for exp.fld in Fly's headers/footers/footnotes.
      39             : const SwTxtNode* GetBodyTxtNode( const SwDoc& pDoc, SwPosition& rPos,
      40             :                                  const SwFrm& rFrm );
      41             : 
      42             : OUString ReplacePoint(const OUString& sTmpName, bool bWithCommandType = false);
      43             : 
      44           0 : struct _SeqFldLstElem
      45             : {
      46             :     OUString sDlgEntry;
      47             :     sal_uInt16 nSeqNo;
      48             : 
      49           0 :     _SeqFldLstElem( const OUString& rStr, sal_uInt16 nNo )
      50           0 :         : sDlgEntry( rStr ), nSeqNo( nNo )
      51           0 :     {}
      52             : };
      53             : 
      54           0 : class SW_DLLPUBLIC SwSeqFldList
      55             : {
      56             :     std::vector<_SeqFldLstElem*> maData;
      57             : public:
      58           0 :     ~SwSeqFldList()
      59           0 :     {
      60           0 :         for( std::vector<_SeqFldLstElem*>::const_iterator it = maData.begin(); it != maData.end(); ++it )
      61           0 :             delete *it;
      62           0 :     }
      63             : 
      64             :     bool InsertSort(_SeqFldLstElem* pNew);
      65             :     bool SeekEntry(const _SeqFldLstElem& rNew, sal_uInt16* pPos) const;
      66             : 
      67           0 :     sal_uInt16 Count() { return maData.size(); }
      68           0 :     _SeqFldLstElem* operator[](sal_uInt16 nIndex) { return maData[nIndex]; }
      69             :     const _SeqFldLstElem* operator[](sal_uInt16 nIndex) const { return maData[nIndex]; }
      70           0 :     void Clear() { maData.clear(); }
      71             : };
      72             : 
      73           0 : class SwGetExpFieldType : public SwValueFieldType
      74             : {
      75             : public:
      76             :         SwGetExpFieldType(SwDoc* pDoc);
      77             :         virtual SwFieldType*    Copy() const SAL_OVERRIDE;
      78             : 
      79             :         /** Overlay, because get-field cannot be changed and therefore
      80             :          does not need to be updated. Update at changing of set-values! */
      81             : protected:
      82             :    virtual void Modify( const SfxPoolItem* pOld, const SfxPoolItem *pNew ) SAL_OVERRIDE;
      83             : };
      84             : 
      85           0 : class SW_DLLPUBLIC SwGetExpField : public SwFormulaField
      86             : {
      87             :     OUString        sExpand;
      88             :     bool            bIsInBodyTxt;
      89             :     sal_uInt16          nSubType;
      90             : 
      91             :     bool            bLateInitialization; // #i82544#
      92             : 
      93             :     virtual OUString            Expand() const SAL_OVERRIDE;
      94             :     virtual SwField*            Copy() const SAL_OVERRIDE;
      95             : 
      96             : public:
      97             :     SwGetExpField( SwGetExpFieldType*, const OUString& rFormel,
      98             :                    sal_uInt16 nSubType = nsSwGetSetExpType::GSE_EXPR, sal_uLong nFmt = 0);
      99             : 
     100             :     virtual void                SetValue( const double& rVal ) SAL_OVERRIDE;
     101             :     virtual void                SetLanguage(sal_uInt16 nLng) SAL_OVERRIDE;
     102             : 
     103             :     inline OUString             GetExpStr() const;
     104             :     inline void                 ChgExpStr(const OUString& rExpand);
     105             : 
     106             :     /// Called by formatting.
     107             :     inline bool                 IsInBodyTxt() const;
     108             : 
     109             :     /// Set by UpdateExpFlds where node position is known.
     110             :     inline void                 ChgBodyTxtFlag( bool bIsInBody );
     111             : 
     112             :     /** For fields in header/footer/footnotes/flys:
     113             :      Only called by formatting!! */
     114             :     void                        ChangeExpansion( const SwFrm&, const SwTxtFld& );
     115             : 
     116             :     virtual OUString    GetFieldName() const SAL_OVERRIDE;
     117             : 
     118             :     /// Change formula.
     119             :     virtual OUString GetPar2() const SAL_OVERRIDE;
     120             :     virtual void        SetPar2(const OUString& rStr) SAL_OVERRIDE;
     121             : 
     122             :     virtual sal_uInt16  GetSubType() const SAL_OVERRIDE;
     123             :     virtual void        SetSubType(sal_uInt16 nType) SAL_OVERRIDE;
     124             :     virtual bool        QueryValue( com::sun::star::uno::Any& rVal, sal_uInt16 nWhich ) const SAL_OVERRIDE;
     125             :     virtual bool        PutValue( const com::sun::star::uno::Any& rVal, sal_uInt16 nWhich ) SAL_OVERRIDE;
     126             : 
     127             :     static sal_Int32    GetReferenceTextPos( const SwFmtFld& rFmt, SwDoc& rDoc, sal_Int32 nHint = 0);
     128             :     // #i82544#
     129           0 :     void                SetLateInitialization() { bLateInitialization = true;}
     130             : };
     131             : 
     132           0 : inline void SwGetExpField::ChgExpStr(const OUString& rExpand)
     133           0 :     { sExpand = rExpand;}
     134             : 
     135           0 : inline OUString SwGetExpField::GetExpStr() const
     136           0 :     { return sExpand;   }
     137             : 
     138             :  /// Called by formatting.
     139           0 : inline bool SwGetExpField::IsInBodyTxt() const
     140           0 :     { return bIsInBodyTxt; }
     141             : 
     142             :  /// Set by UpdateExpFlds where node position is known.
     143           0 : inline void SwGetExpField::ChgBodyTxtFlag( bool bIsInBody )
     144           0 :     { bIsInBodyTxt = bIsInBody; }
     145             : 
     146             : class SwSetExpField;
     147             : 
     148           0 : class SW_DLLPUBLIC SwSetExpFieldType : public SwValueFieldType
     149             : {
     150             :     OUString sName;
     151             :     const SwNode* pOutlChgNd;
     152             :     OUString      sDelim;
     153             :     sal_uInt16      nType;
     154             :     sal_uInt8       nLevel;
     155             :     sal_Bool        bDeleted;
     156             : 
     157             : protected:
     158             :    virtual void Modify( const SfxPoolItem* pOld, const SfxPoolItem *pNew ) SAL_OVERRIDE;
     159             : 
     160             : public:
     161             :     SwSetExpFieldType( SwDoc* pDoc, const OUString& rName,
     162             :                         sal_uInt16 nType = nsSwGetSetExpType::GSE_EXPR );
     163             :     virtual SwFieldType*    Copy() const SAL_OVERRIDE;
     164             :     virtual OUString        GetName() const SAL_OVERRIDE;
     165             : 
     166             :     inline void             SetType(sal_uInt16 nTyp);
     167             :     inline sal_uInt16       GetType() const;
     168             : 
     169             :     void                    SetSeqFormat(sal_uLong nFormat);
     170             :     sal_uLong               GetSeqFormat();
     171             : 
     172           0 :     sal_Bool                IsDeleted() const       { return bDeleted; }
     173           0 :     void                    SetDeleted( sal_Bool b )    { bDeleted = b; }
     174             : 
     175             :     /// Overlay, because set-field takes care for its being updated by itself.
     176             :     inline OUString         GetSetRefName() const;
     177             : 
     178             :     sal_uInt16 SetSeqRefNo( SwSetExpField& rFld );
     179             : 
     180             :     sal_uInt16 GetSeqFldList( SwSeqFldList& rList );
     181             :     OUString MakeSeqName( sal_uInt16 nSeqNo );
     182             : 
     183             :     /// Number sequence fields chapterwise if required.
     184           0 :     OUString GetDelimiter() const             { return sDelim; }
     185           0 :     void SetDelimiter( const OUString& s )    { sDelim = s; }
     186           0 :     sal_uInt8 GetOutlineLvl() const                 { return nLevel; }
     187           0 :     void SetOutlineLvl( sal_uInt8 n )           { nLevel = n; }
     188             :     void SetChapter( SwSetExpField& rFld, const SwNode& rNd );
     189             : 
     190             :     /** Member only for SwDoc::UpdateExpFld.
     191             :      It is needed only at runtime of sequence field types! */
     192           0 :     const SwNode* GetOutlineChgNd() const   { return pOutlChgNd; }
     193           0 :     void SetOutlineChgNd( const SwNode* p ) { pOutlChgNd = p; }
     194             : 
     195             :     virtual bool        QueryValue( com::sun::star::uno::Any& rVal, sal_uInt16 nWhich ) const SAL_OVERRIDE;
     196             :     virtual bool        PutValue( const com::sun::star::uno::Any& rVal, sal_uInt16 nWhich ) SAL_OVERRIDE;
     197             : };
     198             : 
     199           0 : inline void SwSetExpFieldType::SetType( sal_uInt16 nTyp )
     200             : {
     201           0 :         nType = nTyp;
     202           0 :         EnableFormat( !(nType & (nsSwGetSetExpType::GSE_SEQ|nsSwGetSetExpType::GSE_STRING)));
     203           0 : }
     204             : 
     205           0 : inline sal_uInt16 SwSetExpFieldType::GetType() const
     206           0 :     { return nType;   }
     207             : 
     208           0 : inline OUString SwSetExpFieldType::GetSetRefName() const
     209           0 :     { return sName; }
     210             : 
     211           0 : class SW_DLLPUBLIC SwSetExpField : public SwFormulaField
     212             : {
     213             :     OUString        sExpand;
     214             :     OUString        aPText;
     215             :     OUString        aSeqText;
     216             :     sal_Bool            bInput;
     217             :     sal_uInt16          nSeqNo;
     218             :     sal_uInt16          nSubType;
     219             : 
     220             :     virtual OUString            Expand() const SAL_OVERRIDE;
     221             :     virtual SwField*            Copy() const SAL_OVERRIDE;
     222             : 
     223             : public:
     224             :     SwSetExpField(SwSetExpFieldType*, const OUString& rFormel, sal_uLong nFmt = 0);
     225             : 
     226             :     virtual void                SetValue( const double& rVal ) SAL_OVERRIDE;
     227             : 
     228             :     inline OUString             GetExpStr() const;
     229             : 
     230             :     inline void                 ChgExpStr( const OUString& rExpand );
     231             : 
     232             :     inline void                 SetPromptText(const OUString& rStr);
     233             :     inline OUString             GetPromptText() const;
     234             : 
     235             :     inline void                 SetInputFlag(sal_Bool bInp);
     236             :     inline sal_Bool                 GetInputFlag() const;
     237             : 
     238             :     virtual OUString            GetFieldName() const SAL_OVERRIDE;
     239             : 
     240             :     virtual sal_uInt16              GetSubType() const SAL_OVERRIDE;
     241             :     virtual void                SetSubType(sal_uInt16 nType) SAL_OVERRIDE;
     242             : 
     243             :     inline sal_Bool                 IsSequenceFld() const;
     244             : 
     245             :     /// Logical number, sequence fields.
     246           0 :     inline void                 SetSeqNumber( sal_uInt16 n )    { nSeqNo = n; }
     247           0 :     inline sal_uInt16           GetSeqNumber() const        { return nSeqNo; }
     248             : 
     249             :     /// Query name only.
     250             :     virtual OUString       GetPar1()   const SAL_OVERRIDE;
     251             : 
     252             :     /// Query formula.
     253             :     virtual OUString       GetPar2()   const SAL_OVERRIDE;
     254             :     virtual void                SetPar2(const OUString& rStr) SAL_OVERRIDE;
     255             :     virtual bool        QueryValue( com::sun::star::uno::Any& rVal, sal_uInt16 nWhich ) const SAL_OVERRIDE;
     256             :     virtual bool        PutValue( const com::sun::star::uno::Any& rVal, sal_uInt16 nWhich ) SAL_OVERRIDE;
     257             : };
     258             : 
     259           0 : inline OUString SwSetExpField::GetExpStr() const
     260           0 :     { return sExpand;       }
     261             : 
     262           0 : inline void SwSetExpField::ChgExpStr( const OUString& rExpand )
     263           0 :     { sExpand = rExpand;    }
     264             : 
     265           0 : inline void  SwSetExpField::SetPromptText(const OUString& rStr)
     266           0 :     { aPText = rStr;        }
     267             : 
     268           0 : inline OUString SwSetExpField::GetPromptText() const
     269           0 :     { return aPText;        }
     270             : 
     271           0 : inline void SwSetExpField::SetInputFlag(sal_Bool bInp)
     272           0 :     { bInput = bInp; }
     273             : 
     274           0 : inline sal_Bool SwSetExpField::GetInputFlag() const
     275           0 :     { return bInput; }
     276             : 
     277           0 : inline sal_Bool SwSetExpField::IsSequenceFld() const
     278           0 :     { return 0 != (nsSwGetSetExpType::GSE_SEQ & ((SwSetExpFieldType*)GetTyp())->GetType()); }
     279             : 
     280           0 : class SwInputFieldType : public SwFieldType
     281             : {
     282             :     SwDoc* pDoc;
     283             : public:
     284             :     SwInputFieldType( SwDoc* pDoc );
     285             : 
     286             :     virtual SwFieldType* Copy() const SAL_OVERRIDE;
     287             : 
     288           0 :     SwDoc* GetDoc() const { return pDoc; }
     289             : };
     290             : 
     291             : class SW_DLLPUBLIC SwInputField : public SwField
     292             : {
     293             :     mutable OUString aContent;
     294             :     OUString aPText;
     295             :     OUString aHelp;
     296             :     OUString aToolTip;
     297             :     sal_uInt16 nSubType;
     298             :     bool mbIsFormField;
     299             : 
     300             :     SwFmtFld* mpFmtFld; // attribute to which the <SwInputField> belongs to
     301             : 
     302             :     virtual OUString        Expand() const SAL_OVERRIDE;
     303             :     virtual SwField*        Copy() const SAL_OVERRIDE;
     304             : 
     305             :     // Accessing Input Field's content
     306             :     const OUString& getContent() const;
     307             : 
     308             :     void LockNotifyContentChange();
     309             :     void UnlockNotifyContentChange();
     310             : 
     311             : public:
     312             :     /// Direct input via dialog; delete old value.
     313             :     SwInputField(
     314             :         SwInputFieldType* pFieldType,
     315             :         const OUString& rContent,
     316             :         const OUString& rPrompt,
     317             :         sal_uInt16 nSubType = 0,
     318             :         sal_uLong nFmt = 0,
     319             :         bool bIsFormField = true );
     320             :     virtual ~SwInputField();
     321             : 
     322             :     void SetFmtFld( SwFmtFld& rFmtFld );
     323             :     SwFmtFld* GetFmtFld();
     324             : 
     325             :     // Providing new Input Field's content:
     326             :     // Fill Input Field's content depending on <nSupType>.
     327             :     void applyFieldContent( const OUString& rNewFieldContent );
     328             : 
     329             :     bool isFormField() const;
     330             : 
     331             :     virtual OUString        GetFieldName() const SAL_OVERRIDE;
     332             : 
     333             :     /// Content
     334             :     virtual OUString        GetPar1() const SAL_OVERRIDE;
     335             :     virtual void            SetPar1(const OUString& rStr) SAL_OVERRIDE;
     336             : 
     337             :     /// aPromptText
     338             :     virtual OUString   GetPar2() const SAL_OVERRIDE;
     339             :     virtual void            SetPar2(const OUString& rStr) SAL_OVERRIDE;
     340             : 
     341             :     virtual OUString        GetHelp() const;
     342             :     virtual void            SetHelp(const OUString & rStr);
     343             : 
     344             :     virtual OUString        GetToolTip() const;
     345             :     virtual void            SetToolTip(const OUString & rStr);
     346             : 
     347             :     virtual sal_uInt16      GetSubType() const SAL_OVERRIDE;
     348             :     virtual void            SetSubType(sal_uInt16 nSub) SAL_OVERRIDE;
     349             :     virtual bool        QueryValue( com::sun::star::uno::Any& rVal, sal_uInt16 nWhich ) const SAL_OVERRIDE;
     350             :     virtual bool        PutValue( const com::sun::star::uno::Any& rVal, sal_uInt16 nWhich ) SAL_OVERRIDE;
     351             : };
     352             : 
     353             : /*--------------------------------------------------------------------
     354             :     Description: Sorted list of input fields and DropDown fields
     355             :  --------------------------------------------------------------------*/
     356             : 
     357             : class SwInputFieldList
     358             : {
     359             : public:
     360             :     SwInputFieldList( SwEditShell* pShell, sal_Bool bBuildTmpLst = sal_False );
     361             :     ~SwInputFieldList();
     362             : 
     363             :     sal_uInt16      Count() const;
     364             :     SwField*    GetField(sal_uInt16 nId);
     365             : 
     366             :     void        GotoFieldPos(sal_uInt16 nId);
     367             :     void        PushCrsr();
     368             :     void        PopCrsr();
     369             : 
     370             :     /** Put all that are new into SortLst for updating. @return count.
     371             :      (For Glossary: only update its input-fields).
     372             :      Compare TmpLst with current fields. */
     373             :     sal_uInt16      BuildSortLst();
     374             : 
     375             : private:
     376             :     SwEditShell*              pSh;
     377             :     _SetGetExpFlds*           pSrtLst;
     378             :     std::set<const SwTxtFld*> aTmpLst;
     379             : };
     380             : 
     381             :  /// Implementation in tblcalc.cxx.
     382           0 : class SwTblFieldType : public SwValueFieldType
     383             : {
     384             : public:
     385             :     SwTblFieldType(SwDoc* pDocPtr);
     386             :     virtual SwFieldType* Copy() const SAL_OVERRIDE;
     387             : };
     388             : 
     389           0 : class SwTblField : public SwValueField, public SwTableFormula
     390             : {
     391             :     OUString      sExpand;
     392             :     sal_uInt16      nSubType;
     393             : 
     394             :     virtual OUString    Expand() const SAL_OVERRIDE;
     395             :     virtual SwField*    Copy() const SAL_OVERRIDE;
     396             : 
     397             :     /// Search TextNode containing the field.
     398             :     virtual const SwNode* GetNodeOfFormula() const SAL_OVERRIDE;
     399             : 
     400             :     OUString GetCommand();
     401             : 
     402             : public:
     403             :     SwTblField( SwTblFieldType*, const OUString& rFormel,
     404             :                 sal_uInt16 nSubType = 0, sal_uLong nFmt = 0);
     405             : 
     406             :     virtual void        SetValue( const double& rVal ) SAL_OVERRIDE;
     407             :     virtual sal_uInt16      GetSubType() const SAL_OVERRIDE;
     408             :     virtual void        SetSubType(sal_uInt16 nType) SAL_OVERRIDE;
     409             : 
     410           0 :     OUString            GetExpStr() const               { return sExpand; }
     411           0 :     void                ChgExpStr(const OUString& rStr) { sExpand = rStr; }
     412             : 
     413             :     void                CalcField( SwTblCalcPara& rCalcPara );
     414             : 
     415             :     virtual OUString    GetFieldName() const SAL_OVERRIDE;
     416             : 
     417             :     /// The formula.
     418             :     virtual OUString GetPar2()   const SAL_OVERRIDE;
     419             :     virtual void        SetPar2(const OUString& rStr) SAL_OVERRIDE;
     420             :     virtual bool        QueryValue( com::sun::star::uno::Any& rVal, sal_uInt16 nWhich ) const SAL_OVERRIDE;
     421             :     virtual bool        PutValue( const com::sun::star::uno::Any& rVal, sal_uInt16 nWhich ) SAL_OVERRIDE;
     422             : };
     423             : 
     424             : #endif // INCLUDED_SW_INC_EXPFLD_HXX
     425             : 
     426             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10