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