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 : #ifndef INCLUDED_SFX2_MSG_HXX
20 : #define INCLUDED_SFX2_MSG_HXX
21 :
22 : #include <tools/rtti.hxx>
23 : #include <sfx2/shell.hxx>
24 : #include <rtl/string.hxx>
25 : #include <rtl/ustring.hxx>
26 : #include <sfx2/dllapi.h>
27 : #include <svl/itemset.hxx>
28 :
29 :
30 : #define SFX_SLOT_CACHABLE 0x0001L // exclusiv to VOLATILE, default
31 : #define SFX_SLOT_VOLATILE 0x0002L // per Timer every 2s get new,
32 : // exclusiv to CACHABLE
33 : #define SFX_SLOT_TOGGLE 0x0004L // inverted for Execute old value
34 : #define SFX_SLOT_AUTOUPDATE 0x0008L // invalidated the status automatically
35 : // after execute
36 :
37 : #define SFX_SLOT_SYNCHRON 0x0010L // exclusiv to ASYNCHRON, default
38 : #define SFX_SLOT_ASYNCHRON 0x0020L // via Post-Message, exclusiv
39 : // to SYNCHRON
40 :
41 : #define SFX_SLOT_HASCOREID 0x0040L // Slot-ID/Which-ID execute mapping
42 : #define SFX_SLOT_HASDIALOG 0x0080L // Coordinates for dialogue after recofig
43 :
44 : #define SFX_SLOT_NORECORD 0x0100L // no recording
45 : #define SFX_SLOT_RECORDPERITEM 0x0200L // each item, one statement
46 : #define SFX_SLOT_RECORDPERSET 0x0400L // The whole Set is a Statement, default
47 : #define SFX_SLOT_RECORDMANUAL 0x0800L // Recording by the application
48 : // developer is default
49 :
50 : #define SFX_SLOT_RECORDABSOLUTE 0x1000000L // Recording with absolute Target
51 : #define SFX_SLOT_STANDARD ( SFX_SLOT_CACHABLE | \
52 : SFX_SLOT_SYNCHRON | \
53 : SFX_SLOT_RECORDPERSET )
54 :
55 : #define SFX_SLOT_PROPGET 0x1000L // get property
56 : #define SFX_SLOT_PROPSET 0x2000L // set property, exclusiv to
57 : // SFX_SLOT_METHOD
58 : #define SFX_SLOT_METHOD 0x4000L // Method, exclusiv to SFX_SLOT_PROPSET
59 :
60 : #define SFX_SLOT_FASTCALL 0x8000L // No test if disabled before Execute
61 :
62 : #define SFX_SLOT_STATUSBARCONFIG 0x10000L // configurable status row
63 : #define SFX_SLOT_MENUCONFIG 0x20000L // configurable Menu
64 : #define SFX_SLOT_TOOLBOXCONFIG 0x40000L // configurable Toolboxen
65 : #define SFX_SLOT_ACCELCONFIG 0x80000L // configurable keys
66 :
67 : #define SFX_SLOT_CONTAINER 0x100000L // Operated by the container at
68 : // InPlace
69 : #define SFX_SLOT_READONLYDOC 0x200000L // also available for
70 : // read-only Documents
71 : #define SFX_SLOT_IMAGEROTATION 0x400000L // Rotate image on Vertical/
72 : // Bi-directional writing
73 : #define SFX_SLOT_IMAGEREFLECTION 0x800000L // Mirror image on Vertical/
74 : // Bi-directional writing
75 :
76 :
77 :
78 : class SfxRequest;
79 :
80 : #define SFX_EXEC_STUB( aShellClass, aExecMethod) \
81 : void SfxStub##aShellClass##aExecMethod( \
82 : SfxShell *pShell, SfxRequest& rReq) \
83 : { \
84 : static_cast<aShellClass*>(pShell)->aExecMethod( rReq ); \
85 : }
86 :
87 : #define SFX_STATE_STUB( aShellClass, aStateMethod) \
88 : void SfxStub##aShellClass##aStateMethod( \
89 : SfxShell *pShell, SfxItemSet& rSet) \
90 : { \
91 : static_cast<aShellClass*>(pShell)->aStateMethod( rSet ); \
92 : }
93 :
94 : #define SFX_STUB_PTR( aShellClass, aMethod ) \
95 : &SfxStub##aShellClass##aMethod
96 :
97 : #define SFX_STUB_PTR_EXEC_NONE &SfxShell::EmptyExecStub
98 :
99 : #define SFX_STUB_PTR_STATE_NONE &SfxShell::EmptyStateStub
100 :
101 :
102 :
103 : enum SfxSlotKind
104 : {
105 : SFX_KIND_STANDARD,
106 : SFX_KIND_ENUM,
107 : SFX_KIND_ATTR
108 : };
109 :
110 :
111 :
112 : struct SfxTypeAttrib
113 : {
114 : sal_uInt16 nAID;
115 : const char* pName;
116 : };
117 :
118 : struct SfxType
119 : {
120 : TypeId aTypeId;
121 : sal_uInt16 nAttribs;
122 : SfxTypeAttrib aAttrib[16];
123 :
124 125330 : const TypeId& Type() const
125 125330 : { return aTypeId; }
126 28252 : SfxPoolItem* CreateItem() const
127 28252 : { return (SfxPoolItem*) aTypeId(); }
128 : };
129 :
130 : struct SfxType0
131 : {
132 : TypeId aTypeId;
133 : sal_uInt16 nAttribs;
134 :
135 : const TypeId& Type() const
136 : { return aTypeId; }
137 : SfxPoolItem* CreateItem() const
138 : { return (SfxPoolItem*) aTypeId(); }
139 : };
140 :
141 : #define SFX_DECL_TYPE(n) struct SfxType##n \
142 : { \
143 : TypeId aTypeId; \
144 : sal_uInt16 nAttribs; \
145 : SfxTypeAttrib aAttrib[n]; \
146 : }
147 :
148 : #define SFX_TYPE(Class) &a##Class##_Impl
149 :
150 : SFX_DECL_TYPE(1);
151 : SFX_DECL_TYPE(2);
152 : SFX_DECL_TYPE(3);
153 : SFX_DECL_TYPE(4);
154 : SFX_DECL_TYPE(5);
155 : SFX_DECL_TYPE(6);
156 : SFX_DECL_TYPE(7);
157 : SFX_DECL_TYPE(8);
158 : SFX_DECL_TYPE(10); // for SfxDocInfoItem
159 : SFX_DECL_TYPE(11);
160 :
161 : SFX_DECL_TYPE(13); // for SwAddPrinterItem, Sd...
162 : SFX_DECL_TYPE(14);
163 : SFX_DECL_TYPE(16); // for SwDocDisplayItem
164 : SFX_DECL_TYPE(17); // for SvxAddressItem
165 : SFX_DECL_TYPE(18); // for SvxSearchItem
166 :
167 : // all SfxTypes must be in this header
168 : #undef SFX_DECL_TYPE
169 :
170 : #define SFX_SLOT_ARG( aShellClass, id, GroupId, ExecMethodPtr, StateMethodPtr, Flags, ItemClass, nArg0, nArgs, Name, Prop ) \
171 : { id, GroupId, id, Flags | Prop, \
172 : USHRT_MAX, 0, \
173 : ExecMethodPtr, \
174 : StateMethodPtr, \
175 : (const SfxType*) &a##ItemClass##_Impl, \
176 : 0, 0, \
177 : &a##aShellClass##Args_Impl[nArg0], nArgs, 0, Name \
178 : }
179 :
180 : #define SFX_SLOT( aShellClass, id, GroupId, ExecMethodPtr, StateMethodPtr, Flags, ItemClass ) \
181 : { id, GroupId, id, Flags, \
182 : 0, 0, \
183 : ExecMethodPtr, \
184 : StateMethodPtr, \
185 : (const SfxType*) &a##ItemClass##_Impl, \
186 : 0, 0, 0, 0, 0 \
187 : }
188 :
189 : #define SFX_NEW_SLOT_ARG( aShellClass, id, hid, GroupId, pLinked, pNext, ExecMethodPtr, StateMethodPtr, Flags, DisableFlags, ItemClass, nArg0, nArgs, Prop, UnoName ) \
190 : { id, GroupId, hid, Flags | Prop, \
191 : USHRT_MAX, 0, \
192 : ExecMethodPtr, \
193 : StateMethodPtr, \
194 : (const SfxType*) &a##ItemClass##_Impl, \
195 : pLinked, pNext, \
196 : &a##aShellClass##Args_Impl[nArg0], nArgs, DisableFlags, UnoName \
197 : }
198 :
199 : #define SFX_NEW_SLOT_ENUM( SlaveId, hid, GroupId, pMaster, pNext, MasterId, Value, Flags, DisableFlags, UnoName ) \
200 : { SlaveId, GroupId, hid, Flags, \
201 : MasterId, Value, \
202 : 0, \
203 : 0, \
204 : (const SfxType*) &aSfxBoolItem_Impl, \
205 : pMaster, \
206 : pNext, \
207 : 0, 0, DisableFlags, UnoName \
208 : }
209 :
210 : class SfxPoolItem;
211 :
212 : struct SfxFormalArgument
213 : {
214 : const SfxType* pType; // Type of the parameter (SfxPoolItem subclass)
215 : const char* pName; // Name of the sParameters
216 : sal_uInt16 nSlotId; // Slot-Id for identification of the Parameters
217 :
218 : const TypeId& Type() const
219 : { return pType->aTypeId; }
220 744886 : SfxPoolItem* CreateItem() const
221 744886 : { return (SfxPoolItem*) pType->aTypeId(); }
222 : };
223 :
224 :
225 :
226 : class SfxSlot
227 : {
228 : public:
229 : sal_uInt16 nSlotId; // Unique slot-ID in Shell
230 : sal_uInt16 nGroupId; // for configuration region
231 : sal_uIntPtr nHelpId; // Usually == nSlotId
232 : sal_uIntPtr nFlags; // artihmetic ordered Flags
233 :
234 : sal_uInt16 nMasterSlotId; // Enum-Slot for example Which-Id
235 : sal_uInt16 nValue; // Value, in case of Enum-Slot
236 :
237 : SfxExecFunc fnExec; // Function to be excecuted
238 : SfxStateFunc fnState; // Function for Status
239 :
240 : const SfxType* pType; // SfxPoolItem-Type (Status)
241 :
242 : const SfxSlot* pLinkedSlot; // Master-Slot for Enum value
243 : const SfxSlot* pNextSlot; // with the same Status-Method
244 :
245 : const SfxFormalArgument* pFirstArgDef; // first formal Argument-Definition
246 : sal_uInt16 nArgDefCount; // Number of formal Argumentents
247 : long nDisableFlags; // DisableFlags that need to be
248 : // present, so that the Slot
249 : // can be enabled
250 : const char* pUnoName; // UnoName for the Slots
251 :
252 : public:
253 :
254 : SfxSlotKind GetKind() const;
255 : sal_uInt16 GetSlotId() const;
256 : sal_uIntPtr GetHelpId() const;
257 : sal_uIntPtr GetMode() const;
258 : bool IsMode( sal_uIntPtr nMode ) const;
259 : sal_uInt16 GetGroupId() const;
260 : sal_uInt16 GetMasterSlotId() const { return nMasterSlotId; }
261 : sal_uInt16 GetWhich( const SfxItemPool &rPool ) const;
262 0 : sal_uInt16 GetValue() const { return nValue; }
263 219407 : const SfxType* GetType() const { return pType; }
264 412160142 : const char* GetUnoName() const { return pUnoName; }
265 : SFX2_DLLPUBLIC OString GetCommand() const;
266 : SFX2_DLLPUBLIC OUString GetCommandString() const;
267 :
268 49403 : sal_uInt16 GetFormalArgumentCount() const { return nArgDefCount; }
269 445709 : const SfxFormalArgument& GetFormalArgument( sal_uInt16 nNo ) const
270 445709 : { return pFirstArgDef[nNo]; }
271 :
272 296896 : SfxExecFunc GetExecFnc() const { return fnExec; }
273 200696 : SfxStateFunc GetStateFnc() const { return fnState; }
274 :
275 65276 : const SfxSlot* GetLinkedSlot() const { return pLinkedSlot; }
276 209401 : const SfxSlot* GetNextSlot() const { return pNextSlot; }
277 : };
278 :
279 :
280 :
281 : // returns the id of the function
282 :
283 114097473 : inline sal_uInt16 SfxSlot::GetSlotId() const
284 : {
285 114097473 : return nSlotId;
286 : }
287 :
288 : // returns the help-id of the slot
289 :
290 : inline sal_uIntPtr SfxSlot::GetHelpId() const
291 : {
292 : return nHelpId;
293 : }
294 :
295 :
296 :
297 : // returns a bitfield with flags
298 :
299 0 : inline sal_uIntPtr SfxSlot::GetMode() const
300 : {
301 0 : return nFlags;
302 : }
303 :
304 :
305 : // determines if the specified mode is assigned
306 :
307 785023 : inline bool SfxSlot::IsMode( sal_uIntPtr nMode ) const
308 : {
309 785023 : return (nFlags & nMode) != 0;
310 : }
311 :
312 :
313 : // returns the id of the associated group
314 :
315 742622 : inline sal_uInt16 SfxSlot::GetGroupId() const
316 : {
317 742622 : return nGroupId;
318 :
319 : }
320 :
321 : #endif
322 :
323 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|