update dev300-m58
[ooovba.git] / forms / source / richtext / rtattributes.hxx
blob16d51503041eb4c3c390e8abf5d67d9e35685332
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: rtattributes.hxx,v $
10 * $Revision: 1.5 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #ifndef FORMS_SOURCE_RICHTEXT_RTATTRIBUTES_HXX
32 #define FORMS_SOURCE_RICHTEXT_RTATTRIBUTES_HXX
34 #include <tools/solar.h>
35 #include <sal/types.h>
36 #include <svtools/poolitem.hxx>
38 //........................................................................
39 namespace frm
41 //........................................................................
43 //====================================================================
44 //= misc
45 //====================================================================
46 /// the id of an attribute
47 typedef sal_Int32 AttributeId;
48 /// the "which id" of an item in an SfxItemSet
49 typedef USHORT WhichId;
50 /// a SFX slot id
51 typedef USHORT SfxSlotId;
52 /// a script type
53 typedef USHORT ScriptType;
55 //====================================================================
56 //= AttributeCheckState
57 //====================================================================
58 enum AttributeCheckState
60 eChecked,
61 eUnchecked,
62 eIndetermined
65 //====================================================================
66 //= AttributeState
67 //====================================================================
68 struct AttributeState
70 private:
71 SfxItemHandle* pItemHandle;
73 public:
74 AttributeCheckState eSimpleState;
76 //................................................................
77 inline AttributeState( );
78 inline explicit AttributeState( AttributeCheckState _eCheckState );
79 inline AttributeState( const AttributeState& _rSource );
81 inline AttributeState& operator=( const AttributeState& _rSource );
83 inline bool operator==( const AttributeState& _rRHS );
85 inline const SfxPoolItem* getItem() const;
86 inline void setItem( const SfxPoolItem* _pItem );
89 //====================================================================
90 //= AttributeState (inline implementation)
91 //====================================================================
92 //................................................................
93 inline AttributeState::AttributeState( )
94 :pItemHandle( NULL )
95 ,eSimpleState( eIndetermined )
99 //................................................................
100 inline AttributeState::AttributeState( AttributeCheckState _eCheckState )
101 :pItemHandle( NULL )
102 ,eSimpleState( _eCheckState )
106 //................................................................
107 inline AttributeState::AttributeState( const AttributeState& _rSource )
108 :pItemHandle( NULL )
109 ,eSimpleState( eIndetermined )
111 operator=( _rSource );
114 //................................................................
115 inline AttributeState& AttributeState::operator=( const AttributeState& _rSource )
117 if ( &_rSource == this )
118 return *this;
120 eSimpleState = _rSource.eSimpleState;
121 setItem( _rSource.getItem() );
122 return *this;
125 //................................................................
126 inline const SfxPoolItem* AttributeState::getItem() const
128 return pItemHandle ? &pItemHandle->GetItem() : NULL;
131 //................................................................
132 inline void AttributeState::setItem( const SfxPoolItem* _pItem )
134 if ( pItemHandle )
135 delete pItemHandle;
136 if ( _pItem )
137 pItemHandle = new SfxItemHandle( *const_cast< SfxPoolItem* >( _pItem ) );
138 else
139 pItemHandle = NULL;
142 //................................................................
143 inline bool AttributeState::operator==( const AttributeState& _rRHS )
145 if ( eSimpleState != _rRHS.eSimpleState )
146 return false;
148 if ( pItemHandle && !_rRHS.pItemHandle )
149 return false;
151 if ( !pItemHandle && _rRHS.pItemHandle )
152 return false;
154 if ( !pItemHandle && !_rRHS.pItemHandle )
155 return true;
157 return ( pItemHandle->GetItem() == _rRHS.pItemHandle->GetItem() );
160 //====================================================================
161 //= IMultiAttributeDispatcher
162 //====================================================================
163 class IMultiAttributeDispatcher
165 public:
166 virtual AttributeState getState( AttributeId _nAttributeId ) const = 0;
167 virtual void executeAttribute( AttributeId _nAttributeId, const SfxPoolItem* _pArgument ) = 0;
170 //........................................................................
171 } // namespace frm
172 //........................................................................
174 #endif // FORMS_SOURCE_RICHTEXT_RTATTRIBUTES_HXX