update dev300-m58
[ooovba.git] / forms / source / richtext / rtattributehandler.hxx
blobb646ef269ca2ac5fec7afbf2ced1794c49ac873d
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: rtattributehandler.hxx,v $
10 * $Revision: 1.4 $
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_COMPONENT_RTATTRIBUTEHANDLER_HXX
32 #define FORMS_SOURCE_COMPONENT_RTATTRIBUTEHANDLER_HXX
34 #include "rtattributes.hxx"
35 #include <rtl/ref.hxx>
36 #include <svx/svxenum.hxx>
37 #include <svx/frmdir.hxx>
39 class SfxItemSet;
40 class SfxPoolItem;
41 class SfxItemPool;
42 //........................................................................
43 namespace frm
45 //........................................................................
47 //====================================================================
48 //= ReferenceBase
49 //====================================================================
50 class ReferenceBase : public ::rtl::IReference
52 protected:
53 oslInterlockedCount m_refCount;
55 public:
56 // IReference
57 virtual oslInterlockedCount SAL_CALL acquire();
58 virtual oslInterlockedCount SAL_CALL release();
60 protected:
61 virtual ~ReferenceBase();
64 //====================================================================
65 //= IAttributeHandler
66 //====================================================================
67 class IAttributeHandler : public ::rtl::IReference
69 public:
70 virtual AttributeId getAttributeId( ) const = 0;
71 virtual AttributeState getState( const SfxItemSet& _rAttribs ) const = 0;
72 virtual void executeAttribute( const SfxItemSet& _rCurrentAttribs, SfxItemSet& _rNewAttribs, const SfxPoolItem* _pAdditionalArg, ScriptType _nForScriptType ) const = 0;
75 //====================================================================
76 //= AttributeHandler
77 //====================================================================
78 class AttributeHandler :public ReferenceBase
79 ,public IAttributeHandler
81 private:
82 AttributeId m_nAttribute;
83 WhichId m_nWhich;
85 protected:
86 AttributeId getAttribute() const { return m_nAttribute; }
87 WhichId getWhich() const { return m_nWhich; }
89 public:
90 AttributeHandler( AttributeId _nAttributeId, WhichId _nWhichId );
92 // IAttributeHandler
93 virtual AttributeId getAttributeId( ) const;
94 virtual AttributeState getState( const SfxItemSet& _rAttribs ) const;
95 virtual void executeAttribute( const SfxItemSet& _rCurrentAttribs, SfxItemSet& _rNewAttribs, const SfxPoolItem* _pAdditionalArg, ScriptType _nForScriptType ) const = 0;
97 protected:
98 /// helper method calling implGetCheckState
99 AttributeCheckState getCheckState( const SfxItemSet& _rAttribs ) const;
101 /// helper method putting an item into a set, respecting a script type
102 void putItemForScript( SfxItemSet& _rAttribs, const SfxPoolItem& _rItem, ScriptType _nForScriptType ) const;
104 // pseudo-abstract
105 virtual AttributeCheckState implGetCheckState( const SfxPoolItem& _rItem ) const;
107 // disambiguate IReference
108 virtual oslInterlockedCount SAL_CALL acquire();
109 virtual oslInterlockedCount SAL_CALL release();
111 protected:
112 virtual ~AttributeHandler();
115 //====================================================================
116 //= AttributeHandlerFactory
117 //====================================================================
118 class AttributeHandlerFactory
120 public:
121 static ::rtl::Reference< IAttributeHandler > getHandlerFor( AttributeId _nAttributeId, const SfxItemPool& _rEditEnginePool );
123 private:
124 AttributeHandlerFactory(); // never implemented
125 AttributeHandlerFactory( const AttributeHandlerFactory& ); // never implemented
126 AttributeHandlerFactory& operator=( const AttributeHandlerFactory& ); // never implemented
127 ~AttributeHandlerFactory(); // never implemented
130 //====================================================================
131 //= ParaAlignmentHandler
132 //====================================================================
133 class ParaAlignmentHandler : public AttributeHandler
135 private:
136 SvxAdjust m_eAdjust;
138 public:
139 ParaAlignmentHandler( AttributeId _nAttributeId );
141 public:
142 virtual AttributeCheckState implGetCheckState( const SfxPoolItem& _rItem ) const;
143 virtual void executeAttribute( const SfxItemSet& _rCurrentAttribs, SfxItemSet& _rNewAttribs, const SfxPoolItem* _pAdditionalArg, ScriptType _nForScriptType ) const;
146 //====================================================================
147 //= LineSpacingHandler
148 //====================================================================
149 class LineSpacingHandler : public AttributeHandler
151 private:
152 USHORT m_nLineSpace;
154 public:
155 LineSpacingHandler( AttributeId _nAttributeId );
157 public:
158 virtual AttributeCheckState implGetCheckState( const SfxPoolItem& _rItem ) const;
159 virtual void executeAttribute( const SfxItemSet& _rCurrentAttribs, SfxItemSet& _rNewAttribs, const SfxPoolItem* _pAdditionalArg, ScriptType _nForScriptType ) const;
162 //====================================================================
163 //= EscapementHandler
164 //====================================================================
165 class EscapementHandler : public AttributeHandler
167 private:
168 SvxEscapement m_eEscapement;
170 public:
171 EscapementHandler( AttributeId _nAttributeId );
173 public:
174 virtual AttributeCheckState implGetCheckState( const SfxPoolItem& _rItem ) const;
175 virtual void executeAttribute( const SfxItemSet& _rCurrentAttribs, SfxItemSet& _rNewAttribs, const SfxPoolItem* _pAdditionalArg, ScriptType _nForScriptType ) const;
178 //====================================================================
179 //= SlotHandler
180 //====================================================================
181 class SlotHandler : public AttributeHandler
183 private:
184 bool m_bScriptDependent;
186 public:
187 SlotHandler( AttributeId _nAttributeId, WhichId _nWhichId );
189 public:
190 virtual AttributeState getState( const SfxItemSet& _rAttribs ) const;
191 virtual void executeAttribute( const SfxItemSet& _rCurrentAttribs, SfxItemSet& _rNewAttribs, const SfxPoolItem* _pAdditionalArg, ScriptType _nForScriptType ) const;
194 //====================================================================
195 //= BooleanHandler
196 //====================================================================
197 class BooleanHandler : public AttributeHandler
199 public:
200 BooleanHandler( AttributeId _nAttributeId, WhichId _nWhichId );
202 public:
203 virtual AttributeCheckState implGetCheckState( const SfxPoolItem& _rItem ) const;
204 virtual void executeAttribute( const SfxItemSet& _rCurrentAttribs, SfxItemSet& _rNewAttribs, const SfxPoolItem* _pAdditionalArg, ScriptType _nForScriptType ) const;
207 //====================================================================
208 //= FontSizeHandler
209 //====================================================================
210 class FontSizeHandler : public AttributeHandler
212 public:
213 FontSizeHandler( AttributeId _nAttributeId, WhichId _nWhichId );
215 public:
216 virtual AttributeState getState( const SfxItemSet& _rAttribs ) const;
217 virtual void executeAttribute( const SfxItemSet& _rCurrentAttribs, SfxItemSet& _rNewAttribs, const SfxPoolItem* _pAdditionalArg, ScriptType _nForScriptType ) const;
220 //====================================================================
221 //= ParagraphDirectionHandler
222 //====================================================================
223 class ParagraphDirectionHandler : public AttributeHandler
225 private:
226 SvxFrameDirection m_eParagraphDirection;
227 SvxAdjust m_eDefaultAdjustment;
228 SvxAdjust m_eOppositeDefaultAdjustment;
230 public:
231 ParagraphDirectionHandler( AttributeId _nAttributeId );
233 public:
234 virtual AttributeCheckState implGetCheckState( const SfxPoolItem& _rItem ) const;
235 virtual void executeAttribute( const SfxItemSet& _rCurrentAttribs, SfxItemSet& _rNewAttribs, const SfxPoolItem* _pAdditionalArg, ScriptType _nForScriptType ) const;
238 //........................................................................
239 } // namespace frm
240 //........................................................................
242 #endif // FORMS_SOURCE_COMPONENT_RTATTRIBUTEHANDLER_HXX