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