LCOV - code coverage report
Current view: top level - sw/inc - authfld.hxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 39 0.0 %
Date: 2014-04-14 Functions: 0 23 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_AUTHFLD_HXX
      20             : #define INCLUDED_SW_INC_AUTHFLD_HXX
      21             : 
      22             : #include "swdllapi.h"
      23             : #include <fldbas.hxx>
      24             : #include <toxe.hxx>
      25             : #include <vector>
      26             : #include <boost/ptr_container/ptr_vector.hpp>
      27             : 
      28           0 : class SwAuthEntry
      29             : {
      30             :     OUString        aAuthFields[AUTH_FIELD_END];
      31             :     sal_uInt16      nRefCount;
      32             : public:
      33           0 :     SwAuthEntry() : nRefCount(0){}
      34             :     SwAuthEntry( const SwAuthEntry& rCopy );
      35             :     sal_Bool            operator==(const SwAuthEntry& rComp);
      36             : 
      37             :     inline OUString         GetAuthorField(ToxAuthorityField ePos) const;
      38             :     inline void             SetAuthorField(ToxAuthorityField ePos,
      39             :                                             const OUString& rField);
      40             : 
      41           0 :     void            AddRef()                { ++nRefCount; }
      42           0 :     void            RemoveRef()             { --nRefCount; }
      43           0 :     sal_uInt16          GetRefCount()           { return nRefCount; }
      44             : };
      45             : 
      46             : struct SwTOXSortKey
      47             : {
      48             :     ToxAuthorityField   eField;
      49             :     bool                bSortAscending;
      50           0 :     SwTOXSortKey() :
      51             :         eField(AUTH_FIELD_END),
      52           0 :         bSortAscending(true){}
      53             : };
      54             : 
      55             : class SwAuthorityField;
      56             : typedef boost::ptr_vector<SwTOXSortKey> SortKeyArr;
      57             : typedef boost::ptr_vector<SwAuthEntry> SwAuthDataArr;
      58             : 
      59             : class SW_DLLPUBLIC SwAuthorityFieldType : public SwFieldType
      60             : {
      61             :     SwDoc*                  m_pDoc;
      62             :     SwAuthDataArr           m_DataArr;
      63             :     std::vector<sal_IntPtr> m_SequArr;
      64             :     SortKeyArr              m_SortKeyArr;
      65             :     sal_Unicode             m_cPrefix;
      66             :     sal_Unicode             m_cSuffix;
      67             :     sal_Bool                m_bIsSequence :1;
      68             :     sal_Bool                m_bSortByDocument :1;
      69             :     LanguageType            m_eLanguage;
      70             :     OUString                m_sSortAlgorithm;
      71             : 
      72             : protected:
      73             : virtual void Modify( const SfxPoolItem* pOld, const SfxPoolItem *pNew ) SAL_OVERRIDE;
      74             : 
      75             : public:
      76             :     SwAuthorityFieldType(SwDoc* pDoc);
      77             :     virtual ~SwAuthorityFieldType();
      78             : 
      79             :     virtual SwFieldType* Copy()    const SAL_OVERRIDE;
      80             : 
      81             :     virtual bool        QueryValue( com::sun::star::uno::Any& rVal, sal_uInt16 nWhichId ) const SAL_OVERRIDE;
      82             :     virtual bool        PutValue( const com::sun::star::uno::Any& rVal, sal_uInt16 nWhichId ) SAL_OVERRIDE;
      83             : 
      84           0 :     inline void         SetDoc(SwDoc* pNewDoc)              { m_pDoc = pNewDoc; }
      85           0 :     SwDoc*              GetDoc(){ return m_pDoc; }
      86             :     void                RemoveField(sal_IntPtr nHandle);
      87             :     sal_IntPtr          AddField(const OUString& rFieldContents);
      88             :     sal_Bool            AddField(sal_IntPtr nHandle);
      89           0 :     void                DelSequenceArray()
      90             :                         {
      91           0 :                             m_SequArr.clear();
      92           0 :                         }
      93             : 
      94             :     const SwAuthEntry*  GetEntryByHandle(sal_IntPtr nHandle) const;
      95             : 
      96             :     void                GetAllEntryIdentifiers( std::vector<OUString>& rToFill ) const;
      97             :     const SwAuthEntry*  GetEntryByIdentifier(const OUString& rIdentifier) const;
      98             : 
      99             :     bool                ChangeEntryContent(const SwAuthEntry* pNewEntry);
     100             :     // import interface
     101             :     sal_uInt16          AppendField(const SwAuthEntry& rInsert);
     102             :     sal_IntPtr          GetHandle(sal_uInt16 nPos);
     103             : 
     104             :     sal_uInt16          GetSequencePos(sal_IntPtr nHandle);
     105             : 
     106           0 :     sal_Bool            IsSequence() const      {return m_bIsSequence;}
     107           0 :     void                SetSequence(sal_Bool bSet)
     108             :                             {
     109           0 :                                 DelSequenceArray();
     110           0 :                                 m_bIsSequence = bSet;
     111           0 :                             }
     112             : 
     113           0 :     void                SetPreSuffix( sal_Unicode cPre, sal_Unicode cSuf)
     114             :                             {
     115           0 :                                 m_cPrefix = cPre;
     116           0 :                                 m_cSuffix = cSuf;
     117           0 :                             }
     118           0 :     sal_Unicode         GetPrefix() const { return m_cPrefix;}
     119           0 :     sal_Unicode         GetSuffix() const { return m_cSuffix;}
     120             : 
     121           0 :     sal_Bool            IsSortByDocument() const {return m_bSortByDocument;}
     122           0 :     void                SetSortByDocument(sal_Bool bSet)
     123             :                             {
     124           0 :                                 DelSequenceArray();
     125           0 :                                 m_bSortByDocument = bSet;
     126           0 :                             }
     127             : 
     128             :     sal_uInt16          GetSortKeyCount() const ;
     129             :     const SwTOXSortKey* GetSortKey(sal_uInt16 nIdx) const ;
     130             :     void                SetSortKeys(sal_uInt16 nKeyCount, SwTOXSortKey nKeys[]);
     131             : 
     132             :     //initui.cxx
     133             :     static OUString     GetAuthFieldName(ToxAuthorityField eType);
     134             :     static OUString     GetAuthTypeName(ToxAuthorityType eType);
     135             : 
     136           0 :     LanguageType    GetLanguage() const {return m_eLanguage;}
     137           0 :     void            SetLanguage(LanguageType nLang)  {m_eLanguage = nLang;}
     138             : 
     139           0 :     OUString        GetSortAlgorithm() const {return m_sSortAlgorithm;}
     140           0 :     void            SetSortAlgorithm(const OUString& rSet) {m_sSortAlgorithm = rSet;}
     141             : 
     142             : };
     143             : 
     144             : class SwAuthorityField : public SwField
     145             : {
     146             :     sal_IntPtr          m_nHandle;
     147             :     mutable sal_IntPtr  m_nTempSequencePos;
     148             : 
     149             :     virtual OUString    Expand() const SAL_OVERRIDE;
     150             :     virtual SwField*    Copy() const SAL_OVERRIDE;
     151             : 
     152             : public:
     153             :     /// For internal use only, in general continue using ExpandField() instead.
     154             :     OUString ConditionalExpand(ToxAuthorityField eField) const;
     155             : 
     156             :     SwAuthorityField(SwAuthorityFieldType* pType, const OUString& rFieldContents);
     157             :     SwAuthorityField(SwAuthorityFieldType* pType, sal_IntPtr nHandle);
     158             :     virtual ~SwAuthorityField();
     159             : 
     160             :     OUString            GetFieldText(ToxAuthorityField eField) const;
     161             : 
     162             :     virtual void        SetPar1(const OUString& rStr) SAL_OVERRIDE;
     163             :     virtual SwFieldType* ChgTyp( SwFieldType* ) SAL_OVERRIDE;
     164             : 
     165             :     virtual bool        QueryValue( com::sun::star::uno::Any& rVal, sal_uInt16 nWhichId ) const SAL_OVERRIDE;
     166             :     virtual bool        PutValue( const com::sun::star::uno::Any& rVal, sal_uInt16 nWhichId ) SAL_OVERRIDE;
     167             : 
     168           0 :     sal_IntPtr          GetHandle() const       { return m_nHandle; }
     169             : 
     170             :     virtual OUString GetDescription() const SAL_OVERRIDE;
     171             : };
     172             : 
     173             : // --- inlines -----------------------------------------------------------
     174           0 : inline OUString SwAuthEntry::GetAuthorField(ToxAuthorityField ePos) const
     175             : {
     176             :     SAL_WARN_IF(AUTH_FIELD_END <= ePos, "sw", "wrong index");
     177           0 :     return aAuthFields[ePos];
     178             : }
     179           0 : inline void SwAuthEntry::SetAuthorField(ToxAuthorityField ePos, const OUString& rField)
     180             : {
     181             :     SAL_WARN_IF(AUTH_FIELD_END <= ePos, "sw", "wrong index");
     182           0 :     if(AUTH_FIELD_END > ePos)
     183           0 :         aAuthFields[ePos] = rField;
     184           0 : }
     185             : 
     186             : #endif
     187             : 
     188             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10