xref: /trunk/main/forms/source/richtext/rtattributehandler.hxx (revision cdf0e10c4e3984b49a9502b011690b615761d4a3)
1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 #ifndef FORMS_SOURCE_COMPONENT_RTATTRIBUTEHANDLER_HXX
29 #define FORMS_SOURCE_COMPONENT_RTATTRIBUTEHANDLER_HXX
30 
31 #include "rtattributes.hxx"
32 #include <rtl/ref.hxx>
33 #include <editeng/svxenum.hxx>
34 #include <editeng/frmdir.hxx>
35 
36 class SfxItemSet;
37 class SfxPoolItem;
38 class SfxItemPool;
39 //........................................................................
40 namespace frm
41 {
42 //........................................................................
43 
44     //====================================================================
45     //= ReferenceBase
46     //====================================================================
47     class ReferenceBase : public ::rtl::IReference
48     {
49     protected:
50         oslInterlockedCount m_refCount;
51 
52     public:
53         // IReference
54         virtual oslInterlockedCount SAL_CALL acquire();
55         virtual oslInterlockedCount SAL_CALL release();
56 
57     protected:
58         virtual ~ReferenceBase();
59     };
60 
61     //====================================================================
62     //= IAttributeHandler
63     //====================================================================
64     class IAttributeHandler : public ::rtl::IReference
65     {
66     public:
67         virtual     AttributeId     getAttributeId( ) const = 0;
68         virtual     AttributeState  getState( const SfxItemSet& _rAttribs ) const = 0;
69         virtual     void            executeAttribute( const SfxItemSet& _rCurrentAttribs, SfxItemSet& _rNewAttribs, const SfxPoolItem* _pAdditionalArg, ScriptType _nForScriptType ) const = 0;
70     };
71 
72     //====================================================================
73     //= AttributeHandler
74     //====================================================================
75     class AttributeHandler  :public ReferenceBase
76                             ,public IAttributeHandler
77     {
78     private:
79         AttributeId     m_nAttribute;
80         WhichId         m_nWhich;
81 
82     protected:
83         AttributeId getAttribute() const { return m_nAttribute; }
84         WhichId     getWhich() const     { return m_nWhich;     }
85 
86     public:
87         AttributeHandler( AttributeId _nAttributeId, WhichId _nWhichId );
88 
89         // IAttributeHandler
90         virtual     AttributeId     getAttributeId( ) const;
91         virtual     AttributeState  getState( const SfxItemSet& _rAttribs ) const;
92         virtual     void            executeAttribute( const SfxItemSet& _rCurrentAttribs, SfxItemSet& _rNewAttribs, const SfxPoolItem* _pAdditionalArg, ScriptType _nForScriptType ) const = 0;
93 
94     protected:
95         /// helper method calling implGetCheckState
96         AttributeCheckState getCheckState( const SfxItemSet& _rAttribs ) const;
97 
98         /// helper method putting an item into a set, respecting a script type
99         void        putItemForScript( SfxItemSet& _rAttribs, const SfxPoolItem& _rItem, ScriptType _nForScriptType ) const;
100 
101         // pseudo-abstract
102         virtual     AttributeCheckState  implGetCheckState( const SfxPoolItem& _rItem ) const;
103 
104         // disambiguate IReference
105         virtual oslInterlockedCount SAL_CALL acquire();
106         virtual oslInterlockedCount SAL_CALL release();
107 
108     protected:
109         virtual ~AttributeHandler();
110     };
111 
112     //====================================================================
113     //= AttributeHandlerFactory
114     //====================================================================
115     class AttributeHandlerFactory
116     {
117     public:
118         static ::rtl::Reference< IAttributeHandler > getHandlerFor( AttributeId _nAttributeId, const SfxItemPool& _rEditEnginePool );
119 
120     private:
121         AttributeHandlerFactory();                                              // never implemented
122         AttributeHandlerFactory( const AttributeHandlerFactory& );              // never implemented
123         AttributeHandlerFactory& operator=( const AttributeHandlerFactory& );   // never implemented
124         ~AttributeHandlerFactory();                                             // never implemented
125     };
126 
127     //====================================================================
128     //= ParaAlignmentHandler
129     //====================================================================
130     class ParaAlignmentHandler : public AttributeHandler
131     {
132     private:
133         SvxAdjust   m_eAdjust;
134 
135     public:
136         ParaAlignmentHandler( AttributeId _nAttributeId );
137 
138     public:
139         virtual     AttributeCheckState implGetCheckState( const SfxPoolItem& _rItem ) const;
140         virtual     void                executeAttribute( const SfxItemSet& _rCurrentAttribs, SfxItemSet& _rNewAttribs, const SfxPoolItem* _pAdditionalArg, ScriptType _nForScriptType ) const;
141     };
142 
143     //====================================================================
144     //= LineSpacingHandler
145     //====================================================================
146     class LineSpacingHandler : public AttributeHandler
147     {
148     private:
149         sal_uInt16  m_nLineSpace;
150 
151     public:
152         LineSpacingHandler( AttributeId _nAttributeId );
153 
154     public:
155         virtual     AttributeCheckState implGetCheckState( const SfxPoolItem& _rItem ) const;
156         virtual     void                executeAttribute( const SfxItemSet& _rCurrentAttribs, SfxItemSet& _rNewAttribs, const SfxPoolItem* _pAdditionalArg, ScriptType _nForScriptType ) const;
157     };
158 
159     //====================================================================
160     //= EscapementHandler
161     //====================================================================
162     class EscapementHandler : public AttributeHandler
163     {
164     private:
165         SvxEscapement   m_eEscapement;
166 
167     public:
168         EscapementHandler( AttributeId _nAttributeId );
169 
170     public:
171         virtual     AttributeCheckState implGetCheckState( const SfxPoolItem& _rItem ) const;
172         virtual     void                executeAttribute( const SfxItemSet& _rCurrentAttribs, SfxItemSet& _rNewAttribs, const SfxPoolItem* _pAdditionalArg, ScriptType _nForScriptType ) const;
173     };
174 
175     //====================================================================
176     //= SlotHandler
177     //====================================================================
178     class SlotHandler : public AttributeHandler
179     {
180     private:
181         bool    m_bScriptDependent;
182 
183     public:
184         SlotHandler( AttributeId _nAttributeId, WhichId _nWhichId );
185 
186     public:
187         virtual     AttributeState  getState( const SfxItemSet& _rAttribs ) const;
188         virtual     void            executeAttribute( const SfxItemSet& _rCurrentAttribs, SfxItemSet& _rNewAttribs, const SfxPoolItem* _pAdditionalArg, ScriptType _nForScriptType ) const;
189     };
190 
191     //====================================================================
192     //= BooleanHandler
193     //====================================================================
194     class BooleanHandler : public AttributeHandler
195     {
196     public:
197         BooleanHandler( AttributeId _nAttributeId, WhichId _nWhichId );
198 
199     public:
200         virtual     AttributeCheckState implGetCheckState( const SfxPoolItem& _rItem ) const;
201         virtual     void                executeAttribute( const SfxItemSet& _rCurrentAttribs, SfxItemSet& _rNewAttribs, const SfxPoolItem* _pAdditionalArg, ScriptType _nForScriptType ) const;
202     };
203 
204     //====================================================================
205     //= FontSizeHandler
206     //====================================================================
207     class FontSizeHandler : public AttributeHandler
208     {
209     public:
210         FontSizeHandler( AttributeId _nAttributeId, WhichId _nWhichId );
211 
212     public:
213         virtual     AttributeState  getState( const SfxItemSet& _rAttribs ) const;
214         virtual     void            executeAttribute( const SfxItemSet& _rCurrentAttribs, SfxItemSet& _rNewAttribs, const SfxPoolItem* _pAdditionalArg, ScriptType _nForScriptType ) const;
215     };
216 
217     //====================================================================
218     //= ParagraphDirectionHandler
219     //====================================================================
220     class ParagraphDirectionHandler : public AttributeHandler
221     {
222     private:
223         SvxFrameDirection   m_eParagraphDirection;
224         SvxAdjust           m_eDefaultAdjustment;
225         SvxAdjust           m_eOppositeDefaultAdjustment;
226 
227     public:
228         ParagraphDirectionHandler( AttributeId _nAttributeId );
229 
230     public:
231         virtual     AttributeCheckState implGetCheckState( const SfxPoolItem& _rItem ) const;
232         virtual     void                executeAttribute( const SfxItemSet& _rCurrentAttribs, SfxItemSet& _rNewAttribs, const SfxPoolItem* _pAdditionalArg, ScriptType _nForScriptType ) const;
233     };
234 
235 //........................................................................
236 } // namespace frm
237 //........................................................................
238 
239 #endif // FORMS_SOURCE_COMPONENT_RTATTRIBUTEHANDLER_HXX
240 
241