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 : #include <salhelper/simplereferenceobject.hxx>
28 :
29 : class SfxItemSet;
30 : class SfxPoolItem;
31 : class SfxItemPool;
32 :
33 : namespace frm
34 : {
35 :
36 0 : class IAttributeHandler : public salhelper::SimpleReferenceObject
37 : {
38 : public:
39 : virtual AttributeId getAttributeId( ) const = 0;
40 : virtual AttributeState getState( const SfxItemSet& _rAttribs ) const = 0;
41 : virtual void executeAttribute( const SfxItemSet& _rCurrentAttribs, SfxItemSet& _rNewAttribs, const SfxPoolItem* _pAdditionalArg, ScriptType _nForScriptType ) const = 0;
42 :
43 : protected:
44 0 : virtual ~IAttributeHandler() {}
45 : };
46 :
47 : class AttributeHandler : public IAttributeHandler
48 : {
49 : private:
50 : AttributeId m_nAttribute;
51 : WhichId m_nWhich;
52 :
53 : protected:
54 0 : AttributeId getAttribute() const { return m_nAttribute; }
55 0 : WhichId getWhich() const { return m_nWhich; }
56 :
57 : public:
58 : AttributeHandler( AttributeId _nAttributeId, WhichId _nWhichId );
59 :
60 : // IAttributeHandler
61 : virtual AttributeId getAttributeId( ) const SAL_OVERRIDE;
62 : virtual AttributeState getState( const SfxItemSet& _rAttribs ) const SAL_OVERRIDE;
63 : virtual void executeAttribute( const SfxItemSet& _rCurrentAttribs, SfxItemSet& _rNewAttribs, const SfxPoolItem* _pAdditionalArg, ScriptType _nForScriptType ) const SAL_OVERRIDE = 0;
64 :
65 : protected:
66 : /// helper method calling implGetCheckState
67 : AttributeCheckState getCheckState( const SfxItemSet& _rAttribs ) const;
68 :
69 : /// helper method putting an item into a set, respecting a script type
70 : void putItemForScript( SfxItemSet& _rAttribs, const SfxPoolItem& _rItem, ScriptType _nForScriptType ) const;
71 :
72 : // pseudo-abstract
73 : virtual AttributeCheckState implGetCheckState( const SfxPoolItem& _rItem ) const;
74 :
75 : protected:
76 : virtual ~AttributeHandler();
77 : };
78 :
79 : class AttributeHandlerFactory
80 : {
81 : public:
82 : static ::rtl::Reference< IAttributeHandler > getHandlerFor( AttributeId _nAttributeId, const SfxItemPool& _rEditEnginePool );
83 :
84 : private:
85 : AttributeHandlerFactory(); // never implemented
86 : AttributeHandlerFactory( const AttributeHandlerFactory& ); // never implemented
87 : AttributeHandlerFactory& operator=( const AttributeHandlerFactory& ); // never implemented
88 : ~AttributeHandlerFactory(); // never implemented
89 : };
90 :
91 0 : class ParaAlignmentHandler : public AttributeHandler
92 : {
93 : private:
94 : SvxAdjust m_eAdjust;
95 :
96 : public:
97 : ParaAlignmentHandler( AttributeId _nAttributeId );
98 :
99 : public:
100 : virtual AttributeCheckState implGetCheckState( const SfxPoolItem& _rItem ) const SAL_OVERRIDE;
101 : virtual void executeAttribute( const SfxItemSet& _rCurrentAttribs, SfxItemSet& _rNewAttribs, const SfxPoolItem* _pAdditionalArg, ScriptType _nForScriptType ) const SAL_OVERRIDE;
102 : };
103 :
104 0 : class LineSpacingHandler : public AttributeHandler
105 : {
106 : private:
107 : sal_uInt16 m_nLineSpace;
108 :
109 : public:
110 : LineSpacingHandler( AttributeId _nAttributeId );
111 :
112 : public:
113 : virtual AttributeCheckState implGetCheckState( const SfxPoolItem& _rItem ) const SAL_OVERRIDE;
114 : virtual void executeAttribute( const SfxItemSet& _rCurrentAttribs, SfxItemSet& _rNewAttribs, const SfxPoolItem* _pAdditionalArg, ScriptType _nForScriptType ) const SAL_OVERRIDE;
115 : };
116 :
117 0 : class EscapementHandler : public AttributeHandler
118 : {
119 : private:
120 : SvxEscapement m_eEscapement;
121 :
122 : public:
123 : EscapementHandler( AttributeId _nAttributeId );
124 :
125 : public:
126 : virtual AttributeCheckState implGetCheckState( const SfxPoolItem& _rItem ) const SAL_OVERRIDE;
127 : virtual void executeAttribute( const SfxItemSet& _rCurrentAttribs, SfxItemSet& _rNewAttribs, const SfxPoolItem* _pAdditionalArg, ScriptType _nForScriptType ) const SAL_OVERRIDE;
128 : };
129 :
130 0 : class SlotHandler : public AttributeHandler
131 : {
132 : private:
133 : bool m_bScriptDependent;
134 :
135 : public:
136 : SlotHandler( AttributeId _nAttributeId, WhichId _nWhichId );
137 :
138 : public:
139 : virtual AttributeState getState( const SfxItemSet& _rAttribs ) const SAL_OVERRIDE;
140 : virtual void executeAttribute( const SfxItemSet& _rCurrentAttribs, SfxItemSet& _rNewAttribs, const SfxPoolItem* _pAdditionalArg, ScriptType _nForScriptType ) const SAL_OVERRIDE;
141 : };
142 :
143 0 : class BooleanHandler : public AttributeHandler
144 : {
145 : public:
146 : BooleanHandler( AttributeId _nAttributeId, WhichId _nWhichId );
147 :
148 : public:
149 : virtual AttributeCheckState implGetCheckState( const SfxPoolItem& _rItem ) const SAL_OVERRIDE;
150 : virtual void executeAttribute( const SfxItemSet& _rCurrentAttribs, SfxItemSet& _rNewAttribs, const SfxPoolItem* _pAdditionalArg, ScriptType _nForScriptType ) const SAL_OVERRIDE;
151 : };
152 :
153 0 : class FontSizeHandler : public AttributeHandler
154 : {
155 : public:
156 : FontSizeHandler( AttributeId _nAttributeId, WhichId _nWhichId );
157 :
158 : public:
159 : virtual AttributeState getState( const SfxItemSet& _rAttribs ) const SAL_OVERRIDE;
160 : virtual void executeAttribute( const SfxItemSet& _rCurrentAttribs, SfxItemSet& _rNewAttribs, const SfxPoolItem* _pAdditionalArg, ScriptType _nForScriptType ) const SAL_OVERRIDE;
161 : };
162 :
163 0 : class ParagraphDirectionHandler : public AttributeHandler
164 : {
165 : private:
166 : SvxFrameDirection m_eParagraphDirection;
167 : SvxAdjust m_eDefaultAdjustment;
168 : SvxAdjust m_eOppositeDefaultAdjustment;
169 :
170 : public:
171 : ParagraphDirectionHandler( AttributeId _nAttributeId );
172 :
173 : public:
174 : virtual AttributeCheckState implGetCheckState( const SfxPoolItem& _rItem ) const SAL_OVERRIDE;
175 : virtual void executeAttribute( const SfxItemSet& _rCurrentAttribs, SfxItemSet& _rNewAttribs, const SfxPoolItem* _pAdditionalArg, ScriptType _nForScriptType ) const SAL_OVERRIDE;
176 : };
177 :
178 :
179 : } // namespace frm
180 :
181 :
182 : #endif // INCLUDED_FORMS_SOURCE_RICHTEXT_RTATTRIBUTEHANDLER_HXX
183 :
184 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|