1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: rtattributes.hxx,v $
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 //........................................................................
41 //........................................................................
43 //====================================================================
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
;
51 typedef USHORT SfxSlotId
;
53 typedef USHORT ScriptType
;
55 //====================================================================
56 //= AttributeCheckState
57 //====================================================================
58 enum AttributeCheckState
65 //====================================================================
67 //====================================================================
71 SfxItemHandle
* pItemHandle
;
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( )
95 ,eSimpleState( eIndetermined
)
99 //................................................................
100 inline AttributeState::AttributeState( AttributeCheckState _eCheckState
)
102 ,eSimpleState( _eCheckState
)
106 //................................................................
107 inline AttributeState::AttributeState( const AttributeState
& _rSource
)
109 ,eSimpleState( eIndetermined
)
111 operator=( _rSource
);
114 //................................................................
115 inline AttributeState
& AttributeState::operator=( const AttributeState
& _rSource
)
117 if ( &_rSource
== this )
120 eSimpleState
= _rSource
.eSimpleState
;
121 setItem( _rSource
.getItem() );
125 //................................................................
126 inline const SfxPoolItem
* AttributeState::getItem() const
128 return pItemHandle
? &pItemHandle
->GetItem() : NULL
;
131 //................................................................
132 inline void AttributeState::setItem( const SfxPoolItem
* _pItem
)
137 pItemHandle
= new SfxItemHandle( *const_cast< SfxPoolItem
* >( _pItem
) );
142 //................................................................
143 inline bool AttributeState::operator==( const AttributeState
& _rRHS
)
145 if ( eSimpleState
!= _rRHS
.eSimpleState
)
148 if ( pItemHandle
&& !_rRHS
.pItemHandle
)
151 if ( !pItemHandle
&& _rRHS
.pItemHandle
)
154 if ( !pItemHandle
&& !_rRHS
.pItemHandle
)
157 return ( pItemHandle
->GetItem() == _rRHS
.pItemHandle
->GetItem() );
160 //====================================================================
161 //= IMultiAttributeDispatcher
162 //====================================================================
163 class IMultiAttributeDispatcher
166 virtual AttributeState
getState( AttributeId _nAttributeId
) const = 0;
167 virtual void executeAttribute( AttributeId _nAttributeId
, const SfxPoolItem
* _pArgument
) = 0;
170 //........................................................................
172 //........................................................................
174 #endif // FORMS_SOURCE_RICHTEXT_RTATTRIBUTES_HXX