LCOV - code coverage report
Current view: top level - usr/local/src/libreoffice/sw/inc - txatbase.hxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 55 56 98.2 %
Date: 2013-07-09 Functions: 39 40 97.5 %
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 _TXATBASE_HXX
      20             : #define _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             : 
      29             : class SfxItemPool;
      30             : class SvXMLAttrContainerItem;
      31             : class SwFmtRuby;
      32             : class SwFmtCharFmt;
      33             : class SwFmtAutoFmt;
      34             : class SwFmtINetFmt;
      35             : class SwFmtFld;
      36             : class SwFmtFtn;
      37             : class SwFmtFlyCnt;
      38             : class SwTOXMark;
      39             : class SwFmtRefMark;
      40             : class SwFmtMeta;
      41             : 
      42             : 
      43             : class SwTxtAttr : private boost::noncopyable
      44             : {
      45             : private:
      46             :     SfxPoolItem * const m_pAttr;
      47             :     xub_StrLen m_nStart;
      48             :     bool m_bDontExpand          : 1;
      49             :     bool m_bLockExpandFlag      : 1;
      50             : 
      51             :     bool m_bDontMoveAttr        : 1;    // refmarks, toxmarks
      52             :     bool m_bCharFmtAttr         : 1;    // charfmt, inet
      53             :     bool m_bOverlapAllowedAttr  : 1;    // refmarks, toxmarks
      54             :     bool m_bPriorityAttr        : 1;    // attribute has priority (redlining)
      55             :     bool m_bDontExpandStart     : 1;    // don't expand start at paragraph start (ruby)
      56             :     bool m_bNesting             : 1;    // SwTxtAttrNesting
      57             :     bool m_bHasDummyChar        : 1;    // without end + meta
      58             :     bool m_bFormatIgnoreStart   : 1;    ///< text formatting should ignore start
      59             :     bool m_bFormatIgnoreEnd     : 1;    ///< text formatting should ignore end
      60             : 
      61             : protected:
      62             :     SwTxtAttr( SfxPoolItem& rAttr, xub_StrLen nStart );
      63             :     virtual ~SwTxtAttr();
      64             : 
      65         346 :     void SetLockExpandFlag( bool bFlag )    { m_bLockExpandFlag = bFlag; }
      66          80 :     void SetDontMoveAttr( bool bFlag )      { m_bDontMoveAttr = bFlag; }
      67         108 :     void SetCharFmtAttr( bool bFlag )       { m_bCharFmtAttr = bFlag; }
      68          80 :     void SetOverlapAllowedAttr( bool bFlag ){ m_bOverlapAllowedAttr = bFlag; }
      69         346 :     void SetDontExpandStartAttr(bool bFlag) { m_bDontExpandStart = bFlag; }
      70         346 :     void SetNesting(const bool bFlag)       { m_bNesting = bFlag; }
      71        1216 :     void SetHasDummyChar(const bool bFlag)  { m_bHasDummyChar = bFlag; }
      72             : 
      73             : public:
      74             : 
      75             :     /// destroy instance
      76             :     static void Destroy( SwTxtAttr * pToDestroy, SfxItemPool& rPool );
      77             : 
      78             :     /// start position
      79      503007 :                   xub_StrLen* GetStart()        { return & m_nStart; }
      80     7327829 :             const xub_StrLen* GetStart() const  { return & m_nStart; }
      81             : 
      82             :     /// end position
      83             :     virtual      xub_StrLen* GetEnd();
      84             :     inline const xub_StrLen* GetEnd() const;
      85             :     /// end (if available), else start
      86             :     inline const xub_StrLen* GetAnyEnd() const;
      87             : 
      88             :     inline void SetDontExpand( bool bDontExpand );
      89        5059 :     bool DontExpand() const                 { return m_bDontExpand; }
      90         296 :     bool IsLockExpandFlag() const           { return m_bLockExpandFlag; }
      91           0 :     bool IsDontMoveAttr() const             { return m_bDontMoveAttr; }
      92       10940 :     bool IsCharFmtAttr() const              { return m_bCharFmtAttr; }
      93        9193 :     bool IsOverlapAllowedAttr() const       { return m_bOverlapAllowedAttr; }
      94         647 :     bool IsPriorityAttr() const             { return m_bPriorityAttr; }
      95          98 :     void SetPriorityAttr( bool bFlag )      { m_bPriorityAttr = bFlag; }
      96           4 :     bool IsDontExpandStartAttr() const      { return m_bDontExpandStart; }
      97       11036 :     bool IsNesting() const                  { return m_bNesting; }
      98       21383 :     bool HasDummyChar() const               { return m_bHasDummyChar; }
      99       62445 :     bool IsFormatIgnoreStart() const        { return m_bFormatIgnoreStart; }
     100       63477 :     bool IsFormatIgnoreEnd  () const        { return m_bFormatIgnoreEnd  ; }
     101           8 :     void SetFormatIgnoreStart(bool bFlag)   { m_bFormatIgnoreStart = bFlag; }
     102           8 :     void SetFormatIgnoreEnd  (bool bFlag)   { m_bFormatIgnoreEnd   = bFlag; }
     103             : 
     104             :     inline const SfxPoolItem& GetAttr() const;
     105             :     inline       SfxPoolItem& GetAttr();
     106     1431918 :     inline sal_uInt16 Which() const { return GetAttr().Which(); }
     107             : 
     108             :     virtual int         operator==( const SwTxtAttr& ) const;
     109             : 
     110             :     inline const SwFmtCharFmt           &GetCharFmt() const;
     111             :     inline const SwFmtAutoFmt           &GetAutoFmt() const;
     112             :     inline const SwFmtFld               &GetFld() const;
     113             :     inline const SwFmtFtn               &GetFtn() const;
     114             :     inline const SwFmtFlyCnt            &GetFlyCnt() const;
     115             :     inline const SwTOXMark              &GetTOXMark() const;
     116             :     inline const SwFmtRefMark           &GetRefMark() const;
     117             :     inline const SwFmtINetFmt           &GetINetFmt() const;
     118             :     inline const SwFmtRuby              &GetRuby() const;
     119             :     inline const SwFmtMeta              &GetMeta() const;
     120             : 
     121             : };
     122             : 
     123       34961 : class SwTxtAttrEnd : public SwTxtAttr
     124             : {
     125             : protected:
     126             :     xub_StrLen m_nEnd;
     127             : 
     128             : public:
     129             :     SwTxtAttrEnd( SfxPoolItem& rAttr, sal_uInt16 nStart, sal_uInt16 nEnd );
     130             : 
     131             :     using SwTxtAttr::GetEnd;
     132             :     virtual xub_StrLen* GetEnd();
     133             : };
     134             : 
     135             : 
     136             : // --------------- Inline Implementations ------------------------
     137             : 
     138     2998511 : inline const xub_StrLen* SwTxtAttr::GetEnd() const
     139             : {
     140     2998511 :     return const_cast<SwTxtAttr * >(this)->GetEnd();
     141             : }
     142             : 
     143     2805667 : inline const xub_StrLen* SwTxtAttr::GetAnyEnd() const
     144             : {
     145     2805667 :     const xub_StrLen* pEnd = GetEnd();
     146     2805667 :     return pEnd ? pEnd : GetStart();
     147             : }
     148             : 
     149     1588319 : inline const SfxPoolItem& SwTxtAttr::GetAttr() const
     150             : {
     151             :     OSL_ENSURE( m_pAttr, "SwTxtAttr: where is my attribute?" );
     152     1588319 :     return *m_pAttr;
     153             : }
     154             : 
     155       19426 : inline SfxPoolItem& SwTxtAttr::GetAttr()
     156             : {
     157             :     return const_cast<SfxPoolItem&>(
     158       19426 :             const_cast<const SwTxtAttr*>(this)->GetAttr());
     159             : }
     160             : 
     161        1236 : inline void SwTxtAttr::SetDontExpand( bool bDontExpand )
     162             : {
     163        1236 :     if ( !m_bLockExpandFlag )
     164             :     {
     165        1027 :         m_bDontExpand = bDontExpand;
     166             :     }
     167        1236 : }
     168             : 
     169             : //------------------------------------------------------------------------
     170             : 
     171          52 : inline const SwFmtCharFmt& SwTxtAttr::GetCharFmt() const
     172             : {
     173             :     OSL_ENSURE( m_pAttr && m_pAttr->Which() == RES_TXTATR_CHARFMT,
     174             :         "Wrong attribute" );
     175          52 :     return (const SwFmtCharFmt&)(*m_pAttr);
     176             : }
     177             : 
     178      166414 : inline const SwFmtAutoFmt& SwTxtAttr::GetAutoFmt() const
     179             : {
     180             :     OSL_ENSURE( m_pAttr && m_pAttr->Which() == RES_TXTATR_AUTOFMT,
     181             :         "Wrong attribute" );
     182      166414 :     return (const SwFmtAutoFmt&)(*m_pAttr);
     183             : }
     184             : 
     185      127020 : inline const SwFmtFld& SwTxtAttr::GetFld() const
     186             : {
     187             :     OSL_ENSURE( m_pAttr && m_pAttr->Which() == RES_TXTATR_FIELD,
     188             :         "Wrong attribute" );
     189      127020 :     return (const SwFmtFld&)(*m_pAttr);
     190             : }
     191             : 
     192        1813 : inline const SwFmtFtn& SwTxtAttr::GetFtn() const
     193             : {
     194             :     OSL_ENSURE( m_pAttr && m_pAttr->Which() == RES_TXTATR_FTN, "Wrong attribute" );
     195        1813 :     return (const SwFmtFtn&)(*m_pAttr);
     196             : }
     197             : 
     198        3199 : inline const SwFmtFlyCnt& SwTxtAttr::GetFlyCnt() const
     199             : {
     200             :     OSL_ENSURE( m_pAttr && m_pAttr->Which() == RES_TXTATR_FLYCNT,
     201             :         "Wrong attribute" );
     202        3199 :     return (const SwFmtFlyCnt&)(*m_pAttr);
     203             : }
     204             : 
     205          57 : inline const SwTOXMark& SwTxtAttr::GetTOXMark() const
     206             : {
     207             :     OSL_ENSURE( m_pAttr && m_pAttr->Which() == RES_TXTATR_TOXMARK,
     208             :         "Wrong attribute" );
     209          57 :     return (const SwTOXMark&)(*m_pAttr);
     210             : }
     211             : 
     212          52 : inline const SwFmtRefMark& SwTxtAttr::GetRefMark() const
     213             : {
     214             :     OSL_ENSURE( m_pAttr && m_pAttr->Which() == RES_TXTATR_REFMARK,
     215             :         "Wrong attribute" );
     216          52 :     return (const SwFmtRefMark&)(*m_pAttr);
     217             : }
     218             : 
     219        2203 : inline const SwFmtINetFmt& SwTxtAttr::GetINetFmt() const
     220             : {
     221             :     OSL_ENSURE( m_pAttr && m_pAttr->Which() == RES_TXTATR_INETFMT,
     222             :         "Wrong attribute" );
     223        2203 :     return (const SwFmtINetFmt&)(*m_pAttr);
     224             : }
     225             : 
     226         336 : inline const SwFmtRuby& SwTxtAttr::GetRuby() const
     227             : {
     228             :     OSL_ENSURE( m_pAttr && m_pAttr->Which() == RES_TXTATR_CJK_RUBY,
     229             :         "Wrong attribute" );
     230         336 :     return (const SwFmtRuby&)(*m_pAttr);
     231             : }
     232             : 
     233             : inline const SwFmtMeta& SwTxtAttr::GetMeta() const
     234             : {
     235             :     OSL_ENSURE( m_pAttr && (m_pAttr->Which() == RES_TXTATR_META ||
     236             :                         m_pAttr->Which() == RES_TXTATR_METAFIELD),
     237             :         "Wrong attribute" );
     238             :     return (const SwFmtMeta&)(*m_pAttr);
     239             : }
     240             : 
     241             : #endif
     242             : 
     243             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10