Version 5.2.6.1, tag libreoffice-5.2.6.1
[LibreOffice.git] / include / sfx2 / msg.hxx
blob6753181644a9d76733a3a4e1c53827c3e9938bae
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 <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>
28 #include <functional>
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;
43 METHOD = 0x4000L,
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
57 namespace o3tl
59 template<> struct typed_flags<SfxSlotMode> : is_typed_flags<SfxSlotMode, 0x1fec72cL> {};
63 class SfxRequest;
65 #define SFX_EXEC_STUB( aShellClass, aExecMethod) \
66 void SfxStub##aShellClass##aExecMethod( \
67 SfxShell *pShell, SfxRequest& rReq) \
68 { \
69 static_cast<aShellClass*>(pShell)->aExecMethod( rReq ); \
72 #define SFX_STATE_STUB( aShellClass, aStateMethod) \
73 void SfxStub##aShellClass##aStateMethod( \
74 SfxShell *pShell, SfxItemSet& rSet) \
75 { \
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
89 Standard,
90 Enum,
91 Attribute
95 struct SfxTypeAttrib
97 sal_uInt16 nAID;
98 const char* pName;
100 class SfxPoolItem;
101 template<class T> SfxPoolItem* createSfxPoolItem()
103 return T::CreateDefault();
105 struct SfxType
107 std::function<SfxPoolItem* ()> createSfxPoolItemFunc;
108 const std::type_info* pType;
109 sal_uInt16 nAttribs;
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()); }
117 struct SfxType0
119 std::function<SfxPoolItem* ()> createSfxPoolItemFunc;
120 const std::type_info* pType;
121 sal_uInt16 nAttribs;
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
134 SFX_DECL_TYPE(1);
135 SFX_DECL_TYPE(2);
136 SFX_DECL_TYPE(3);
137 SFX_DECL_TYPE(4);
138 SFX_DECL_TYPE(5);
139 SFX_DECL_TYPE(6);
140 SFX_DECL_TYPE(7);
141 SFX_DECL_TYPE(8);
142 SFX_DECL_TYPE(10); // for SfxDocInfoItem
143 SFX_DECL_TYPE(11);
145 SFX_DECL_TYPE(13); // for SwAddPrinterItem, Sd...
146 SFX_DECL_TYPE(14);
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
152 #undef SFX_DECL_TYPE
154 #define SFX_SLOT_ARG( aShellClass, id, GroupId, ExecMethodPtr, StateMethodPtr, Flags, ItemClass, nArg0, nArgs, Name, Prop ) \
155 { id, GroupId, Flags | Prop, \
156 USHRT_MAX, 0, \
157 ExecMethodPtr, \
158 StateMethodPtr, \
159 (const SfxType*) &a##ItemClass##_Impl, \
160 0, 0, \
161 &a##aShellClass##Args_Impl[nArg0], nArgs, 0, Name \
164 #define SFX_SLOT( aShellClass, id, GroupId, ExecMethodPtr, StateMethodPtr, Flags, ItemClass ) \
165 { id, GroupId, Flags, \
166 0, 0, \
167 ExecMethodPtr, \
168 StateMethodPtr, \
169 (const SfxType*) &a##ItemClass##_Impl, \
170 0, 0, 0, 0, 0 \
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, \
175 USHRT_MAX, 0, \
176 ExecMethodPtr, \
177 StateMethodPtr, \
178 (const SfxType*) &a##ItemClass##_Impl, \
179 pLinked, pNext, \
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, \
185 MasterId, Value, \
186 0, \
187 0, \
188 (const SfxType*) &aSfxBoolItem_Impl, \
189 pMaster, \
190 pNext, \
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(); }
205 class SfxSlot
207 public:
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
227 // can be enabled
228 const char* pUnoName; // UnoName for the Slots
230 public:
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
261 return nSlotId;
264 // returns a bitfield with flags
266 inline SfxSlotMode SfxSlot::GetMode() const
268 return nFlags;
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
284 return nGroupId;
288 #endif
290 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */