LCOV - code coverage report
Current view: top level - sw/inc - txatbase.hxx (source / functions) Hit Total Coverage
Test: commit 0e63ca4fde4e446f346e35849c756a30ca294aab Lines: 58 58 100.0 %
Date: 2014-04-11 Functions: 42 42 100.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_TXATBASE_HXX
      20             : #define INCLUDED_SW_INC_TXATBASE_HXX
      21             : 
      22             : #include <tools/solar.h>
      23             : #include <svl/poolitem.hxx>
      24             : #include <hintids.hxx>
      25             : 
      26             : #include <boost/utility.hpp>
      27             : 
      28             : class SfxItemPool;
      29             : class SvXMLAttrContainerItem;
      30             : class SwFmtRuby;
      31             : class SwFmtCharFmt;
      32             : class SwFmtAutoFmt;
      33             : class SwFmtINetFmt;
      34             : class SwFmtFld;
      35             : class SwFmtFtn;
      36             : class SwFmtFlyCnt;
      37             : class SwTOXMark;
      38             : class SwFmtRefMark;
      39             : class SwFmtMeta;
      40             : 
      41             : class SwTxtAttr : private boost::noncopyable
      42             : {
      43             : private:
      44             :     SfxPoolItem * const m_pAttr;
      45             :     sal_Int32 m_nStart;
      46             :     bool m_bDontExpand          : 1;
      47             :     bool m_bLockExpandFlag      : 1;
      48             : 
      49             :     bool m_bDontMoveAttr        : 1;    // refmarks, toxmarks
      50             :     bool m_bCharFmtAttr         : 1;    // charfmt, inet
      51             :     bool m_bOverlapAllowedAttr  : 1;    // refmarks, toxmarks
      52             :     bool m_bPriorityAttr        : 1;    // attribute has priority (redlining)
      53             :     bool m_bDontExpandStart     : 1;    // don't expand start at paragraph start (ruby)
      54             :     bool m_bNesting             : 1;    // SwTxtAttrNesting
      55             :     bool m_bHasDummyChar        : 1;    // without end + meta
      56             :     bool m_bFormatIgnoreStart   : 1;    ///< text formatting should ignore start
      57             :     bool m_bFormatIgnoreEnd     : 1;    ///< text formatting should ignore end
      58             :     bool m_bHasContent          : 1;    // text attribute with content
      59             : 
      60             : protected:
      61             :     SwTxtAttr( SfxPoolItem& rAttr, sal_Int32 nStart );
      62             :     virtual ~SwTxtAttr();
      63             : 
      64        1880 :     void SetLockExpandFlag( bool bFlag )    { m_bLockExpandFlag = bFlag; }
      65         206 :     void SetDontMoveAttr( bool bFlag )      { m_bDontMoveAttr = bFlag; }
      66        2556 :     void SetCharFmtAttr( bool bFlag )       { m_bCharFmtAttr = bFlag; }
      67         206 :     void SetOverlapAllowedAttr( bool bFlag ){ m_bOverlapAllowedAttr = bFlag; }
      68        1880 :     void SetDontExpandStartAttr(bool bFlag) { m_bDontExpandStart = bFlag; }
      69        1880 :     void SetNesting(const bool bFlag)       { m_bNesting = bFlag; }
      70        3841 :     void SetHasDummyChar(const bool bFlag)  { m_bHasDummyChar = bFlag; }
      71           2 :     void SetHasContent( const bool bFlag )  { m_bHasContent = bFlag; }
      72             : 
      73             : public:
      74             : 
      75             :     /// destroy instance
      76             :     static void Destroy( SwTxtAttr * pToDestroy, SfxItemPool& rPool );
      77             : 
      78             :     /// start position
      79     2003072 :                   sal_Int32* GetStart()        { return & m_nStart; }
      80    10740541 :             const sal_Int32* GetStart() const  { return & m_nStart; }
      81             : 
      82             :     /// end position
      83             :     virtual      sal_Int32* GetEnd(); // also used to change the end position
      84             :     inline const sal_Int32* End() const;
      85             :     /// end (if available), else start
      86             :     inline const sal_Int32* GetAnyEnd() const;
      87             : 
      88             :     inline void SetDontExpand( bool bDontExpand );
      89       63360 :     bool DontExpand() const                 { return m_bDontExpand; }
      90       14201 :     bool IsLockExpandFlag() const           { return m_bLockExpandFlag; }
      91           2 :     bool IsDontMoveAttr() const             { return m_bDontMoveAttr; }
      92       56338 :     bool IsCharFmtAttr() const              { return m_bCharFmtAttr; }
      93       58401 :     bool IsOverlapAllowedAttr() const       { return m_bOverlapAllowedAttr; }
      94       11576 :     bool IsPriorityAttr() const             { return m_bPriorityAttr; }
      95        3822 :     void SetPriorityAttr( bool bFlag )      { m_bPriorityAttr = bFlag; }
      96         102 :     bool IsDontExpandStartAttr() const      { return m_bDontExpandStart; }
      97       68182 :     bool IsNesting() const                  { return m_bNesting; }
      98      151406 :     bool HasDummyChar() const               { return m_bHasDummyChar; }
      99      177467 :     bool IsFormatIgnoreStart() const        { return m_bFormatIgnoreStart; }
     100      195931 :     bool IsFormatIgnoreEnd  () const        { return m_bFormatIgnoreEnd  ; }
     101          47 :     void SetFormatIgnoreStart(bool bFlag)   { m_bFormatIgnoreStart = bFlag; }
     102          47 :     void SetFormatIgnoreEnd  (bool bFlag)   { m_bFormatIgnoreEnd   = bFlag; }
     103       91495 :     bool HasContent() const                 { return m_bHasContent; }
     104             : 
     105             :     inline const SfxPoolItem& GetAttr() const;
     106             :     inline       SfxPoolItem& GetAttr();
     107     6936814 :     inline sal_uInt16 Which() const { return GetAttr().Which(); }
     108             : 
     109             :     virtual bool operator==( const SwTxtAttr& ) const;
     110             : 
     111             :     inline const SwFmtCharFmt           &GetCharFmt() const;
     112             :     inline const SwFmtAutoFmt           &GetAutoFmt() const;
     113             :     inline const SwFmtFld               &GetFmtFld() const;
     114             :     inline const SwFmtFtn               &GetFtn() const;
     115             :     inline const SwFmtFlyCnt            &GetFlyCnt() const;
     116             :     inline const SwTOXMark              &GetTOXMark() const;
     117             :     inline const SwFmtRefMark           &GetRefMark() const;
     118             :     inline const SwFmtINetFmt           &GetINetFmt() const;
     119             :     inline const SwFmtRuby              &GetRuby() const;
     120             :     inline const SwFmtMeta              &GetMeta() const;
     121             : 
     122             : };
     123             : 
     124      167919 : class SwTxtAttrEnd : public SwTxtAttr
     125             : {
     126             : protected:
     127             :     sal_Int32 m_nEnd;
     128             : 
     129             : public:
     130             :     SwTxtAttrEnd( SfxPoolItem& rAttr, sal_Int32 nStart, sal_Int32 nEnd );
     131             : 
     132             :     virtual sal_Int32* GetEnd() SAL_OVERRIDE;
     133             : };
     134             : 
     135             : // --------------- Inline Implementations ------------------------
     136             : 
     137     5381484 : inline const sal_Int32* SwTxtAttr::End() const
     138             : {
     139     5381484 :     return const_cast<SwTxtAttr * >(this)->GetEnd();
     140             : }
     141             : 
     142     4704646 : inline const sal_Int32* SwTxtAttr::GetAnyEnd() const
     143             : {
     144     4704646 :     const sal_Int32* pEnd = End();
     145     4704646 :     return pEnd ? pEnd : GetStart();
     146             : }
     147             : 
     148     7613864 : inline const SfxPoolItem& SwTxtAttr::GetAttr() const
     149             : {
     150             :     assert( m_pAttr );
     151     7613864 :     return *m_pAttr;
     152             : }
     153             : 
     154       87640 : inline SfxPoolItem& SwTxtAttr::GetAttr()
     155             : {
     156             :     return const_cast<SfxPoolItem&>(
     157       87640 :             const_cast<const SwTxtAttr*>(this)->GetAttr());
     158             : }
     159             : 
     160       31041 : inline void SwTxtAttr::SetDontExpand( bool bDontExpand )
     161             : {
     162       31041 :     if ( !m_bLockExpandFlag )
     163             :     {
     164       30494 :         m_bDontExpand = bDontExpand;
     165             :     }
     166       31041 : }
     167             : 
     168        1245 : inline const SwFmtCharFmt& SwTxtAttr::GetCharFmt() const
     169             : {
     170             :     assert( m_pAttr && m_pAttr->Which() == RES_TXTATR_CHARFMT );
     171        1245 :     return (const SwFmtCharFmt&)(*m_pAttr);
     172             : }
     173             : 
     174      360711 : inline const SwFmtAutoFmt& SwTxtAttr::GetAutoFmt() const
     175             : {
     176             :     assert( m_pAttr && m_pAttr->Which() == RES_TXTATR_AUTOFMT );
     177      360711 :     return (const SwFmtAutoFmt&)(*m_pAttr);
     178             : }
     179             : 
     180      133093 : inline const SwFmtFld& SwTxtAttr::GetFmtFld() const
     181             : {
     182             :     assert( m_pAttr
     183             :             && ( m_pAttr->Which() == RES_TXTATR_FIELD
     184             :                  || m_pAttr->Which() == RES_TXTATR_ANNOTATION
     185             :                  || m_pAttr->Which() == RES_TXTATR_INPUTFIELD ));
     186      133093 :     return (const SwFmtFld&)(*m_pAttr);
     187             : }
     188             : 
     189        3087 : inline const SwFmtFtn& SwTxtAttr::GetFtn() const
     190             : {
     191             :     assert( m_pAttr && m_pAttr->Which() == RES_TXTATR_FTN );
     192        3087 :     return (const SwFmtFtn&)(*m_pAttr);
     193             : }
     194             : 
     195       14109 : inline const SwFmtFlyCnt& SwTxtAttr::GetFlyCnt() const
     196             : {
     197             :     assert( m_pAttr && m_pAttr->Which() == RES_TXTATR_FLYCNT );
     198       14109 :     return (const SwFmtFlyCnt&)(*m_pAttr);
     199             : }
     200             : 
     201         183 : inline const SwTOXMark& SwTxtAttr::GetTOXMark() const
     202             : {
     203             :     assert( m_pAttr && m_pAttr->Which() == RES_TXTATR_TOXMARK );
     204         183 :     return (const SwTOXMark&)(*m_pAttr);
     205             : }
     206             : 
     207          52 : inline const SwFmtRefMark& SwTxtAttr::GetRefMark() const
     208             : {
     209             :     assert( m_pAttr && m_pAttr->Which() == RES_TXTATR_REFMARK );
     210          52 :     return (const SwFmtRefMark&)(*m_pAttr);
     211             : }
     212             : 
     213       17104 : inline const SwFmtINetFmt& SwTxtAttr::GetINetFmt() const
     214             : {
     215             :     assert( m_pAttr && m_pAttr->Which() == RES_TXTATR_INETFMT );
     216       17104 :     return (const SwFmtINetFmt&)(*m_pAttr);
     217             : }
     218             : 
     219         336 : inline const SwFmtRuby& SwTxtAttr::GetRuby() const
     220             : {
     221             :     assert( m_pAttr && m_pAttr->Which() == RES_TXTATR_CJK_RUBY );
     222         336 :     return (const SwFmtRuby&)(*m_pAttr);
     223             : }
     224             : 
     225             : inline const SwFmtMeta& SwTxtAttr::GetMeta() const
     226             : {
     227             :     assert( m_pAttr && (m_pAttr->Which() == RES_TXTATR_META ||
     228             :         m_pAttr->Which() == RES_TXTATR_METAFIELD) );
     229             :     return (const SwFmtMeta&)(*m_pAttr);
     230             : }
     231             : 
     232             : #endif
     233             : 
     234             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10