1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: rtattributehandler.hxx,v $
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>
42 //........................................................................
45 //........................................................................
47 //====================================================================
49 //====================================================================
50 class ReferenceBase
: public ::rtl::IReference
53 oslInterlockedCount m_refCount
;
57 virtual oslInterlockedCount SAL_CALL
acquire();
58 virtual oslInterlockedCount SAL_CALL
release();
61 virtual ~ReferenceBase();
64 //====================================================================
66 //====================================================================
67 class IAttributeHandler
: public ::rtl::IReference
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 //====================================================================
77 //====================================================================
78 class AttributeHandler
:public ReferenceBase
79 ,public IAttributeHandler
82 AttributeId m_nAttribute
;
86 AttributeId
getAttribute() const { return m_nAttribute
; }
87 WhichId
getWhich() const { return m_nWhich
; }
90 AttributeHandler( AttributeId _nAttributeId
, WhichId _nWhichId
);
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;
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;
105 virtual AttributeCheckState
implGetCheckState( const SfxPoolItem
& _rItem
) const;
107 // disambiguate IReference
108 virtual oslInterlockedCount SAL_CALL
acquire();
109 virtual oslInterlockedCount SAL_CALL
release();
112 virtual ~AttributeHandler();
115 //====================================================================
116 //= AttributeHandlerFactory
117 //====================================================================
118 class AttributeHandlerFactory
121 static ::rtl::Reference
< IAttributeHandler
> getHandlerFor( AttributeId _nAttributeId
, const SfxItemPool
& _rEditEnginePool
);
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
139 ParaAlignmentHandler( AttributeId _nAttributeId
);
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
155 LineSpacingHandler( AttributeId _nAttributeId
);
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
168 SvxEscapement m_eEscapement
;
171 EscapementHandler( AttributeId _nAttributeId
);
174 virtual AttributeCheckState
implGetCheckState( const SfxPoolItem
& _rItem
) const;
175 virtual void executeAttribute( const SfxItemSet
& _rCurrentAttribs
, SfxItemSet
& _rNewAttribs
, const SfxPoolItem
* _pAdditionalArg
, ScriptType _nForScriptType
) const;
178 //====================================================================
180 //====================================================================
181 class SlotHandler
: public AttributeHandler
184 bool m_bScriptDependent
;
187 SlotHandler( AttributeId _nAttributeId
, WhichId _nWhichId
);
190 virtual AttributeState
getState( const SfxItemSet
& _rAttribs
) const;
191 virtual void executeAttribute( const SfxItemSet
& _rCurrentAttribs
, SfxItemSet
& _rNewAttribs
, const SfxPoolItem
* _pAdditionalArg
, ScriptType _nForScriptType
) const;
194 //====================================================================
196 //====================================================================
197 class BooleanHandler
: public AttributeHandler
200 BooleanHandler( AttributeId _nAttributeId
, WhichId _nWhichId
);
203 virtual AttributeCheckState
implGetCheckState( const SfxPoolItem
& _rItem
) const;
204 virtual void executeAttribute( const SfxItemSet
& _rCurrentAttribs
, SfxItemSet
& _rNewAttribs
, const SfxPoolItem
* _pAdditionalArg
, ScriptType _nForScriptType
) const;
207 //====================================================================
209 //====================================================================
210 class FontSizeHandler
: public AttributeHandler
213 FontSizeHandler( AttributeId _nAttributeId
, WhichId _nWhichId
);
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
226 SvxFrameDirection m_eParagraphDirection
;
227 SvxAdjust m_eDefaultAdjustment
;
228 SvxAdjust m_eOppositeDefaultAdjustment
;
231 ParagraphDirectionHandler( AttributeId _nAttributeId
);
234 virtual AttributeCheckState
implGetCheckState( const SfxPoolItem
& _rItem
) const;
235 virtual void executeAttribute( const SfxItemSet
& _rCurrentAttribs
, SfxItemSet
& _rNewAttribs
, const SfxPoolItem
* _pAdditionalArg
, ScriptType _nForScriptType
) const;
238 //........................................................................
240 //........................................................................
242 #endif // FORMS_SOURCE_COMPONENT_RTATTRIBUTEHANDLER_HXX