1 /************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. 19 * 20 *************************************************************/ 21 22 23 24 #ifndef FORMS_SOURCE_RICHTEXT_RTATTRIBUTES_HXX 25 #define FORMS_SOURCE_RICHTEXT_RTATTRIBUTES_HXX 26 27 #include <tools/solar.h> 28 #include <sal/types.h> 29 #include <svl/poolitem.hxx> 30 31 //........................................................................ 32 namespace frm 33 { 34 //........................................................................ 35 36 //==================================================================== 37 //= misc 38 //==================================================================== 39 /// the id of an attribute 40 typedef sal_Int32 AttributeId; 41 /// the "which id" of an item in an SfxItemSet 42 typedef sal_uInt16 WhichId; 43 /// a SFX slot id 44 typedef sal_uInt16 SfxSlotId; 45 /// a script type 46 typedef sal_uInt16 ScriptType; 47 48 //==================================================================== 49 //= AttributeCheckState 50 //==================================================================== 51 enum AttributeCheckState 52 { 53 eChecked, 54 eUnchecked, 55 eIndetermined 56 }; 57 58 //==================================================================== 59 //= AttributeState 60 //==================================================================== 61 struct AttributeState 62 { 63 private: 64 SfxItemHandle* pItemHandle; 65 66 public: 67 AttributeCheckState eSimpleState; 68 69 //................................................................ 70 inline AttributeState( ); 71 inline explicit AttributeState( AttributeCheckState _eCheckState ); 72 inline AttributeState( const AttributeState& _rSource ); 73 74 inline AttributeState& operator=( const AttributeState& _rSource ); 75 76 inline bool operator==( const AttributeState& _rRHS ); 77 78 inline const SfxPoolItem* getItem() const; 79 inline void setItem( const SfxPoolItem* _pItem ); 80 }; 81 82 //==================================================================== 83 //= AttributeState (inline implementation) 84 //==================================================================== 85 //................................................................ AttributeState()86 inline AttributeState::AttributeState( ) 87 :pItemHandle( NULL ) 88 ,eSimpleState( eIndetermined ) 89 { 90 } 91 92 //................................................................ AttributeState(AttributeCheckState _eCheckState)93 inline AttributeState::AttributeState( AttributeCheckState _eCheckState ) 94 :pItemHandle( NULL ) 95 ,eSimpleState( _eCheckState ) 96 { 97 } 98 99 //................................................................ AttributeState(const AttributeState & _rSource)100 inline AttributeState::AttributeState( const AttributeState& _rSource ) 101 :pItemHandle( NULL ) 102 ,eSimpleState( eIndetermined ) 103 { 104 operator=( _rSource ); 105 } 106 107 //................................................................ operator =(const AttributeState & _rSource)108 inline AttributeState& AttributeState::operator=( const AttributeState& _rSource ) 109 { 110 if ( &_rSource == this ) 111 return *this; 112 113 eSimpleState = _rSource.eSimpleState; 114 setItem( _rSource.getItem() ); 115 return *this; 116 } 117 118 //................................................................ getItem() const119 inline const SfxPoolItem* AttributeState::getItem() const 120 { 121 return pItemHandle ? &pItemHandle->GetItem() : NULL; 122 } 123 124 //................................................................ setItem(const SfxPoolItem * _pItem)125 inline void AttributeState::setItem( const SfxPoolItem* _pItem ) 126 { 127 if ( pItemHandle ) 128 delete pItemHandle; 129 if ( _pItem ) 130 pItemHandle = new SfxItemHandle( *const_cast< SfxPoolItem* >( _pItem ) ); 131 else 132 pItemHandle = NULL; 133 } 134 135 //................................................................ operator ==(const AttributeState & _rRHS)136 inline bool AttributeState::operator==( const AttributeState& _rRHS ) 137 { 138 if ( eSimpleState != _rRHS.eSimpleState ) 139 return false; 140 141 if ( pItemHandle && !_rRHS.pItemHandle ) 142 return false; 143 144 if ( !pItemHandle && _rRHS.pItemHandle ) 145 return false; 146 147 if ( !pItemHandle && !_rRHS.pItemHandle ) 148 return true; 149 150 return ( pItemHandle->GetItem() == _rRHS.pItemHandle->GetItem() ); 151 } 152 153 //==================================================================== 154 //= IMultiAttributeDispatcher 155 //==================================================================== 156 class IMultiAttributeDispatcher 157 { 158 public: 159 virtual AttributeState getState( AttributeId _nAttributeId ) const = 0; 160 virtual void executeAttribute( AttributeId _nAttributeId, const SfxPoolItem* _pArgument ) = 0; 161 }; 162 163 //........................................................................ 164 } // namespace frm 165 //........................................................................ 166 167 #endif // FORMS_SOURCE_RICHTEXT_RTATTRIBUTES_HXX 168 169