LCOV - code coverage report
Current view: top level - sw/inc - authfld.hxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 22 39 56.4 %
Date: 2014-11-03 Functions: 16 23 69.6 %
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         126 : class SwAuthEntry
      29             : {
      30             :     OUString        aAuthFields[AUTH_FIELD_END];
      31             :     sal_uInt16      nRefCount;
      32             : public:
      33         126 :     SwAuthEntry() : nRefCount(0){}
      34             :     SwAuthEntry( const SwAuthEntry& rCopy );
      35             :     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         320 :     void            AddRef()                { ++nRefCount; }
      42         320 :     void            RemoveRef()             { --nRefCount; }
      43         320 :     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             :     bool                m_bIsSequence :1;
      68             :     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          40 :     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             :     bool            AddField(sal_IntPtr nHandle);
      89         446 :     void                DelSequenceArray()
      90             :                         {
      91         446 :                             m_SequArr.clear();
      92         446 :                         }
      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         154 :     bool            IsSequence() const      {return m_bIsSequence;}
     107           0 :     void                SetSequence(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         252 :     sal_Unicode         GetPrefix() const { return m_cPrefix;}
     119         252 :     sal_Unicode         GetSuffix() const { return m_cSuffix;}
     120             : 
     121           0 :     bool            IsSortByDocument() const {return m_bSortByDocument;}
     122           0 :     void                SetSortByDocument(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           2 :     LanguageType    GetLanguage() const {return m_eLanguage;}
     137           4 :     void            SetLanguage(LanguageType nLang)  {m_eLanguage = nLang;}
     138             : 
     139           2 :     OUString        GetSortAlgorithm() const {return m_sSortAlgorithm;}
     140           4 :     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             :     //To handle Citation
     157             :     OUString ExpandCitation(ToxAuthorityField eField) const;
     158             : 
     159             :     SwAuthorityField(SwAuthorityFieldType* pType, const OUString& rFieldContents);
     160             :     SwAuthorityField(SwAuthorityFieldType* pType, sal_IntPtr nHandle);
     161             :     virtual ~SwAuthorityField();
     162             : 
     163             :     OUString            GetFieldText(ToxAuthorityField eField) const;
     164             : 
     165             :     virtual void        SetPar1(const OUString& rStr) SAL_OVERRIDE;
     166             :     virtual SwFieldType* ChgTyp( SwFieldType* ) SAL_OVERRIDE;
     167             : 
     168             :     virtual bool        QueryValue( com::sun::star::uno::Any& rVal, sal_uInt16 nWhichId ) const SAL_OVERRIDE;
     169             :     virtual bool        PutValue( const com::sun::star::uno::Any& rVal, sal_uInt16 nWhichId ) SAL_OVERRIDE;
     170             : 
     171           0 :     sal_IntPtr          GetHandle() const       { return m_nHandle; }
     172             : 
     173             :     virtual OUString GetDescription() const SAL_OVERRIDE;
     174             : };
     175             : 
     176        1456 : inline OUString SwAuthEntry::GetAuthorField(ToxAuthorityField ePos) const
     177             : {
     178             :     SAL_WARN_IF(AUTH_FIELD_END <= ePos, "sw", "wrong index");
     179        1456 :     return aAuthFields[ePos];
     180             : }
     181        3906 : inline void SwAuthEntry::SetAuthorField(ToxAuthorityField ePos, const OUString& rField)
     182             : {
     183             :     SAL_WARN_IF(AUTH_FIELD_END <= ePos, "sw", "wrong index");
     184        3906 :     if(AUTH_FIELD_END > ePos)
     185        3906 :         aAuthFields[ePos] = rField;
     186        3906 : }
     187             : 
     188             : #endif
     189             : 
     190             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10