lok: calc - send other views our selection in their co-ordinates.
[LibreOffice.git] / include / sfx2 / msg.hxx
blob7f9eb2de916bf5ac454a9bf6e64b9757cc88d689
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 <svl/poolitem.hxx>
26 #include <sfx2/dllapi.h>
27 #include <o3tl/typed_flags_set.hxx>
28 #include <sfx2/groupid.hxx>
29 #include <functional>
31 #include <climits>
33 class SfxItemPool;
35 enum class SfxSlotMode {
36 NONE = 0x0000L, // default
38 TOGGLE = 0x0004L, // inverted for Execute old value
39 AUTOUPDATE = 0x0008L, // invalidated the status automatically after execute
40 ASYNCHRON = 0x0020L, // via Post-Message
42 NORECORD = 0x0100L, // no recording
43 RECORDPERITEM = 0x0200L, // each item, one statement
44 RECORDPERSET = 0x0400L, // The whole Set is a Statement, default
45 RECORDABSOLUTE = 0x1000000L, // Recording with absolute Target
47 METHOD = 0x4000L,
49 FASTCALL = 0x8000L, // No test if disabled before Execute
51 MENUCONFIG = 0x20000L, // configurable Menu
52 TOOLBOXCONFIG = 0x40000L, // configurable Toolboxen
53 ACCELCONFIG = 0x80000L, // configurable keys
55 CONTAINER = 0x100000L, // Operated by the container at InPlace
56 READONLYDOC = 0x200000L // also available for read-only Documents
59 namespace o3tl
61 template<> struct typed_flags<SfxSlotMode> : is_typed_flags<SfxSlotMode, 0x13ec72cL> {};
64 #define SFX_EXEC_STUB( aShellClass, aExecMethod) \
65 void SfxStub##aShellClass##aExecMethod( \
66 SfxShell *pShell, SfxRequest& rReq) \
67 { \
68 ::tools::detail::castTo<aShellClass*>(pShell)->aExecMethod( rReq ); \
71 #define SFX_STATE_STUB( aShellClass, aStateMethod) \
72 void SfxStub##aShellClass##aStateMethod( \
73 SfxShell *pShell, SfxItemSet& rSet) \
74 { \
75 static_cast<aShellClass*>(pShell)->aStateMethod( rSet ); \
78 #define SFX_STUB_PTR( aShellClass, aMethod ) \
79 &SfxStub##aShellClass##aMethod
81 #define SFX_STUB_PTR_EXEC_NONE &SfxShell::EmptyExecStub
83 #define SFX_STUB_PTR_STATE_NONE &SfxShell::EmptyStateStub
86 enum class SfxSlotKind
88 Standard,
89 Attribute
93 struct SfxTypeAttrib
95 sal_uInt16 nAID;
96 const char* pName;
99 template<class T> SfxPoolItem* createSfxPoolItem()
101 return T::CreateDefault();
103 struct SfxType
105 std::function<SfxPoolItem* ()> const createSfxPoolItemFunc;
106 const std::type_info* pType;
107 sal_uInt16 const nAttribs;
108 SfxTypeAttrib aAttrib[1]; // variable length
110 const std::type_info* Type() const{return pType;}
111 std::unique_ptr<SfxPoolItem> CreateItem() const
112 { return std::unique_ptr<SfxPoolItem>(createSfxPoolItemFunc()); }
115 struct SfxType0
117 std::function<SfxPoolItem* ()> const createSfxPoolItemFunc;
118 const std::type_info* pType;
119 sal_uInt16 const nAttribs;
120 const std::type_info* Type() const { return pType;}
122 #define SFX_DECL_TYPE(n) struct SfxType##n \
124 std::function<SfxPoolItem* ()> createSfxPoolItemFunc; \
125 const std::type_info* pType; \
126 sal_uInt16 nAttribs; \
127 SfxTypeAttrib aAttrib[n]; \
130 #define SFX_TYPE(Class) &a##Class##_Impl
132 SFX_DECL_TYPE(1);
133 SFX_DECL_TYPE(2);
134 SFX_DECL_TYPE(3);
135 SFX_DECL_TYPE(4);
136 SFX_DECL_TYPE(5);
137 SFX_DECL_TYPE(6);
138 SFX_DECL_TYPE(7);
139 SFX_DECL_TYPE(8);
140 SFX_DECL_TYPE(10); // for SfxDocInfoItem
141 SFX_DECL_TYPE(11);
143 SFX_DECL_TYPE(13); // for SwAddPrinterItem, Sd...
144 SFX_DECL_TYPE(14);
145 SFX_DECL_TYPE(16); // for SwDocDisplayItem
146 SFX_DECL_TYPE(17); // for SvxAddressItem
147 SFX_DECL_TYPE(23); // for SvxSearchItem
149 // all SfxTypes must be in this header
150 #undef SFX_DECL_TYPE
152 #define SFX_SLOT_ARG( aShellClass, id, GroupId, ExecMethodPtr, StateMethodPtr, Flags, ItemClass, nArg0, nArgs, Name, Prop ) \
153 { id, GroupId, Flags | Prop, \
154 USHRT_MAX, 0, \
155 ExecMethodPtr, \
156 StateMethodPtr, \
157 (const SfxType*) &a##ItemClass##_Impl, \
158 0, \
159 &a##aShellClass##Args_Impl[nArg0], nArgs, SfxDisableFlags::NONE, Name \
162 #define SFX_NEW_SLOT_ARG( aShellClass, id, GroupId, pNext, ExecMethodPtr, StateMethodPtr, Flags, DisableFlags, ItemClass, nArg0, nArgs, Prop, UnoName ) \
163 { id, GroupId, Flags | Prop, \
164 USHRT_MAX, 0, \
165 ExecMethodPtr, \
166 StateMethodPtr, \
167 (const SfxType*) &a##ItemClass##_Impl, \
168 pNext, \
169 &a##aShellClass##Args_Impl[nArg0], nArgs, DisableFlags, UnoName \
172 struct SfxFormalArgument
174 const SfxType* pType; // Type of the parameter (SfxPoolItem subclass)
175 const char* pName; // Name of the sParameters
176 sal_uInt16 const nSlotId; // Slot-Id for identification of the Parameters
178 std::unique_ptr<SfxPoolItem> CreateItem() const
179 { return pType->CreateItem(); }
183 class SfxSlot
185 public:
186 sal_uInt16 nSlotId; // Unique slot-ID in Shell
187 SfxGroupId nGroupId; // for configuration region
188 SfxSlotMode nFlags; // arithmetic ordered Flags
190 sal_uInt16 nMasterSlotId; // Enum-Slot for example Which-Id
191 sal_uInt16 nValue; // Value, in case of Enum-Slot
193 SfxExecFunc fnExec; // Function to be executed
194 SfxStateFunc fnState; // Function for Status
196 const SfxType* pType; // SfxPoolItem-Type (Status)
198 const SfxSlot* pNextSlot; // with the same Status-Method
200 const SfxFormalArgument* pFirstArgDef; // first formal Argument-Definition
201 sal_uInt16 nArgDefCount; // Number of formal Arguments
202 SfxDisableFlags nDisableFlags; // DisableFlags that need to be
203 // present, so that the Slot
204 // can be enabled
205 const char* pUnoName; // UnoName for the Slots
207 public:
209 SfxSlotKind GetKind() const;
210 sal_uInt16 GetSlotId() const;
211 SfxSlotMode GetMode() const;
212 bool IsMode( SfxSlotMode nMode ) const;
213 SfxGroupId GetGroupId() const;
214 sal_uInt16 GetWhich( const SfxItemPool &rPool ) const;
215 const SfxType* GetType() const { return pType; }
216 const char* GetUnoName() const { return pUnoName; }
217 SFX2_DLLPUBLIC OString GetCommand() const;
218 SFX2_DLLPUBLIC OUString GetCommandString() const;
220 sal_uInt16 GetFormalArgumentCount() const { return nArgDefCount; }
221 const SfxFormalArgument& GetFormalArgument( sal_uInt16 nNo ) const
222 { return pFirstArgDef[nNo]; }
224 SfxExecFunc GetExecFnc() const { return fnExec; }
225 SfxStateFunc GetStateFnc() const { return fnState; }
227 const SfxSlot* GetNextSlot() const { return pNextSlot; }
231 // returns the id of the function
233 inline sal_uInt16 SfxSlot::GetSlotId() const
235 return nSlotId;
238 // returns a bitfield with flags
240 inline SfxSlotMode SfxSlot::GetMode() const
242 return nFlags;
246 // determines if the specified mode is assigned
248 inline bool SfxSlot::IsMode( SfxSlotMode nMode ) const
250 return bool(nFlags & nMode);
254 // returns the id of the associated group
256 inline SfxGroupId SfxSlot::GetGroupId() const
258 return nGroupId;
262 #endif
264 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */