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_COMPONENT_RTATTRIBUTEHANDLER_HXX
25 #define FORMS_SOURCE_COMPONENT_RTATTRIBUTEHANDLER_HXX
26 
27 #include "rtattributes.hxx"
28 #include <rtl/ref.hxx>
29 #include <editeng/svxenum.hxx>
30 #include <editeng/frmdir.hxx>
31 
32 class SfxItemSet;
33 class SfxPoolItem;
34 class SfxItemPool;
35 //........................................................................
36 namespace frm
37 {
38 //........................................................................
39 
40 	//====================================================================
41 	//= ReferenceBase
42 	//====================================================================
43     class ReferenceBase : public ::rtl::IReference
44     {
45     protected:
46         oslInterlockedCount m_refCount;
47 
48     public:
49         // IReference
50 	    virtual oslInterlockedCount SAL_CALL acquire();
51 	    virtual oslInterlockedCount SAL_CALL release();
52 
53     protected:
54         virtual ~ReferenceBase();
55     };
56 
57     //====================================================================
58 	//= IAttributeHandler
59 	//====================================================================
60     class IAttributeHandler : public ::rtl::IReference
61     {
62     public:
63         virtual     AttributeId     getAttributeId( ) const = 0;
64         virtual     AttributeState  getState( const SfxItemSet& _rAttribs ) const = 0;
65         virtual     void            executeAttribute( const SfxItemSet& _rCurrentAttribs, SfxItemSet& _rNewAttribs, const SfxPoolItem* _pAdditionalArg, ScriptType _nForScriptType ) const = 0;
66     };
67 
68     //====================================================================
69 	//= AttributeHandler
70 	//====================================================================
71     class AttributeHandler  :public ReferenceBase
72                             ,public IAttributeHandler
73 	{
74     private:
75         AttributeId     m_nAttribute;
76         WhichId         m_nWhich;
77 
78     protected:
getAttribute() const79         AttributeId getAttribute() const { return m_nAttribute; }
getWhich() const80         WhichId     getWhich() const     { return m_nWhich;     }
81 
82     public:
83         AttributeHandler( AttributeId _nAttributeId, WhichId _nWhichId );
84 
85         // IAttributeHandler
86         virtual     AttributeId     getAttributeId( ) const;
87         virtual     AttributeState  getState( const SfxItemSet& _rAttribs ) const;
88         virtual     void            executeAttribute( const SfxItemSet& _rCurrentAttribs, SfxItemSet& _rNewAttribs, const SfxPoolItem* _pAdditionalArg, ScriptType _nForScriptType ) const = 0;
89 
90     protected:
91         /// helper method calling implGetCheckState
92         AttributeCheckState getCheckState( const SfxItemSet& _rAttribs ) const;
93 
94         /// helper method putting an item into a set, respecting a script type
95         void        putItemForScript( SfxItemSet& _rAttribs, const SfxPoolItem& _rItem, ScriptType _nForScriptType ) const;
96 
97         // pseudo-abstract
98         virtual     AttributeCheckState  implGetCheckState( const SfxPoolItem& _rItem ) const;
99 
100         // disambiguate IReference
101 	    virtual oslInterlockedCount SAL_CALL acquire();
102 	    virtual oslInterlockedCount SAL_CALL release();
103 
104     protected:
105         virtual ~AttributeHandler();
106 	};
107 
108     //====================================================================
109 	//= AttributeHandlerFactory
110 	//====================================================================
111     class AttributeHandlerFactory
112     {
113     public:
114         static ::rtl::Reference< IAttributeHandler > getHandlerFor( AttributeId _nAttributeId, const SfxItemPool& _rEditEnginePool );
115 
116     private:
117         AttributeHandlerFactory();                                              // never implemented
118         AttributeHandlerFactory( const AttributeHandlerFactory& );              // never implemented
119         AttributeHandlerFactory& operator=( const AttributeHandlerFactory& );   // never implemented
120         ~AttributeHandlerFactory();                                             // never implemented
121     };
122 
123     //====================================================================
124 	//= ParaAlignmentHandler
125 	//====================================================================
126     class ParaAlignmentHandler : public AttributeHandler
127     {
128     private:
129         SvxAdjust   m_eAdjust;
130 
131     public:
132         ParaAlignmentHandler( AttributeId _nAttributeId );
133 
134     public:
135         virtual     AttributeCheckState implGetCheckState( const SfxPoolItem& _rItem ) const;
136         virtual     void                executeAttribute( const SfxItemSet& _rCurrentAttribs, SfxItemSet& _rNewAttribs, const SfxPoolItem* _pAdditionalArg, ScriptType _nForScriptType ) const;
137     };
138 
139     //====================================================================
140 	//= LineSpacingHandler
141 	//====================================================================
142     class LineSpacingHandler : public AttributeHandler
143     {
144     private:
145         sal_uInt16  m_nLineSpace;
146 
147     public:
148         LineSpacingHandler( AttributeId _nAttributeId );
149 
150     public:
151         virtual     AttributeCheckState implGetCheckState( const SfxPoolItem& _rItem ) const;
152         virtual     void                executeAttribute( const SfxItemSet& _rCurrentAttribs, SfxItemSet& _rNewAttribs, const SfxPoolItem* _pAdditionalArg, ScriptType _nForScriptType ) const;
153     };
154 
155     //====================================================================
156 	//= EscapementHandler
157 	//====================================================================
158     class EscapementHandler : public AttributeHandler
159     {
160     private:
161         SvxEscapement   m_eEscapement;
162 
163     public:
164         EscapementHandler( AttributeId _nAttributeId );
165 
166     public:
167         virtual     AttributeCheckState implGetCheckState( const SfxPoolItem& _rItem ) const;
168         virtual     void                executeAttribute( const SfxItemSet& _rCurrentAttribs, SfxItemSet& _rNewAttribs, const SfxPoolItem* _pAdditionalArg, ScriptType _nForScriptType ) const;
169     };
170 
171     //====================================================================
172 	//= SlotHandler
173 	//====================================================================
174     class SlotHandler : public AttributeHandler
175     {
176     private:
177         bool    m_bScriptDependent;
178 
179     public:
180         SlotHandler( AttributeId _nAttributeId, WhichId _nWhichId );
181 
182     public:
183         virtual     AttributeState  getState( const SfxItemSet& _rAttribs ) const;
184         virtual     void            executeAttribute( const SfxItemSet& _rCurrentAttribs, SfxItemSet& _rNewAttribs, const SfxPoolItem* _pAdditionalArg, ScriptType _nForScriptType ) const;
185     };
186 
187     //====================================================================
188 	//= BooleanHandler
189 	//====================================================================
190     class BooleanHandler : public AttributeHandler
191     {
192     public:
193         BooleanHandler( AttributeId _nAttributeId, WhichId _nWhichId );
194 
195     public:
196         virtual     AttributeCheckState implGetCheckState( const SfxPoolItem& _rItem ) const;
197         virtual     void                executeAttribute( const SfxItemSet& _rCurrentAttribs, SfxItemSet& _rNewAttribs, const SfxPoolItem* _pAdditionalArg, ScriptType _nForScriptType ) const;
198     };
199 
200     //====================================================================
201 	//= FontSizeHandler
202 	//====================================================================
203     class FontSizeHandler : public AttributeHandler
204     {
205     public:
206         FontSizeHandler( AttributeId _nAttributeId, WhichId _nWhichId );
207 
208     public:
209         virtual     AttributeState  getState( const SfxItemSet& _rAttribs ) const;
210         virtual     void            executeAttribute( const SfxItemSet& _rCurrentAttribs, SfxItemSet& _rNewAttribs, const SfxPoolItem* _pAdditionalArg, ScriptType _nForScriptType ) const;
211     };
212 
213     //====================================================================
214 	//= ParagraphDirectionHandler
215 	//====================================================================
216     class ParagraphDirectionHandler : public AttributeHandler
217     {
218     private:
219         SvxFrameDirection   m_eParagraphDirection;
220         SvxAdjust           m_eDefaultAdjustment;
221         SvxAdjust           m_eOppositeDefaultAdjustment;
222 
223     public:
224         ParagraphDirectionHandler( AttributeId _nAttributeId );
225 
226     public:
227         virtual     AttributeCheckState implGetCheckState( const SfxPoolItem& _rItem ) const;
228         virtual     void                executeAttribute( const SfxItemSet& _rCurrentAttribs, SfxItemSet& _rNewAttribs, const SfxPoolItem* _pAdditionalArg, ScriptType _nForScriptType ) const;
229     };
230 
231 //........................................................................
232 } // namespace frm
233 //........................................................................
234 
235 #endif // FORMS_SOURCE_COMPONENT_RTATTRIBUTEHANDLER_HXX
236 
237