LCOV - code coverage report
Current view: top level - forms/source/richtext - rtattributes.hxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 2 39 5.1 %
Date: 2015-06-13 12:38:46 Functions: 2 10 20.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             : 
      20             : #ifndef INCLUDED_FORMS_SOURCE_RICHTEXT_RTATTRIBUTES_HXX
      21             : #define INCLUDED_FORMS_SOURCE_RICHTEXT_RTATTRIBUTES_HXX
      22             : 
      23             : #include <sal/types.h>
      24             : #include <svl/poolitem.hxx>
      25             : 
      26             : namespace frm
      27             : {
      28             : 
      29             :     /// the id of an attribute
      30             :     typedef sal_Int32   AttributeId;
      31             :     /// the "which id" of an item in an SfxItemSet
      32             :     typedef sal_uInt16      WhichId;
      33             :     /// a SFX slot id
      34             :     typedef sal_uInt16      SfxSlotId;
      35             : 
      36             :     enum AttributeCheckState
      37             :     {
      38             :         eChecked,
      39             :         eUnchecked,
      40             :         eIndetermined
      41             :     };
      42             : 
      43             :     struct AttributeState
      44             :     {
      45             :     private:
      46             :         SfxPoolItem     *pItemHandleItem;
      47             : 
      48             :     public:
      49             :         AttributeCheckState eSimpleState;
      50             : 
      51             :         inline          AttributeState( );
      52             :         inline explicit AttributeState( AttributeCheckState _eCheckState );
      53             :         inline          AttributeState( const AttributeState& _rSource );
      54             :         inline          ~AttributeState( );
      55             : 
      56             :         inline AttributeState& operator=( const AttributeState& _rSource );
      57             : 
      58             :         inline bool operator==( const AttributeState& _rRHS );
      59             : 
      60             :         inline const SfxPoolItem* getItem() const;
      61             :         inline void setItem( const SfxPoolItem* _pItem );
      62             :     };
      63             : 
      64           0 :     inline AttributeState::AttributeState( )
      65             :         :pItemHandleItem ( NULL )
      66           0 :         ,eSimpleState( eIndetermined )
      67             :     {
      68           0 :     }
      69             : 
      70           0 :     inline AttributeState::AttributeState( AttributeCheckState _eCheckState )
      71             :         :pItemHandleItem ( NULL )
      72           0 :         ,eSimpleState( _eCheckState )
      73             :     {
      74           0 :     }
      75             : 
      76           0 :     inline AttributeState::AttributeState( const AttributeState& _rSource )
      77             :         :pItemHandleItem ( NULL )
      78           0 :         ,eSimpleState( eIndetermined )
      79             :     {
      80           0 :         operator=( _rSource );
      81           0 :     }
      82             : 
      83           0 :     inline AttributeState::~AttributeState( )
      84             :     {
      85             : //        delete(pItemHandle);
      86           0 :     }
      87             : 
      88           0 :     inline AttributeState& AttributeState::operator=( const AttributeState& _rSource )
      89             :     {
      90           0 :         if ( &_rSource == this )
      91           0 :             return *this;
      92             : 
      93           0 :         eSimpleState = _rSource.eSimpleState;
      94           0 :         setItem( _rSource.getItem() );
      95           0 :         return *this;
      96             :     }
      97             : 
      98           0 :     inline const SfxPoolItem* AttributeState::getItem() const
      99             :     {
     100           0 :         return pItemHandleItem;
     101             :     }
     102             : 
     103           0 :     inline void AttributeState::setItem( const SfxPoolItem* _pItem )
     104             :     {
     105           0 :         if ( pItemHandleItem )
     106           0 :             delete pItemHandleItem;
     107           0 :         if ( _pItem )
     108           0 :             pItemHandleItem = _pItem->Clone();
     109             :         else
     110           0 :             pItemHandleItem = NULL;
     111           0 :     }
     112             : 
     113           0 :     inline bool AttributeState::operator==( const AttributeState& _rRHS )
     114             :     {
     115           0 :         if ( eSimpleState != _rRHS.eSimpleState )
     116           0 :             return false;
     117             : 
     118           0 :         if ( pItemHandleItem && !_rRHS.pItemHandleItem )
     119           0 :             return false;
     120             : 
     121           0 :         if ( !pItemHandleItem && _rRHS.pItemHandleItem )
     122           0 :             return false;
     123             : 
     124           0 :         if ( !pItemHandleItem && !_rRHS.pItemHandleItem )
     125           0 :             return true;
     126             : 
     127           0 :         return pItemHandleItem == _rRHS.pItemHandleItem;
     128             :     }
     129             : 
     130          20 :     class IMultiAttributeDispatcher
     131             :     {
     132             :     public:
     133             :         virtual AttributeState  getState( AttributeId _nAttributeId ) const = 0;
     134             :         virtual void            executeAttribute( AttributeId _nAttributeId, const SfxPoolItem* _pArgument ) = 0;
     135             : 
     136             :     protected:
     137          20 :         ~IMultiAttributeDispatcher() {}
     138             :     };
     139             : 
     140             : } // namespace frm
     141             : 
     142             : #endif // INCLUDED_FORMS_SOURCE_RICHTEXT_RTATTRIBUTES_HXX
     143             : 
     144             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11