LCOV - code coverage report
Current view: top level - sw/inc - txatbase.hxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 58 0.0 %
Date: 2014-04-14 Functions: 0 42 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_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           0 :     void SetLockExpandFlag( bool bFlag )    { m_bLockExpandFlag = bFlag; }
      65           0 :     void SetDontMoveAttr( bool bFlag )      { m_bDontMoveAttr = bFlag; }
      66           0 :     void SetCharFmtAttr( bool bFlag )       { m_bCharFmtAttr = bFlag; }
      67           0 :     void SetOverlapAllowedAttr( bool bFlag ){ m_bOverlapAllowedAttr = bFlag; }
      68           0 :     void SetDontExpandStartAttr(bool bFlag) { m_bDontExpandStart = bFlag; }
      69           0 :     void SetNesting(const bool bFlag)       { m_bNesting = bFlag; }
      70           0 :     void SetHasDummyChar(const bool bFlag)  { m_bHasDummyChar = bFlag; }
      71           0 :     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           0 :                   sal_Int32* GetStart()        { return & m_nStart; }
      80           0 :             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           0 :     bool DontExpand() const                 { return m_bDontExpand; }
      90           0 :     bool IsLockExpandFlag() const           { return m_bLockExpandFlag; }
      91           0 :     bool IsDontMoveAttr() const             { return m_bDontMoveAttr; }
      92           0 :     bool IsCharFmtAttr() const              { return m_bCharFmtAttr; }
      93           0 :     bool IsOverlapAllowedAttr() const       { return m_bOverlapAllowedAttr; }
      94           0 :     bool IsPriorityAttr() const             { return m_bPriorityAttr; }
      95           0 :     void SetPriorityAttr( bool bFlag )      { m_bPriorityAttr = bFlag; }
      96           0 :     bool IsDontExpandStartAttr() const      { return m_bDontExpandStart; }
      97           0 :     bool IsNesting() const                  { return m_bNesting; }
      98           0 :     bool HasDummyChar() const               { return m_bHasDummyChar; }
      99           0 :     bool IsFormatIgnoreStart() const        { return m_bFormatIgnoreStart; }
     100           0 :     bool IsFormatIgnoreEnd  () const        { return m_bFormatIgnoreEnd  ; }
     101           0 :     void SetFormatIgnoreStart(bool bFlag)   { m_bFormatIgnoreStart = bFlag; }
     102           0 :     void SetFormatIgnoreEnd  (bool bFlag)   { m_bFormatIgnoreEnd   = bFlag; }
     103           0 :     bool HasContent() const                 { return m_bHasContent; }
     104             : 
     105             :     inline const SfxPoolItem& GetAttr() const;
     106             :     inline       SfxPoolItem& GetAttr();
     107           0 :     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           0 : 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           0 : inline const sal_Int32* SwTxtAttr::End() const
     138             : {
     139           0 :     return const_cast<SwTxtAttr * >(this)->GetEnd();
     140             : }
     141             : 
     142           0 : inline const sal_Int32* SwTxtAttr::GetAnyEnd() const
     143             : {
     144           0 :     const sal_Int32* pEnd = End();
     145           0 :     return pEnd ? pEnd : GetStart();
     146             : }
     147             : 
     148           0 : inline const SfxPoolItem& SwTxtAttr::GetAttr() const
     149             : {
     150             :     assert( m_pAttr );
     151           0 :     return *m_pAttr;
     152             : }
     153             : 
     154           0 : inline SfxPoolItem& SwTxtAttr::GetAttr()
     155             : {
     156             :     return const_cast<SfxPoolItem&>(
     157           0 :             const_cast<const SwTxtAttr*>(this)->GetAttr());
     158             : }
     159             : 
     160           0 : inline void SwTxtAttr::SetDontExpand( bool bDontExpand )
     161             : {
     162           0 :     if ( !m_bLockExpandFlag )
     163             :     {
     164           0 :         m_bDontExpand = bDontExpand;
     165             :     }
     166           0 : }
     167             : 
     168           0 : inline const SwFmtCharFmt& SwTxtAttr::GetCharFmt() const
     169             : {
     170             :     assert( m_pAttr && m_pAttr->Which() == RES_TXTATR_CHARFMT );
     171           0 :     return (const SwFmtCharFmt&)(*m_pAttr);
     172             : }
     173             : 
     174           0 : inline const SwFmtAutoFmt& SwTxtAttr::GetAutoFmt() const
     175             : {
     176             :     assert( m_pAttr && m_pAttr->Which() == RES_TXTATR_AUTOFMT );
     177           0 :     return (const SwFmtAutoFmt&)(*m_pAttr);
     178             : }
     179             : 
     180           0 : 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           0 :     return (const SwFmtFld&)(*m_pAttr);
     187             : }
     188             : 
     189           0 : inline const SwFmtFtn& SwTxtAttr::GetFtn() const
     190             : {
     191             :     assert( m_pAttr && m_pAttr->Which() == RES_TXTATR_FTN );
     192           0 :     return (const SwFmtFtn&)(*m_pAttr);
     193             : }
     194             : 
     195           0 : inline const SwFmtFlyCnt& SwTxtAttr::GetFlyCnt() const
     196             : {
     197             :     assert( m_pAttr && m_pAttr->Which() == RES_TXTATR_FLYCNT );
     198           0 :     return (const SwFmtFlyCnt&)(*m_pAttr);
     199             : }
     200             : 
     201           0 : inline const SwTOXMark& SwTxtAttr::GetTOXMark() const
     202             : {
     203             :     assert( m_pAttr && m_pAttr->Which() == RES_TXTATR_TOXMARK );
     204           0 :     return (const SwTOXMark&)(*m_pAttr);
     205             : }
     206             : 
     207           0 : inline const SwFmtRefMark& SwTxtAttr::GetRefMark() const
     208             : {
     209             :     assert( m_pAttr && m_pAttr->Which() == RES_TXTATR_REFMARK );
     210           0 :     return (const SwFmtRefMark&)(*m_pAttr);
     211             : }
     212             : 
     213           0 : inline const SwFmtINetFmt& SwTxtAttr::GetINetFmt() const
     214             : {
     215             :     assert( m_pAttr && m_pAttr->Which() == RES_TXTATR_INETFMT );
     216           0 :     return (const SwFmtINetFmt&)(*m_pAttr);
     217             : }
     218             : 
     219           0 : inline const SwFmtRuby& SwTxtAttr::GetRuby() const
     220             : {
     221             :     assert( m_pAttr && m_pAttr->Which() == RES_TXTATR_CJK_RUBY );
     222           0 :     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