1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 28 #ifndef FORMS_SOURCE_RICHTEXT_RTATTRIBUTES_HXX 29 #define FORMS_SOURCE_RICHTEXT_RTATTRIBUTES_HXX 30 31 #include <tools/solar.h> 32 #include <sal/types.h> 33 #include <svl/poolitem.hxx> 34 35 //........................................................................ 36 namespace frm 37 { 38 //........................................................................ 39 40 //==================================================================== 41 //= misc 42 //==================================================================== 43 /// the id of an attribute 44 typedef sal_Int32 AttributeId; 45 /// the "which id" of an item in an SfxItemSet 46 typedef sal_uInt16 WhichId; 47 /// a SFX slot id 48 typedef sal_uInt16 SfxSlotId; 49 /// a script type 50 typedef sal_uInt16 ScriptType; 51 52 //==================================================================== 53 //= AttributeCheckState 54 //==================================================================== 55 enum AttributeCheckState 56 { 57 eChecked, 58 eUnchecked, 59 eIndetermined 60 }; 61 62 //==================================================================== 63 //= AttributeState 64 //==================================================================== 65 struct AttributeState 66 { 67 private: 68 SfxItemHandle* pItemHandle; 69 70 public: 71 AttributeCheckState eSimpleState; 72 73 //................................................................ 74 inline AttributeState( ); 75 inline explicit AttributeState( AttributeCheckState _eCheckState ); 76 inline AttributeState( const AttributeState& _rSource ); 77 78 inline AttributeState& operator=( const AttributeState& _rSource ); 79 80 inline bool operator==( const AttributeState& _rRHS ); 81 82 inline const SfxPoolItem* getItem() const; 83 inline void setItem( const SfxPoolItem* _pItem ); 84 }; 85 86 //==================================================================== 87 //= AttributeState (inline implementation) 88 //==================================================================== 89 //................................................................ 90 inline AttributeState::AttributeState( ) 91 :pItemHandle( NULL ) 92 ,eSimpleState( eIndetermined ) 93 { 94 } 95 96 //................................................................ 97 inline AttributeState::AttributeState( AttributeCheckState _eCheckState ) 98 :pItemHandle( NULL ) 99 ,eSimpleState( _eCheckState ) 100 { 101 } 102 103 //................................................................ 104 inline AttributeState::AttributeState( const AttributeState& _rSource ) 105 :pItemHandle( NULL ) 106 ,eSimpleState( eIndetermined ) 107 { 108 operator=( _rSource ); 109 } 110 111 //................................................................ 112 inline AttributeState& AttributeState::operator=( const AttributeState& _rSource ) 113 { 114 if ( &_rSource == this ) 115 return *this; 116 117 eSimpleState = _rSource.eSimpleState; 118 setItem( _rSource.getItem() ); 119 return *this; 120 } 121 122 //................................................................ 123 inline const SfxPoolItem* AttributeState::getItem() const 124 { 125 return pItemHandle ? &pItemHandle->GetItem() : NULL; 126 } 127 128 //................................................................ 129 inline void AttributeState::setItem( const SfxPoolItem* _pItem ) 130 { 131 if ( pItemHandle ) 132 delete pItemHandle; 133 if ( _pItem ) 134 pItemHandle = new SfxItemHandle( *const_cast< SfxPoolItem* >( _pItem ) ); 135 else 136 pItemHandle = NULL; 137 } 138 139 //................................................................ 140 inline bool AttributeState::operator==( const AttributeState& _rRHS ) 141 { 142 if ( eSimpleState != _rRHS.eSimpleState ) 143 return false; 144 145 if ( pItemHandle && !_rRHS.pItemHandle ) 146 return false; 147 148 if ( !pItemHandle && _rRHS.pItemHandle ) 149 return false; 150 151 if ( !pItemHandle && !_rRHS.pItemHandle ) 152 return true; 153 154 return ( pItemHandle->GetItem() == _rRHS.pItemHandle->GetItem() ); 155 } 156 157 //==================================================================== 158 //= IMultiAttributeDispatcher 159 //==================================================================== 160 class IMultiAttributeDispatcher 161 { 162 public: 163 virtual AttributeState getState( AttributeId _nAttributeId ) const = 0; 164 virtual void executeAttribute( AttributeId _nAttributeId, const SfxPoolItem* _pArgument ) = 0; 165 }; 166 167 //........................................................................ 168 } // namespace frm 169 //........................................................................ 170 171 #endif // FORMS_SOURCE_RICHTEXT_RTATTRIBUTES_HXX 172 173