bump product version to 4.2.0.1
[LibreOffice.git] / include / sfx2 / msg.hxx
blobf48284cbbb4dfbc14a63141b452c934faa090556
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
19 #ifndef INCLUDED_SFX2_MSG_HXX
20 #define INCLUDED_SFX2_MSG_HXX
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>
28 //--------------------------------------------------------------------
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
37 #define SFX_SLOT_SYNCHRON 0x0010L // exclusiv to ASYNCHRON, default
38 #define SFX_SLOT_ASYNCHRON 0x0020L // via Post-Message, exclusiv
39 // to SYNCHRON
41 #define SFX_SLOT_HASCOREID 0x0040L // Slot-ID/Which-ID execute mapping
42 #define SFX_SLOT_HASDIALOG 0x0080L // Coordinates for dialogue after recofig
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
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 )
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
60 #define SFX_SLOT_FASTCALL 0x8000L // No test if disabled before Execute
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
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
76 //--------------------------------------------------------------------
78 class SfxRequest;
79 class SfxItemSet;
81 #define SFX_EXEC_STUB( aShellClass, aExecMethod) \
82 void SfxStub##aShellClass##aExecMethod( \
83 SfxShell *pShell, SfxRequest& rReq) \
84 { \
85 (( aShellClass* ) pShell )->aExecMethod( rReq ); \
88 #define SFX_STATE_STUB( aShellClass, aStateMethod) \
89 void SfxStub##aShellClass##aStateMethod( \
90 SfxShell *pShell, SfxItemSet& rSet) \
91 { \
92 (( aShellClass* ) pShell )->aStateMethod( rSet ); \
95 #define SFX_STUB_PTR( aShellClass, aMethod ) \
96 &SfxStub##aShellClass##aMethod
98 #define SFX_STUB_PTR_EXEC_NONE &SfxShell::EmptyExecStub
100 #define SFX_STUB_PTR_STATE_NONE &SfxShell::EmptyStateStub
102 //--------------------------------------------------------------------
104 enum SfxSlotKind
106 SFX_KIND_STANDARD,
107 SFX_KIND_ENUM,
108 SFX_KIND_ATTR
111 //=========================================================================
113 struct SfxTypeAttrib
115 sal_uInt16 nAID;
116 const char* pName;
119 struct SfxType
121 TypeId aTypeId;
122 sal_uInt16 nAttribs;
123 SfxTypeAttrib aAttrib[16];
125 const TypeId& Type() const
126 { return aTypeId; }
127 SfxPoolItem* CreateItem() const
128 { return (SfxPoolItem*) aTypeId(); }
131 struct SfxType0
133 TypeId aTypeId;
134 sal_uInt16 nAttribs;
136 const TypeId& Type() const
137 { return aTypeId; }
138 SfxPoolItem* CreateItem() const
139 { return (SfxPoolItem*) aTypeId(); }
142 #define SFX_DECL_TYPE(n) struct SfxType##n \
144 TypeId aTypeId; \
145 sal_uInt16 nAttribs; \
146 SfxTypeAttrib aAttrib[n]; \
149 #define SFX_TYPE(Class) &a##Class##_Impl
151 SFX_DECL_TYPE(1);
152 SFX_DECL_TYPE(2);
153 SFX_DECL_TYPE(3);
154 SFX_DECL_TYPE(4);
155 SFX_DECL_TYPE(5);
156 SFX_DECL_TYPE(6);
157 SFX_DECL_TYPE(7);
158 SFX_DECL_TYPE(8);
159 SFX_DECL_TYPE(10); // for SfxDocInfoItem
160 SFX_DECL_TYPE(11);
162 SFX_DECL_TYPE(13); // for SwAddPrinterItem, Sd...
163 SFX_DECL_TYPE(14);
164 SFX_DECL_TYPE(16); // for SwDocDisplayItem
165 SFX_DECL_TYPE(17); // for SvxAddressItem
166 SFX_DECL_TYPE(18); // for SvxSearchItem
168 // all SfxTypes must be in this header
169 #undef SFX_DECL_TYPE
171 #define SFX_SLOT_ARG( aShellClass, id, GroupId, ExecMethodPtr, StateMethodPtr, Flags, ItemClass, nArg0, nArgs, Name, Prop ) \
172 { id, GroupId, id, Flags | Prop, \
173 USHRT_MAX, 0, \
174 ExecMethodPtr, \
175 StateMethodPtr, \
176 (const SfxType*) &a##ItemClass##_Impl, \
177 Name, Name, 0, 0, \
178 &a##aShellClass##Args_Impl[nArg0], nArgs, 0, Name \
181 #define SFX_SLOT( aShellClass, id, GroupId, ExecMethodPtr, StateMethodPtr, Flags, ItemClass ) \
182 { id, GroupId, id, Flags, \
183 0, 0, \
184 ExecMethodPtr, \
185 StateMethodPtr, \
186 (const SfxType*) &a##ItemClass##_Impl, \
187 0, 0, 0, 0, 0, 0, 0 \
190 #define SFX_NEW_SLOT_ARG( aShellClass, id, hid, GroupId, pLinked, pNext, ExecMethodPtr, StateMethodPtr, Flags, DisableFlags, ItemClass, nArg0, nArgs, Name, Prop, UnoName ) \
191 { id, GroupId, hid, Flags | Prop, \
192 USHRT_MAX, 0, \
193 ExecMethodPtr, \
194 StateMethodPtr, \
195 (const SfxType*) &a##ItemClass##_Impl, \
196 Name, Name, \
197 pLinked, pNext, \
198 &a##aShellClass##Args_Impl[nArg0], nArgs, DisableFlags, UnoName \
201 #define SFX_NEW_SLOT_ENUM( SlaveId, hid, GroupId, pMaster, pNext, MasterId, Value, Flags, DisableFlags, UnoName ) \
202 { SlaveId, GroupId, hid, Flags, \
203 MasterId, Value, \
204 0, \
205 0, \
206 (const SfxType*) &aSfxBoolItem_Impl, \
207 0, 0, \
208 pMaster, \
209 pNext, \
210 0, 0, DisableFlags, UnoName \
213 #define SFX_ARGUMENT( ArgSlotId, ArgName, ArgTypeId ) \
214 { (const SfxType*) &a##ArgTypeId##_Impl, ArgName, ArgSlotId }
216 //--------------------------------------------------------------------
218 class SfxPoolItem;
220 struct SfxFormalArgument
222 const SfxType* pType; // Type of the parameter (SfxPoolItem subclass)
223 const char* pName; // Name of the sParameters
224 sal_uInt16 nSlotId; // Slot-Id for identification of the Parameters
226 const TypeId& Type() const
227 { return pType->aTypeId; }
228 SfxPoolItem* CreateItem() const
229 { return (SfxPoolItem*) pType->aTypeId(); }
232 //--------------------------------------------------------------------
234 class SfxSlot
236 public:
237 sal_uInt16 nSlotId; // Unique slot-ID in Shell
238 sal_uInt16 nGroupId; // for configuration region
239 sal_uIntPtr nHelpId; // Usually == nSlotId
240 sal_uIntPtr nFlags; // artihmetic ordered Flags
242 sal_uInt16 nMasterSlotId; // Enum-Slot for example Which-Id
243 sal_uInt16 nValue; // Value, in case of Enum-Slot
245 SfxExecFunc fnExec; // Function to be excecuted
246 SfxStateFunc fnState; // Function for Status
248 const SfxType* pType; // SfxPoolItem-Type (Status)
249 const char* pName; // Name of the Slots
250 const char* pMethodName; // Name of the Method if different
252 const SfxSlot* pLinkedSlot; // Master-Slot for Enum value
253 const SfxSlot* pNextSlot; // with the same Status-Method
255 const SfxFormalArgument* pFirstArgDef; // first formal Argument-Definition
256 sal_uInt16 nArgDefCount; // Number of formal Argumentents
257 long nDisableFlags; // DisableFlags that need to be
258 // present, so that the Slot
259 // can be enabled
260 const char* pUnoName; // UnoName for the Slots
262 public:
264 SfxSlotKind GetKind() const;
265 sal_uInt16 GetSlotId() const;
266 sal_uIntPtr GetHelpId() const;
267 sal_uIntPtr GetMode() const;
268 sal_Bool IsMode( sal_uIntPtr nMode ) const;
269 sal_uInt16 GetGroupId() const;
270 sal_uInt16 GetMasterSlotId() const { return nMasterSlotId; }
271 sal_uInt16 GetWhich( const SfxItemPool &rPool ) const;
272 sal_uInt16 GetValue() const { return nValue; }
273 const SfxType* GetType() const { return pType; }
274 const char* GetUnoName() const { return pUnoName; }
275 SFX2_DLLPUBLIC OString GetCommand() const;
276 SFX2_DLLPUBLIC OUString GetCommandString() const;
278 sal_uInt16 GetFormalArgumentCount() const { return nArgDefCount; }
279 const SfxFormalArgument& GetFormalArgument( sal_uInt16 nNo ) const
280 { return pFirstArgDef[nNo]; }
282 SfxExecFunc GetExecFnc() const { return fnExec; }
283 SfxStateFunc GetStateFnc() const { return fnState; }
285 const SfxSlot* GetLinkedSlot() const { return pLinkedSlot; }
286 const SfxSlot* GetNextSlot() const { return pNextSlot; }
289 //=========================================================================
291 // returns the id of the function
293 inline sal_uInt16 SfxSlot::GetSlotId() const
295 return nSlotId;
297 //--------------------------------------------------------------------
298 // returns the help-id of the slot
300 inline sal_uIntPtr SfxSlot::GetHelpId() const
302 return nHelpId;
305 //--------------------------------------------------------------------
307 // returns a bitfield with flags
309 inline sal_uIntPtr SfxSlot::GetMode() const
311 return nFlags;
313 //--------------------------------------------------------------------
315 // determines if the specified mode is assigned
317 inline sal_Bool SfxSlot::IsMode( sal_uIntPtr nMode ) const
319 return (nFlags & nMode) != 0;
321 //--------------------------------------------------------------------
323 // returns the id of the associated group
325 inline sal_uInt16 SfxSlot::GetGroupId() const
327 return nGroupId;
331 #endif
333 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */