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 <sfx2/shell.hxx>
23 #include <rtl/ustring.hxx>
24 #include <svl/poolitem.hxx>
25 #include <sfx2/dllapi.h>
26 #include <o3tl/typed_flags_set.hxx>
27 #include <sfx2/groupid.hxx>
34 enum class SfxSlotMode
{
35 NONE
= 0x0000, // default
37 TOGGLE
= 0x0004, // inverted for Execute old value
38 AUTOUPDATE
= 0x0008, // invalidated the status automatically after execute
39 ASYNCHRON
= 0x0020, // via Post-Message
41 NORECORD
= 0x0100, // no recording
42 RECORDPERITEM
= 0x0200, // each item, one statement
43 RECORDPERSET
= 0x0400, // The whole Set is a Statement, default
44 RECORDABSOLUTE
= 0x1000000, // Recording with absolute Target
48 FASTCALL
= 0x8000, // No test if disabled before Execute
50 MENUCONFIG
= 0x20000, // configurable Menu
51 TOOLBOXCONFIG
= 0x40000, // configurable Toolboxen
52 ACCELCONFIG
= 0x80000, // configurable keys
54 CONTAINER
= 0x100000, // Operated by the container at InPlace
55 READONLYDOC
= 0x200000 // also available for read-only Documents
60 template<> struct typed_flags
<SfxSlotMode
> : is_typed_flags
<SfxSlotMode
, 0x13ec72cL
> {};
63 #define SFX_EXEC_STUB( aShellClass, aExecMethod) \
64 void SfxStub##aShellClass##aExecMethod( \
65 SfxShell *pShell, SfxRequest& rReq) \
67 ::tools::detail::castTo<aShellClass*>(pShell)->aExecMethod( rReq ); \
70 #define SFX_STATE_STUB( aShellClass, aStateMethod) \
71 void SfxStub##aShellClass##aStateMethod( \
72 SfxShell *pShell, SfxItemSet& rSet) \
74 static_cast<aShellClass*>(pShell)->aStateMethod( rSet ); \
77 #define SFX_STUB_PTR( aShellClass, aMethod ) \
78 &SfxStub##aShellClass##aMethod
80 #define SFX_STUB_PTR_EXEC_NONE &SfxShell::EmptyExecStub
82 #define SFX_STUB_PTR_STATE_NONE &SfxShell::EmptyStateStub
85 enum class SfxSlotKind
98 template<class T
> SfxPoolItem
* createSfxPoolItem()
100 return T::CreateDefault();
104 std::function
<SfxPoolItem
* ()> createSfxPoolItemFunc
;
105 const std::type_info
* pType
;
107 SfxTypeAttrib aAttrib
[1]; // variable length
109 const std::type_info
* Type() const{return pType
;}
110 std::unique_ptr
<SfxPoolItem
> CreateItem() const
111 { return std::unique_ptr
<SfxPoolItem
>(createSfxPoolItemFunc()); }
116 std::function
<SfxPoolItem
* ()> createSfxPoolItemFunc
;
117 const std::type_info
* pType
;
119 const std::type_info
* Type() const { return pType
;}
121 #define SFX_DECL_TYPE(n) struct SfxType##n \
123 std::function<SfxPoolItem* ()> createSfxPoolItemFunc; \
124 const std::type_info* pType; \
125 sal_uInt16 nAttribs; \
126 SfxTypeAttrib aAttrib[n]; \
129 #define SFX_TYPE(Class) &a##Class##_Impl
139 SFX_DECL_TYPE(10); // for SfxDocInfoItem
142 SFX_DECL_TYPE(13); // for SwAddPrinterItem, Sd...
144 SFX_DECL_TYPE(16); // for SwDocDisplayItem
145 SFX_DECL_TYPE(17); // for SvxAddressItem
146 SFX_DECL_TYPE(23); // for SvxSearchItem
148 // all SfxTypes must be in this header
151 #define SFX_SLOT_ARG( aShellClass, id, GroupId, ExecMethodPtr, StateMethodPtr, Flags, ItemClass, nArg0, nArgs, Name, Prop ) \
152 { id, GroupId, Flags | Prop, \
156 (const SfxType*) &a##ItemClass##_Impl, \
158 &a##aShellClass##Args_Impl[nArg0], nArgs, SfxDisableFlags::NONE, Name \
161 #define SFX_NEW_SLOT_ARG( aShellClass, id, GroupId, pNext, ExecMethodPtr, StateMethodPtr, Flags, DisableFlags, ItemClass, nArg0, nArgs, Prop, UnoName ) \
162 { id, GroupId, Flags | Prop, \
166 (const SfxType*) &a##ItemClass##_Impl, \
168 &a##aShellClass##Args_Impl[nArg0], nArgs, DisableFlags, UnoName \
171 struct SfxFormalArgument
173 const SfxType
* pType
; // Type of the parameter (SfxPoolItem subclass)
174 const char* pName
; // Name of the sParameters
175 sal_uInt16 nSlotId
; // Slot-Id for identification of the Parameters
177 std::unique_ptr
<SfxPoolItem
> CreateItem() const
178 { return pType
->CreateItem(); }
185 sal_uInt16 nSlotId
; // Unique slot-ID in Shell
186 SfxGroupId nGroupId
; // for configuration region
187 SfxSlotMode nFlags
; // arithmetic ordered Flags
189 sal_uInt16 nMasterSlotId
; // Enum-Slot for example Which-Id
190 sal_uInt16 nValue
; // Value, in case of Enum-Slot
192 SfxExecFunc fnExec
; // Function to be executed
193 SfxStateFunc fnState
; // Function for Status
195 const SfxType
* pType
; // SfxPoolItem-Type (Status)
197 const SfxSlot
* pNextSlot
; // with the same Status-Method
199 const SfxFormalArgument
* pFirstArgDef
; // first formal Argument-Definition
200 sal_uInt16 nArgDefCount
; // Number of formal Arguments
201 SfxDisableFlags nDisableFlags
; // DisableFlags that need to be
202 // present, so that the Slot
204 OUString pUnoName
; // UnoName for the Slots
209 SfxSlot(sal_uInt16 sId
, SfxGroupId gId
, SfxSlotMode flags
, sal_uInt16 masterSlotId
,
210 sal_uInt16 value
, SfxExecFunc exec
, SfxStateFunc state
, const SfxType
* type
,
211 const SfxSlot
* nextSlot
, const SfxFormalArgument
* firstArgDef
, sal_uInt16 argDefCount
,
212 SfxDisableFlags disableFlags
, const char (&literal
)[N
])
216 , nMasterSlotId(masterSlotId
)
221 , pNextSlot(nextSlot
)
222 , pFirstArgDef(firstArgDef
)
223 , nArgDefCount(argDefCount
)
224 , nDisableFlags(disableFlags
)
229 SfxSlotKind
GetKind() const;
230 sal_uInt16
GetSlotId() const;
231 SfxSlotMode
GetMode() const;
232 bool IsMode( SfxSlotMode nMode
) const;
233 SfxGroupId
GetGroupId() const;
234 sal_uInt16
GetWhich( const SfxItemPool
&rPool
) const;
235 const SfxType
* GetType() const { return pType
; }
236 const OUString
& GetUnoName() const { return pUnoName
; }
237 SFX2_DLLPUBLIC OUString
GetCommand() const;
239 sal_uInt16
GetFormalArgumentCount() const { return nArgDefCount
; }
240 const SfxFormalArgument
& GetFormalArgument( sal_uInt16 nNo
) const
241 { return pFirstArgDef
[nNo
]; }
243 SfxExecFunc
GetExecFnc() const { return fnExec
; }
244 SfxStateFunc
GetStateFnc() const { return fnState
; }
246 const SfxSlot
* GetNextSlot() const { return pNextSlot
; }
250 // returns the id of the function
252 inline sal_uInt16
SfxSlot::GetSlotId() const
257 // returns a bitfield with flags
259 inline SfxSlotMode
SfxSlot::GetMode() const
265 // determines if the specified mode is assigned
267 inline bool SfxSlot::IsMode( SfxSlotMode nMode
) const
269 return bool(nFlags
& nMode
);
273 // returns the id of the associated group
275 inline SfxGroupId
SfxSlot::GetGroupId() const
283 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */