xref: /AOO41X/main/sfx2/inc/sfx2/msg.hxx (revision 353d8f4d17010cd2d0ea815067cad67e477f2bee)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 #ifndef _SFXMSG_HXX
24 #define _SFXMSG_HXX
25 
26 #include <tools/rtti.hxx>
27 #include <sfx2/shell.hxx>
28 #include <rtl/string.hxx>
29 #include <rtl/ustring.hxx>
30 #include <sfx2/dllapi.h>
31 
32 //--------------------------------------------------------------------
33 
34 #define SFX_SLOT_CACHABLE          0x0001L // exklusiv zu VOLATILE, default
35 #define SFX_SLOT_VOLATILE          0x0002L // per Timer alle 2s neu geholt, exklusiv zu CACHABLE
36 #define SFX_SLOT_TOGGLE            0x0004L // invertiert bei Execute alten Wert
37 #define SFX_SLOT_AUTOUPDATE        0x0008L // invalidiert den Status nach Execute automatisch
38 
39 #define SFX_SLOT_SYNCHRON          0x0010L // exklusiv zu ASYNCHRON, default
40 #define SFX_SLOT_ASYNCHRON         0x0020L // via Post-Message, exklusiv zu SYNCHRON
41 
42 #define SFX_SLOT_HASCOREID         0x0040L // Slot-ID/Which-ID Mappting durchf"uhren
43 #define SFX_SLOT_HASDIALOG         0x0080L // Punkte fuer Dialog nach recofig
44 
45 #define SFX_SLOT_NORECORD          0x0100L // kein Recording
46 #define SFX_SLOT_RECORDPERITEM     0x0200L // je Item ein Statement
47 #define SFX_SLOT_RECORDPERSET      0x0400L // das ganze Set ist ein Statement, def.
48 #define SFX_SLOT_RECORDMANUAL      0x0800L // Recording vom Applikationsentwickler                                         iss-default
49 
50 #define SFX_SLOT_RECORDABSOLUTE 0x1000000L // Recording mit absolutem Target
51 #define SFX_SLOT_STANDARD       ( SFX_SLOT_CACHABLE | \
52                                   SFX_SLOT_SYNCHRON | \
53                                   SFX_SLOT_RECORDPERSET )
54 
55 #define SFX_SLOT_PROPGET          0x1000L  // abfragbares Property
56 #define SFX_SLOT_PROPSET          0x2000L  // setzbares Property, exklusiv zu SFX_SLOT_METHOD
57 #define SFX_SLOT_METHOD           0x4000L  // Methode, exklusiv zu SFX_SLOT_PROPSET
58 
59 #define SFX_SLOT_FASTCALL         0x8000L  // vor Execute keine Pr"ufung, ob disabled
60 
61 #define SFX_SLOT_STATUSBARCONFIG 0x10000L  // konfigurierbar in Statuszeile
62 #define SFX_SLOT_MENUCONFIG      0x20000L  // konfigurierbar im Men"u
63 #define SFX_SLOT_TOOLBOXCONFIG   0x40000L  // konfigurierbar in Toolboxen
64 #define SFX_SLOT_ACCELCONFIG     0x80000L  // konfigurierbar auf Tasten
65 
66 #define SFX_SLOT_CONTAINER      0x100000L  // beim InPlace vom Container bedient
67 #define SFX_SLOT_READONLYDOC    0x200000L  // auch bei readonly-Docs verf"ugbar
68 #define SFX_SLOT_IMAGEROTATION  0x400000L  // bei Vertical/Bidi writing Image drehen
69 #define SFX_SLOT_IMAGEREFLECTION  0x800000L  // bei Vertical/Bidi writing Image spiegeln
70 
71 //--------------------------------------------------------------------
72 
73 class SfxRequest;
74 class SfxItemSet;
75 
76 #define SFX_EXEC_STUB( aShellClass, aExecMethod) \
77  void __EXPORT SfxStub##aShellClass##aExecMethod( \
78    SfxShell *pShell, SfxRequest& rReq) \
79   { \
80     (( aShellClass* ) pShell )->aExecMethod( rReq ); \
81   }
82 
83 #define SFX_STATE_STUB( aShellClass, aStateMethod) \
84  void  __EXPORT SfxStub##aShellClass##aStateMethod( \
85    SfxShell *pShell, SfxItemSet& rSet) \
86   { \
87     (( aShellClass* ) pShell )->aStateMethod( rSet ); \
88   }
89 
90 #define SFX_STUB_PTR( aShellClass, aMethod ) \
91    &SfxStub##aShellClass##aMethod
92 
93 #define SFX_STUB_PTR_EXEC_NONE &SfxShell::EmptyExecStub
94 
95 #define SFX_STUB_PTR_STATE_NONE &SfxShell::EmptyStateStub
96 
97 //--------------------------------------------------------------------
98 
99 enum SfxSlotKind
100 {
101     SFX_KIND_STANDARD,
102     SFX_KIND_ENUM,
103     SFX_KIND_ATTR
104 };
105 
106 //=========================================================================
107 
108 struct SfxTypeAttrib
109 {
110     sal_uInt16                  nAID;
111     const char __FAR_DATA*  pName;
112 };
113 
114 struct SfxType
115 {
116     TypeId          aTypeId;
117     sal_uInt16          nAttribs;
118     SfxTypeAttrib   aAttrib[16];
119 
TypeSfxType120     const TypeId&   Type() const
121                     { return aTypeId; }
CreateItemSfxType122     SfxPoolItem*    CreateItem() const
123                     { return (SfxPoolItem*) aTypeId(); }
124 };
125 
126 struct SfxType0
127 {
128     TypeId          aTypeId;
129     sal_uInt16          nAttribs;
130 
TypeSfxType0131     const TypeId&   Type() const
132                     { return aTypeId; }
CreateItemSfxType0133     SfxPoolItem*    CreateItem() const
134                     { return (SfxPoolItem*) aTypeId(); }
135 };
136 
137 #define SFX_DECL_TYPE(n)    struct SfxType##n                   \
138                             {                                   \
139                                 TypeId          aTypeId;        \
140                                 sal_uInt16          nAttribs;       \
141                                 SfxTypeAttrib   aAttrib[n];     \
142                             }
143 
144 #define SFX_TYPE(Class) &a##Class##_Impl
145 
146 SFX_DECL_TYPE(1);
147 SFX_DECL_TYPE(2);
148 SFX_DECL_TYPE(3);
149 SFX_DECL_TYPE(4);
150 SFX_DECL_TYPE(5);
151 SFX_DECL_TYPE(6);
152 SFX_DECL_TYPE(7);
153 SFX_DECL_TYPE(8);
154 SFX_DECL_TYPE(10); // for SfxDocInfoItem
155 SFX_DECL_TYPE(11);
156 
157 SFX_DECL_TYPE(13); // for SwAddPrinterItem, Sd...
158 SFX_DECL_TYPE(14);
159 SFX_DECL_TYPE(16); // for SwDocDisplayItem
160 SFX_DECL_TYPE(17); // for SvxAddressItem
161 SFX_DECL_TYPE(18); // for SvxSearchItem
162 
163 // all SfxTypes must be in this header
164 #undef SFX_DECL_TYPE
165 
166 #define SFX_SLOT_ARG( aShellClass, id, GroupId, ExecMethodPtr, StateMethodPtr, Flags, ItemClass, nArg0, nArgs, Name, Prop ) \
167                { id, GroupId, id, Flags | Prop, \
168                  USHRT_MAX, 0, \
169                  ExecMethodPtr, \
170                  StateMethodPtr, \
171                  (const SfxType*) &a##ItemClass##_Impl, \
172                  Name, Name, 0, 0, \
173                  &a##aShellClass##Args_Impl[nArg0], nArgs, 0, Name \
174                }
175 
176 #define SFX_SLOT( aShellClass, id, GroupId, ExecMethodPtr, StateMethodPtr, Flags, ItemClass ) \
177                { id, GroupId, id, Flags, \
178                  0, 0, \
179                  ExecMethodPtr, \
180                  StateMethodPtr, \
181                  (const SfxType*) &a##ItemClass##_Impl, \
182                  0, 0, 0, 0, 0, 0, 0 \
183                }
184 
185 #define SFX_SLOT_ATTR( id, GroupId, Dummy, ExecMethodPtr, StateMethodPtr, Flags, ItemClass ) \
186                { id, GroupId, id, Flags, \
187                  USHRT_MAX, 0, \
188                  ExecMethodPtr, \
189                  StateMethodPtr, \
190                  (const SfxType*) &a##ItemClass##_Impl, \
191                  0, 0, 0, 0, 0, 0, 0 \
192                }
193 
194 #define SFX_SLOT_ENUM( SlaveId, GroupId, MasterId, Value, Flags ) \
195                { SlaveId, GroupId, id, Flags,    \
196                  MasterId,  Value, 0, 0, \
197                  (const SfxType*) &aSfxBoolItem_Impl, \
198                  0, 0, 0, 0, 0, 0, 0 \
199                }
200 #define SFX_NEW_SLOT_ARG( aShellClass, id, hid, GroupId, pLinked, pNext, ExecMethodPtr, StateMethodPtr, Flags, DisableFlags, ItemClass, nArg0, nArgs, Name, Prop, UnoName ) \
201                { id, GroupId, hid, Flags | Prop, \
202                  USHRT_MAX, 0, \
203                  ExecMethodPtr, \
204                  StateMethodPtr, \
205                  (const SfxType*) &a##ItemClass##_Impl, \
206                  Name, Name, \
207                  pLinked, pNext, \
208                  &a##aShellClass##Args_Impl[nArg0], nArgs, DisableFlags, UnoName \
209                }
210 
211 #define SFX_NEW_SLOT_ENUM( SlaveId, hid, GroupId, pMaster, pNext, MasterId, Value, Flags, DisableFlags, UnoName  ) \
212                { SlaveId, GroupId, hid, Flags,   \
213                  MasterId,  Value, \
214                  0, \
215                  0, \
216                  (const SfxType*) &aSfxBoolItem_Impl, \
217                  0, 0, \
218                  pMaster, \
219                  pNext, \
220                  0, 0, DisableFlags, UnoName \
221                }
222 
223 #define SFX_SLOTMAP_NONE(ShellClass) \
224             static SfxFormalArgument __FAR_DATA a##ShellClass##Args_Impl[1]; \
225             static SfxSlot __FAR_DATA a##ShellClass##Slots_Impl[] = \
226             { { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } }
227 
228 #define SFX_ARGUMENT( ArgSlotId, ArgName, ArgTypeId ) \
229             { (const SfxType*) &a##ArgTypeId##_Impl, ArgName, ArgSlotId }
230 
231 //--------------------------------------------------------------------
232 
233 class SfxPoolItem;
234 
235 struct SfxFormalArgument
236 {
237     const SfxType*          pType;  // Typ des Parameters (SfxPoolItem Subklasse)
238     const char __FAR_DATA*  pName;  // Name des Parameters
239     sal_uInt16                  nSlotId;// Slot-Id zur Identifikation des Parameters
240 
TypeSfxFormalArgument241     const TypeId&           Type() const
242                             { return pType->aTypeId; }
CreateItemSfxFormalArgument243     SfxPoolItem*            CreateItem() const
244                             { return (SfxPoolItem*) pType->aTypeId(); }
245 };
246 
247 //--------------------------------------------------------------------
248 
249 class SfxSlot
250 {
251 public:
252     sal_uInt16                      nSlotId;        // in Shell eindeutige Slot-Id
253     sal_uInt16                      nGroupId;       // f"ur Konfigurations-Bereich
254     sal_uIntPtr                     nHelpId;        // i.d.R. == nSlotId
255     sal_uIntPtr                     nFlags;         // artihm. veroderte Flags
256 
257     sal_uInt16                      nMasterSlotId;  // Enum-Slot bzw. Which-Id
258     sal_uInt16                      nValue;         // Wert, falls Enum-Slot
259 
260     SfxExecFunc                 fnExec;         // Funktion zum Ausf"uhren
261     SfxStateFunc                fnState;        // Funktion f"ur Status
262 
263     const SfxType*              pType;          // SfxPoolItem-Typ (Status)
264     const char __FAR_DATA*      pName;          // Name des Slots
265     const char __FAR_DATA*      pMethodName;    // Name der Method falls anders
266 
267     const SfxSlot*              pLinkedSlot;    // Master-Slot f"ur Enum-Werte
268     const SfxSlot*              pNextSlot;      // mit derselben Status-Methode
269 
270     const SfxFormalArgument*    pFirstArgDef;   // erste formale Argument-Definition
271     sal_uInt16                      nArgDefCount;   // Anzahl der formalen Argumente
272     long                        nDisableFlags;      // DisableFlags, die vorhanden sein
273                                                 // m"ussen, damit der Slot enabled ist
274     const char __FAR_DATA*      pUnoName;       // UnoName des Slots
275 
276 public:
277 
278     SfxSlotKind     GetKind() const;
279     sal_uInt16          GetSlotId() const;
280     sal_uIntPtr         GetHelpId() const;
281     sal_uIntPtr         GetMode() const;
282     sal_Bool            IsMode( sal_uIntPtr nMode ) const;
283     sal_uInt16          GetGroupId() const;
GetMasterSlotId() const284     sal_uInt16          GetMasterSlotId() const { return nMasterSlotId; }
285     sal_uInt16          GetWhich( const SfxItemPool &rPool ) const;
GetValue() const286     sal_uInt16          GetValue() const { return nValue; }
GetType() const287     const SfxType*  GetType() const { return pType; }
GetUnoName() const288     const char*     GetUnoName() const { return pUnoName; }
289     SFX2_DLLPUBLIC rtl::OString    GetCommand() const;
290     SFX2_DLLPUBLIC rtl::OUString    GetCommandString() const;
291 
GetFormalArgumentCount() const292     sal_uInt16          GetFormalArgumentCount() const { return nArgDefCount; }
GetFormalArgument(sal_uInt16 nNo) const293     const SfxFormalArgument& GetFormalArgument( sal_uInt16 nNo ) const
294                     { return pFirstArgDef[nNo]; }
295 
GetExecFnc() const296     SfxExecFunc     GetExecFnc() const { return fnExec; }
GetStateFnc() const297     SfxStateFunc    GetStateFnc() const { return fnState; }
298 
GetLinkedSlot() const299     const SfxSlot*  GetLinkedSlot() const { return pLinkedSlot; }
GetNextSlot() const300     const SfxSlot*  GetNextSlot() const { return pNextSlot; }
301 };
302 
303 //=========================================================================
304 
305 // returns the id of the function
306 
GetSlotId() const307 inline sal_uInt16 SfxSlot::GetSlotId() const
308 {
309     return nSlotId;
310 }
311 //--------------------------------------------------------------------
312 // returns the help-id of the slot
313 
GetHelpId() const314 inline sal_uIntPtr SfxSlot::GetHelpId() const
315 {
316     return nHelpId;
317 }
318 
319 //--------------------------------------------------------------------
320 
321 // returns  a bitfield with flags
322 
GetMode() const323 inline sal_uIntPtr SfxSlot::GetMode() const
324 {
325     return nFlags;
326 }
327 //--------------------------------------------------------------------
328 
329 // determines if the specified mode is assigned
330 
IsMode(sal_uIntPtr nMode) const331 inline sal_Bool SfxSlot::IsMode( sal_uIntPtr nMode ) const
332 {
333     return (nFlags & nMode) != 0;
334 }
335 //--------------------------------------------------------------------
336 
337 // returns the id of the associated group
338 
GetGroupId() const339 inline sal_uInt16 SfxSlot::GetGroupId() const
340 {
341     return nGroupId;
342 
343 }
344 
345 #endif
346