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

Generated by: LCOV version 1.10