Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
5 : * This Source Code Form is subject to the terms of the Mozilla Public
6 : * License, v. 2.0. If a copy of the MPL was not distributed with this
7 : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
11 : * Licensed to the Apache Software Foundation (ASF) under one or more
12 : * contributor license agreements. See the NOTICE file distributed
13 : * with this work for additional information regarding copyright
14 : * ownership. The ASF licenses this file to you under the Apache
15 : * License, Version 2.0 (the "License"); you may not use this file
16 : * except in compliance with the License. You may obtain a copy of
17 : * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 : */
19 :
20 : #ifndef INCLUDED_FORMS_SOURCE_RICHTEXT_RTATTRIBUTEHANDLER_HXX
21 : #define INCLUDED_FORMS_SOURCE_RICHTEXT_RTATTRIBUTEHANDLER_HXX
22 :
23 : #include "rtattributes.hxx"
24 : #include <rtl/ref.hxx>
25 : #include <editeng/svxenum.hxx>
26 : #include <editeng/frmdir.hxx>
27 :
28 : class SfxItemSet;
29 : class SfxPoolItem;
30 : class SfxItemPool;
31 :
32 : namespace frm
33 : {
34 :
35 :
36 :
37 : //= ReferenceBase
38 :
39 0 : class ReferenceBase : public ::rtl::IReference
40 : {
41 : protected:
42 : oslInterlockedCount m_refCount;
43 :
44 : public:
45 : // IReference
46 : virtual oslInterlockedCount SAL_CALL acquire() SAL_OVERRIDE;
47 : virtual oslInterlockedCount SAL_CALL release() SAL_OVERRIDE;
48 :
49 : protected:
50 : virtual ~ReferenceBase();
51 : };
52 :
53 :
54 : //= IAttributeHandler
55 :
56 0 : class IAttributeHandler : public ::rtl::IReference
57 : {
58 : public:
59 : virtual AttributeId getAttributeId( ) const = 0;
60 : virtual AttributeState getState( const SfxItemSet& _rAttribs ) const = 0;
61 : virtual void executeAttribute( const SfxItemSet& _rCurrentAttribs, SfxItemSet& _rNewAttribs, const SfxPoolItem* _pAdditionalArg, ScriptType _nForScriptType ) const = 0;
62 :
63 : protected:
64 0 : ~IAttributeHandler() {}
65 : };
66 :
67 :
68 : //= AttributeHandler
69 :
70 : class AttributeHandler :public ReferenceBase
71 : ,public IAttributeHandler
72 : {
73 : private:
74 : AttributeId m_nAttribute;
75 : WhichId m_nWhich;
76 :
77 : protected:
78 0 : AttributeId getAttribute() const { return m_nAttribute; }
79 0 : WhichId getWhich() const { return m_nWhich; }
80 :
81 : public:
82 : AttributeHandler( AttributeId _nAttributeId, WhichId _nWhichId );
83 :
84 : // IAttributeHandler
85 : virtual AttributeId getAttributeId( ) const SAL_OVERRIDE;
86 : virtual AttributeState getState( const SfxItemSet& _rAttribs ) const SAL_OVERRIDE;
87 : virtual void executeAttribute( const SfxItemSet& _rCurrentAttribs, SfxItemSet& _rNewAttribs, const SfxPoolItem* _pAdditionalArg, ScriptType _nForScriptType ) const SAL_OVERRIDE = 0;
88 :
89 : protected:
90 : /// helper method calling implGetCheckState
91 : AttributeCheckState getCheckState( const SfxItemSet& _rAttribs ) const;
92 :
93 : /// helper method putting an item into a set, respecting a script type
94 : void putItemForScript( SfxItemSet& _rAttribs, const SfxPoolItem& _rItem, ScriptType _nForScriptType ) const;
95 :
96 : // pseudo-abstract
97 : virtual AttributeCheckState implGetCheckState( const SfxPoolItem& _rItem ) const;
98 :
99 : // disambiguate IReference
100 : virtual oslInterlockedCount SAL_CALL acquire() SAL_OVERRIDE;
101 : virtual oslInterlockedCount SAL_CALL release() SAL_OVERRIDE;
102 :
103 : protected:
104 : virtual ~AttributeHandler();
105 : };
106 :
107 :
108 : //= AttributeHandlerFactory
109 :
110 : class AttributeHandlerFactory
111 : {
112 : public:
113 : static ::rtl::Reference< IAttributeHandler > getHandlerFor( AttributeId _nAttributeId, const SfxItemPool& _rEditEnginePool );
114 :
115 : private:
116 : AttributeHandlerFactory(); // never implemented
117 : AttributeHandlerFactory( const AttributeHandlerFactory& ); // never implemented
118 : AttributeHandlerFactory& operator=( const AttributeHandlerFactory& ); // never implemented
119 : ~AttributeHandlerFactory(); // never implemented
120 : };
121 :
122 :
123 : //= ParaAlignmentHandler
124 :
125 0 : class ParaAlignmentHandler : public AttributeHandler
126 : {
127 : private:
128 : SvxAdjust m_eAdjust;
129 :
130 : public:
131 : ParaAlignmentHandler( AttributeId _nAttributeId );
132 :
133 : public:
134 : virtual AttributeCheckState implGetCheckState( const SfxPoolItem& _rItem ) const SAL_OVERRIDE;
135 : virtual void executeAttribute( const SfxItemSet& _rCurrentAttribs, SfxItemSet& _rNewAttribs, const SfxPoolItem* _pAdditionalArg, ScriptType _nForScriptType ) const SAL_OVERRIDE;
136 : };
137 :
138 :
139 : //= LineSpacingHandler
140 :
141 0 : class LineSpacingHandler : public AttributeHandler
142 : {
143 : private:
144 : sal_uInt16 m_nLineSpace;
145 :
146 : public:
147 : LineSpacingHandler( AttributeId _nAttributeId );
148 :
149 : public:
150 : virtual AttributeCheckState implGetCheckState( const SfxPoolItem& _rItem ) const SAL_OVERRIDE;
151 : virtual void executeAttribute( const SfxItemSet& _rCurrentAttribs, SfxItemSet& _rNewAttribs, const SfxPoolItem* _pAdditionalArg, ScriptType _nForScriptType ) const SAL_OVERRIDE;
152 : };
153 :
154 :
155 : //= EscapementHandler
156 :
157 0 : class EscapementHandler : public AttributeHandler
158 : {
159 : private:
160 : SvxEscapement m_eEscapement;
161 :
162 : public:
163 : EscapementHandler( AttributeId _nAttributeId );
164 :
165 : public:
166 : virtual AttributeCheckState implGetCheckState( const SfxPoolItem& _rItem ) const SAL_OVERRIDE;
167 : virtual void executeAttribute( const SfxItemSet& _rCurrentAttribs, SfxItemSet& _rNewAttribs, const SfxPoolItem* _pAdditionalArg, ScriptType _nForScriptType ) const SAL_OVERRIDE;
168 : };
169 :
170 :
171 : //= SlotHandler
172 :
173 0 : class SlotHandler : public AttributeHandler
174 : {
175 : private:
176 : bool m_bScriptDependent;
177 :
178 : public:
179 : SlotHandler( AttributeId _nAttributeId, WhichId _nWhichId );
180 :
181 : public:
182 : virtual AttributeState getState( const SfxItemSet& _rAttribs ) const SAL_OVERRIDE;
183 : virtual void executeAttribute( const SfxItemSet& _rCurrentAttribs, SfxItemSet& _rNewAttribs, const SfxPoolItem* _pAdditionalArg, ScriptType _nForScriptType ) const SAL_OVERRIDE;
184 : };
185 :
186 :
187 : //= BooleanHandler
188 :
189 0 : class BooleanHandler : public AttributeHandler
190 : {
191 : public:
192 : BooleanHandler( AttributeId _nAttributeId, WhichId _nWhichId );
193 :
194 : public:
195 : virtual AttributeCheckState implGetCheckState( const SfxPoolItem& _rItem ) const SAL_OVERRIDE;
196 : virtual void executeAttribute( const SfxItemSet& _rCurrentAttribs, SfxItemSet& _rNewAttribs, const SfxPoolItem* _pAdditionalArg, ScriptType _nForScriptType ) const SAL_OVERRIDE;
197 : };
198 :
199 :
200 : //= FontSizeHandler
201 :
202 0 : class FontSizeHandler : public AttributeHandler
203 : {
204 : public:
205 : FontSizeHandler( AttributeId _nAttributeId, WhichId _nWhichId );
206 :
207 : public:
208 : virtual AttributeState getState( const SfxItemSet& _rAttribs ) const SAL_OVERRIDE;
209 : virtual void executeAttribute( const SfxItemSet& _rCurrentAttribs, SfxItemSet& _rNewAttribs, const SfxPoolItem* _pAdditionalArg, ScriptType _nForScriptType ) const SAL_OVERRIDE;
210 : };
211 :
212 :
213 : //= ParagraphDirectionHandler
214 :
215 0 : class ParagraphDirectionHandler : public AttributeHandler
216 : {
217 : private:
218 : SvxFrameDirection m_eParagraphDirection;
219 : SvxAdjust m_eDefaultAdjustment;
220 : SvxAdjust m_eOppositeDefaultAdjustment;
221 :
222 : public:
223 : ParagraphDirectionHandler( AttributeId _nAttributeId );
224 :
225 : public:
226 : virtual AttributeCheckState implGetCheckState( const SfxPoolItem& _rItem ) const SAL_OVERRIDE;
227 : virtual void executeAttribute( const SfxItemSet& _rCurrentAttribs, SfxItemSet& _rNewAttribs, const SfxPoolItem* _pAdditionalArg, ScriptType _nForScriptType ) const SAL_OVERRIDE;
228 : };
229 :
230 :
231 : } // namespace frm
232 :
233 :
234 : #endif // INCLUDED_FORMS_SOURCE_RICHTEXT_RTATTRIBUTEHANDLER_HXX
235 :
236 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|