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