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