1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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>
27 #include <svl/itemset.hxx>
28 #include <o3tl/typed_flags_set.hxx>
30 enum class SfxSlotMode
{
31 NONE
= 0x0000L
, // exclusiv to VOLATILE, default
32 CACHABLE
= 0x0001L
, // exclusiv to VOLATILE, default
33 VOLATILE
= 0x0002L
, // per Timer every 2s get new, exclusive to CACHABLE
35 TOGGLE
= 0x0004L
, // inverted for Execute old value
36 AUTOUPDATE
= 0x0008L
, // invalidated the status automatically after execute
37 SYNCHRON
= 0x0010L
, // exclusive to ASYNCHRON, default
38 ASYNCHRON
= 0x0020L
, // via Post-Message, exclusive to SYNCHRON
39 HASDIALOG
= 0x0080L
, // Coordinates for dialogue after recofig
41 NORECORD
= 0x0100L
, // no recording
42 RECORDPERITEM
= 0x0200L
, // each item, one statement
43 RECORDPERSET
= 0x0400L
, // The whole Set is a Statement, default
44 RECORDMANUAL
= 0x0800L
, // Recording by the application developer is default
45 RECORDABSOLUTE
= 0x1000000L
, // Recording with absolute Target
46 STANDARD
= 0x00411L
, // CACHABLE | SYNCHRON | RECORDPERSET;
48 PROPGET
= 0x1000L
, // get property
49 PROPSET
= 0x2000L
, // set property, exclusive to METHOD
50 METHOD
= 0x4000L
, // Method, exclusiv to PROPSET
52 FASTCALL
= 0x8000L
, // No test if disabled before Execute
54 STATUSBARCONFIG
= 0x10000L
, // configurable status row
55 MENUCONFIG
= 0x20000L
, // configurable Menu
56 TOOLBOXCONFIG
= 0x40000L
, // configurable Toolboxen
57 ACCELCONFIG
= 0x80000L
, // configurable keys
59 CONTAINER
= 0x100000L
, // Operated by the container at InPlace
60 READONLYDOC
= 0x200000L
, // also available for read-only Documents
61 IMAGEROTATION
= 0x400000L
, // Rotate image on Vertical/Bi-directional writing
62 IMAGEREFLECTION
= 0x800000L
// Mirror image on Vertical/Bi-directional writing
67 template<> struct typed_flags
<SfxSlotMode
> : is_typed_flags
<SfxSlotMode
, 0x1ffffbfL
> {};
73 #define SFX_EXEC_STUB( aShellClass, aExecMethod) \
74 void SfxStub##aShellClass##aExecMethod( \
75 SfxShell *pShell, SfxRequest& rReq) \
77 static_cast<aShellClass*>(pShell)->aExecMethod( rReq ); \
80 #define SFX_STATE_STUB( aShellClass, aStateMethod) \
81 void SfxStub##aShellClass##aStateMethod( \
82 SfxShell *pShell, SfxItemSet& rSet) \
84 static_cast<aShellClass*>(pShell)->aStateMethod( rSet ); \
87 #define SFX_STUB_PTR( aShellClass, aMethod ) \
88 &SfxStub##aShellClass##aMethod
90 #define SFX_STUB_PTR_EXEC_NONE &SfxShell::EmptyExecStub
92 #define SFX_STUB_PTR_STATE_NONE &SfxShell::EmptyStateStub
115 SfxTypeAttrib aAttrib
[16];
117 const TypeId
& Type() const
119 SfxPoolItem
* CreateItem() const
120 { return static_cast<SfxPoolItem
*>(aTypeId()); }
128 const TypeId
& Type() const
130 SfxPoolItem
* CreateItem() const
131 { return static_cast<SfxPoolItem
*>(aTypeId()); }
134 #define SFX_DECL_TYPE(n) struct SfxType##n \
137 sal_uInt16 nAttribs; \
138 SfxTypeAttrib aAttrib[n]; \
141 #define SFX_TYPE(Class) &a##Class##_Impl
151 SFX_DECL_TYPE(10); // for SfxDocInfoItem
154 SFX_DECL_TYPE(13); // for SwAddPrinterItem, Sd...
156 SFX_DECL_TYPE(16); // for SwDocDisplayItem
157 SFX_DECL_TYPE(17); // for SvxAddressItem
158 SFX_DECL_TYPE(20); // for SvxSearchItem
160 // all SfxTypes must be in this header
163 #define SFX_SLOT_ARG( aShellClass, id, GroupId, ExecMethodPtr, StateMethodPtr, Flags, ItemClass, nArg0, nArgs, Name, Prop ) \
164 { id, GroupId, id, Flags | Prop, \
168 (const SfxType*) &a##ItemClass##_Impl, \
170 &a##aShellClass##Args_Impl[nArg0], nArgs, 0, Name \
173 #define SFX_SLOT( aShellClass, id, GroupId, ExecMethodPtr, StateMethodPtr, Flags, ItemClass ) \
174 { id, GroupId, id, Flags, \
178 (const SfxType*) &a##ItemClass##_Impl, \
182 #define SFX_NEW_SLOT_ARG( aShellClass, id, hid, GroupId, pLinked, pNext, ExecMethodPtr, StateMethodPtr, Flags, DisableFlags, ItemClass, nArg0, nArgs, Prop, UnoName ) \
183 { id, GroupId, hid, Flags | Prop, \
187 (const SfxType*) &a##ItemClass##_Impl, \
189 &a##aShellClass##Args_Impl[nArg0], nArgs, DisableFlags, UnoName \
192 #define SFX_NEW_SLOT_ENUM( SlaveId, hid, GroupId, pMaster, pNext, MasterId, Value, Flags, DisableFlags, UnoName ) \
193 { SlaveId, GroupId, hid, Flags, \
197 (const SfxType*) &aSfxBoolItem_Impl, \
200 0, 0, DisableFlags, UnoName \
205 struct SfxFormalArgument
207 const SfxType
* pType
; // Type of the parameter (SfxPoolItem subclass)
208 const char* pName
; // Name of the sParameters
209 sal_uInt16 nSlotId
; // Slot-Id for identification of the Parameters
211 const TypeId
& Type() const
212 { return pType
->aTypeId
; }
213 SfxPoolItem
* CreateItem() const
214 { return static_cast<SfxPoolItem
*>(pType
->aTypeId()); }
222 sal_uInt16 nSlotId
; // Unique slot-ID in Shell
223 sal_uInt16 nGroupId
; // for configuration region
224 sal_uIntPtr nHelpId
; // Usually == nSlotId
225 SfxSlotMode nFlags
; // artihmetic ordered Flags
227 sal_uInt16 nMasterSlotId
; // Enum-Slot for example Which-Id
228 sal_uInt16 nValue
; // Value, in case of Enum-Slot
230 SfxExecFunc fnExec
; // Function to be executed
231 SfxStateFunc fnState
; // Function for Status
233 const SfxType
* pType
; // SfxPoolItem-Type (Status)
235 const SfxSlot
* pLinkedSlot
; // Master-Slot for Enum value
236 const SfxSlot
* pNextSlot
; // with the same Status-Method
238 const SfxFormalArgument
* pFirstArgDef
; // first formal Argument-Definition
239 sal_uInt16 nArgDefCount
; // Number of formal Argumentents
240 long nDisableFlags
; // DisableFlags that need to be
241 // present, so that the Slot
243 const char* pUnoName
; // UnoName for the Slots
247 SfxSlotKind
GetKind() const;
248 sal_uInt16
GetSlotId() const;
249 sal_uIntPtr
GetHelpId() const;
250 SfxSlotMode
GetMode() const;
251 bool IsMode( SfxSlotMode nMode
) const;
252 sal_uInt16
GetGroupId() const;
253 sal_uInt16
GetMasterSlotId() const { return nMasterSlotId
; }
254 sal_uInt16
GetWhich( const SfxItemPool
&rPool
) const;
255 sal_uInt16
GetValue() const { return nValue
; }
256 const SfxType
* GetType() const { return pType
; }
257 const char* GetUnoName() const { return pUnoName
; }
258 SFX2_DLLPUBLIC OString
GetCommand() const;
259 SFX2_DLLPUBLIC OUString
GetCommandString() const;
261 sal_uInt16
GetFormalArgumentCount() const { return nArgDefCount
; }
262 const SfxFormalArgument
& GetFormalArgument( sal_uInt16 nNo
) const
263 { return pFirstArgDef
[nNo
]; }
265 SfxExecFunc
GetExecFnc() const { return fnExec
; }
266 SfxStateFunc
GetStateFnc() const { return fnState
; }
268 const SfxSlot
* GetLinkedSlot() const { return pLinkedSlot
; }
269 const SfxSlot
* GetNextSlot() const { return pNextSlot
; }
274 // returns the id of the function
276 inline sal_uInt16
SfxSlot::GetSlotId() const
281 // returns the help-id of the slot
283 inline sal_uIntPtr
SfxSlot::GetHelpId() const
290 // returns a bitfield with flags
292 inline SfxSlotMode
SfxSlot::GetMode() const
298 // determines if the specified mode is assigned
300 inline bool SfxSlot::IsMode( SfxSlotMode nMode
) const
302 return bool(nFlags
& nMode
);
306 // returns the id of the associated group
308 inline sal_uInt16
SfxSlot::GetGroupId() const
316 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */