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/string.hxx>
24 #include <rtl/ustring.hxx>
25 #include <sfx2/dllapi.h>
26 #include <svl/itemset.hxx>
27 #include <o3tl/typed_flags_set.hxx>
30 enum class SfxSlotMode
{
31 NONE
= 0x0000L
, // default
33 TOGGLE
= 0x0004L
, // inverted for Execute old value
34 AUTOUPDATE
= 0x0008L
, // invalidated the status automatically after execute
35 ASYNCHRON
= 0x0020L
, // via Post-Message
37 NORECORD
= 0x0100L
, // no recording
38 RECORDPERITEM
= 0x0200L
, // each item, one statement
39 RECORDPERSET
= 0x0400L
, // The whole Set is a Statement, default
40 RECORDABSOLUTE
= 0x1000000L
, // Recording with absolute Target
41 STANDARD
= 0x00400L
, // RECORDPERSET;
45 FASTCALL
= 0x8000L
, // No test if disabled before Execute
47 MENUCONFIG
= 0x20000L
, // configurable Menu
48 TOOLBOXCONFIG
= 0x40000L
, // configurable Toolboxen
49 ACCELCONFIG
= 0x80000L
, // configurable keys
51 CONTAINER
= 0x100000L
, // Operated by the container at InPlace
52 READONLYDOC
= 0x200000L
, // also available for read-only Documents
53 IMAGEROTATION
= 0x400000L
, // Rotate image on Vertical/Bi-directional writing
54 IMAGEREFLECTION
= 0x800000L
// Mirror image on Vertical/Bi-directional writing
59 template<> struct typed_flags
<SfxSlotMode
> : is_typed_flags
<SfxSlotMode
, 0x1fec72cL
> {};
65 #define SFX_EXEC_STUB( aShellClass, aExecMethod) \
66 void SfxStub##aShellClass##aExecMethod( \
67 SfxShell *pShell, SfxRequest& rReq) \
69 static_cast<aShellClass*>(pShell)->aExecMethod( rReq ); \
72 #define SFX_STATE_STUB( aShellClass, aStateMethod) \
73 void SfxStub##aShellClass##aStateMethod( \
74 SfxShell *pShell, SfxItemSet& rSet) \
76 static_cast<aShellClass*>(pShell)->aStateMethod( rSet ); \
79 #define SFX_STUB_PTR( aShellClass, aMethod ) \
80 &SfxStub##aShellClass##aMethod
82 #define SFX_STUB_PTR_EXEC_NONE &SfxShell::EmptyExecStub
84 #define SFX_STUB_PTR_STATE_NONE &SfxShell::EmptyStateStub
87 enum class SfxSlotKind
101 template<class T
> SfxPoolItem
* createSfxPoolItem()
103 return T::CreateDefault();
107 std::function
<SfxPoolItem
* ()> createSfxPoolItemFunc
;
108 const std::type_info
* pType
;
110 SfxTypeAttrib aAttrib
[1]; // variable length
112 const std::type_info
* Type() const{return pType
;}
113 SfxPoolItem
* CreateItem() const
114 { return static_cast<SfxPoolItem
*>(createSfxPoolItemFunc()); }
119 std::function
<SfxPoolItem
* ()> createSfxPoolItemFunc
;
120 const std::type_info
* pType
;
122 const std::type_info
* Type() const { return pType
;}
124 #define SFX_DECL_TYPE(n) struct SfxType##n \
126 std::function<SfxPoolItem* ()> createSfxPoolItemFunc; \
127 const std::type_info* pType; \
128 sal_uInt16 nAttribs; \
129 SfxTypeAttrib aAttrib[n]; \
132 #define SFX_TYPE(Class) &a##Class##_Impl
142 SFX_DECL_TYPE(10); // for SfxDocInfoItem
145 SFX_DECL_TYPE(13); // for SwAddPrinterItem, Sd...
147 SFX_DECL_TYPE(16); // for SwDocDisplayItem
148 SFX_DECL_TYPE(17); // for SvxAddressItem
149 SFX_DECL_TYPE(23); // for SvxSearchItem
151 // all SfxTypes must be in this header
154 #define SFX_SLOT_ARG( aShellClass, id, GroupId, ExecMethodPtr, StateMethodPtr, Flags, ItemClass, nArg0, nArgs, Name, Prop ) \
155 { id, GroupId, Flags | Prop, \
159 (const SfxType*) &a##ItemClass##_Impl, \
161 &a##aShellClass##Args_Impl[nArg0], nArgs, 0, Name \
164 #define SFX_SLOT( aShellClass, id, GroupId, ExecMethodPtr, StateMethodPtr, Flags, ItemClass ) \
165 { id, GroupId, Flags, \
169 (const SfxType*) &a##ItemClass##_Impl, \
173 #define SFX_NEW_SLOT_ARG( aShellClass, id, GroupId, pLinked, pNext, ExecMethodPtr, StateMethodPtr, Flags, DisableFlags, ItemClass, nArg0, nArgs, Prop, UnoName ) \
174 { id, GroupId, Flags | Prop, \
178 (const SfxType*) &a##ItemClass##_Impl, \
180 &a##aShellClass##Args_Impl[nArg0], nArgs, DisableFlags, UnoName \
183 #define SFX_NEW_SLOT_ENUM( SlaveId, GroupId, pMaster, pNext, MasterId, Value, Flags, DisableFlags, UnoName ) \
184 { SlaveId, GroupId, Flags, \
188 (const SfxType*) &aSfxBoolItem_Impl, \
191 0, 0, DisableFlags, UnoName \
194 struct SfxFormalArgument
196 const SfxType
* pType
; // Type of the parameter (SfxPoolItem subclass)
197 const char* pName
; // Name of the sParameters
198 sal_uInt16 nSlotId
; // Slot-Id for identification of the Parameters
200 SfxPoolItem
* CreateItem() const
201 { return pType
->createSfxPoolItemFunc(); }
208 sal_uInt16 nSlotId
; // Unique slot-ID in Shell
209 sal_uInt16 nGroupId
; // for configuration region
210 SfxSlotMode nFlags
; // arithmetic ordered Flags
212 sal_uInt16 nMasterSlotId
; // Enum-Slot for example Which-Id
213 sal_uInt16 nValue
; // Value, in case of Enum-Slot
215 SfxExecFunc fnExec
; // Function to be executed
216 SfxStateFunc fnState
; // Function for Status
218 const SfxType
* pType
; // SfxPoolItem-Type (Status)
220 const SfxSlot
* pLinkedSlot
; // Master-Slot for Enum value
221 const SfxSlot
* pNextSlot
; // with the same Status-Method
223 const SfxFormalArgument
* pFirstArgDef
; // first formal Argument-Definition
224 sal_uInt16 nArgDefCount
; // Number of formal Arguments
225 long nDisableFlags
; // DisableFlags that need to be
226 // present, so that the Slot
228 const char* pUnoName
; // UnoName for the Slots
232 SfxSlotKind
GetKind() const;
233 sal_uInt16
GetSlotId() const;
234 SfxSlotMode
GetMode() const;
235 bool IsMode( SfxSlotMode nMode
) const;
236 sal_uInt16
GetGroupId() const;
237 sal_uInt16
GetMasterSlotId() const { return nMasterSlotId
; }
238 sal_uInt16
GetWhich( const SfxItemPool
&rPool
) const;
239 sal_uInt16
GetValue() const { return nValue
; }
240 const SfxType
* GetType() const { return pType
; }
241 const char* GetUnoName() const { return pUnoName
; }
242 SFX2_DLLPUBLIC OString
GetCommand() const;
243 SFX2_DLLPUBLIC OUString
GetCommandString() const;
245 sal_uInt16
GetFormalArgumentCount() const { return nArgDefCount
; }
246 const SfxFormalArgument
& GetFormalArgument( sal_uInt16 nNo
) const
247 { return pFirstArgDef
[nNo
]; }
249 SfxExecFunc
GetExecFnc() const { return fnExec
; }
250 SfxStateFunc
GetStateFnc() const { return fnState
; }
252 const SfxSlot
* GetLinkedSlot() const { return pLinkedSlot
; }
253 const SfxSlot
* GetNextSlot() const { return pNextSlot
; }
257 // returns the id of the function
259 inline sal_uInt16
SfxSlot::GetSlotId() const
264 // returns a bitfield with flags
266 inline SfxSlotMode
SfxSlot::GetMode() const
272 // determines if the specified mode is assigned
274 inline bool SfxSlot::IsMode( SfxSlotMode nMode
) const
276 return bool(nFlags
& nMode
);
280 // returns the id of the associated group
282 inline sal_uInt16
SfxSlot::GetGroupId() const
290 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */