LCOV - code coverage report
Current view: top level - include/sfx2 - msg.hxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 22 24 91.7 %
Date: 2015-06-13 12:38:46 Functions: 15 16 93.8 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       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/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      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 .
      18             :  */
      19             : #ifndef INCLUDED_SFX2_MSG_HXX
      20             : #define INCLUDED_SFX2_MSG_HXX
      21             : 
      22             : #include <tools/rtti.hxx>
      23             : #include <sfx2/shell.hxx>
      24             : #include <rtl/string.hxx>
      25             : #include <rtl/ustring.hxx>
      26             : #include <sfx2/dllapi.h>
      27             : #include <svl/itemset.hxx>
      28             : #include <o3tl/typed_flags_set.hxx>
      29             : 
      30             : enum class SfxSlotMode {
      31             :     NONE            =    0x0000L, // exclusiv to VOLATILE, default
      32             :     CACHABLE        =    0x0001L, // exclusiv to VOLATILE, default
      33             :     VOLATILE        =    0x0002L, // per Timer every 2s get new, exclusive to CACHABLE
      34             : 
      35             :     TOGGLE          =    0x0004L, // inverted for Execute old value
      36             :     AUTOUPDATE      =    0x0008L, // invalidated the status automatically after execute
      37             :     SYNCHRON        =    0x0010L, // exclusive to ASYNCHRON, default
      38             :     ASYNCHRON       =    0x0020L, // via Post-Message, exclusive to SYNCHRON
      39             :     HASDIALOG       =    0x0080L, // Coordinates for dialogue after recofig
      40             : 
      41             :     NORECORD        =    0x0100L, // no recording
      42             :     RECORDPERITEM   =    0x0200L, // each item, one statement
      43             :     RECORDPERSET    =    0x0400L, // The whole Set is a Statement, default
      44             :     RECORDMANUAL    =    0x0800L, // Recording by the application developer is default
      45             :     RECORDABSOLUTE  = 0x1000000L, // Recording with absolute Target
      46             :     STANDARD        =   0x00411L, // CACHABLE | SYNCHRON | RECORDPERSET;
      47             : 
      48             :     PROPGET         =    0x1000L, // get property
      49             :     PROPSET         =    0x2000L, // set property, exclusive to METHOD
      50             :     METHOD          =    0x4000L, // Method, exclusiv to PROPSET
      51             : 
      52             :     FASTCALL        =    0x8000L, // No test if disabled before Execute
      53             : 
      54             :     STATUSBARCONFIG =   0x10000L, // configurable status row
      55             :     MENUCONFIG      =   0x20000L, // configurable Menu
      56             :     TOOLBOXCONFIG   =   0x40000L, // configurable Toolboxen
      57             :     ACCELCONFIG     =   0x80000L, // configurable keys
      58             : 
      59             :     CONTAINER       =  0x100000L, // Operated by the container at InPlace
      60             :     READONLYDOC     =  0x200000L, // also available for read-only Documents
      61             :     IMAGEROTATION   =  0x400000L, // Rotate image on Vertical/Bi-directional writing
      62             :     IMAGEREFLECTION =  0x800000L  // Mirror image on Vertical/Bi-directional writing
      63             : };
      64             : 
      65             : namespace o3tl
      66             : {
      67             :     template<> struct typed_flags<SfxSlotMode> : is_typed_flags<SfxSlotMode, 0x1ffffbfL> {};
      68             : }
      69             : 
      70             : 
      71             : class SfxRequest;
      72             : 
      73             : #define SFX_EXEC_STUB( aShellClass, aExecMethod) \
      74             :  void SfxStub##aShellClass##aExecMethod( \
      75             :    SfxShell *pShell, SfxRequest& rReq) \
      76             :   { \
      77             :       static_cast<aShellClass*>(pShell)->aExecMethod( rReq ); \
      78             :   }
      79             : 
      80             : #define SFX_STATE_STUB( aShellClass, aStateMethod) \
      81             :  void  SfxStub##aShellClass##aStateMethod( \
      82             :    SfxShell *pShell, SfxItemSet& rSet) \
      83             :   { \
      84             :       static_cast<aShellClass*>(pShell)->aStateMethod( rSet ); \
      85             :   }
      86             : 
      87             : #define SFX_STUB_PTR( aShellClass, aMethod ) \
      88             :    &SfxStub##aShellClass##aMethod
      89             : 
      90             : #define SFX_STUB_PTR_EXEC_NONE &SfxShell::EmptyExecStub
      91             : 
      92             : #define SFX_STUB_PTR_STATE_NONE &SfxShell::EmptyStateStub
      93             : 
      94             : 
      95             : 
      96             : enum SfxSlotKind
      97             : {
      98             :     SFX_KIND_STANDARD,
      99             :     SFX_KIND_ENUM,
     100             :     SFX_KIND_ATTR
     101             : };
     102             : 
     103             : 
     104             : 
     105             : struct SfxTypeAttrib
     106             : {
     107             :     sal_uInt16                  nAID;
     108             :     const char* pName;
     109             : };
     110             : 
     111             : struct SfxType
     112             : {
     113             :     TypeId          aTypeId;
     114             :     sal_uInt16          nAttribs;
     115             :     SfxTypeAttrib   aAttrib[1]; // variable length
     116             : 
     117       70893 :     const TypeId&   Type() const
     118       70893 :                     { return aTypeId; }
     119       21172 :     SfxPoolItem*    CreateItem() const
     120       21172 :                     { return static_cast<SfxPoolItem*>(aTypeId()); }
     121             : };
     122             : 
     123             : struct SfxType0
     124             : {
     125             :     TypeId          aTypeId;
     126             :     sal_uInt16          nAttribs;
     127             : 
     128             :     const TypeId&   Type() const
     129             :                     { return aTypeId; }
     130             :     SfxPoolItem*    CreateItem() const
     131             :                     { return static_cast<SfxPoolItem*>(aTypeId()); }
     132             : };
     133             : 
     134             : #define SFX_DECL_TYPE(n)    struct SfxType##n                   \
     135             :                             {                                   \
     136             :                                 TypeId          aTypeId;        \
     137             :                                 sal_uInt16          nAttribs;       \
     138             :                                 SfxTypeAttrib   aAttrib[n];     \
     139             :                             }
     140             : 
     141             : #define SFX_TYPE(Class) &a##Class##_Impl
     142             : 
     143             : SFX_DECL_TYPE(1);
     144             : SFX_DECL_TYPE(2);
     145             : SFX_DECL_TYPE(3);
     146             : SFX_DECL_TYPE(4);
     147             : SFX_DECL_TYPE(5);
     148             : SFX_DECL_TYPE(6);
     149             : SFX_DECL_TYPE(7);
     150             : SFX_DECL_TYPE(8);
     151             : SFX_DECL_TYPE(10); // for SfxDocInfoItem
     152             : SFX_DECL_TYPE(11);
     153             : 
     154             : SFX_DECL_TYPE(13); // for SwAddPrinterItem, Sd...
     155             : SFX_DECL_TYPE(14);
     156             : SFX_DECL_TYPE(16); // for SwDocDisplayItem
     157             : SFX_DECL_TYPE(17); // for SvxAddressItem
     158             : SFX_DECL_TYPE(20); // for SvxSearchItem
     159             : 
     160             : // all SfxTypes must be in this header
     161             : #undef SFX_DECL_TYPE
     162             : 
     163             : #define SFX_SLOT_ARG( aShellClass, id, GroupId, ExecMethodPtr, StateMethodPtr, Flags, ItemClass, nArg0, nArgs, Name, Prop ) \
     164             :                { id, GroupId, id, Flags | Prop, \
     165             :                  USHRT_MAX, 0, \
     166             :                  ExecMethodPtr, \
     167             :                  StateMethodPtr, \
     168             :                  (const SfxType*) &a##ItemClass##_Impl, \
     169             :                  0, 0, \
     170             :                  &a##aShellClass##Args_Impl[nArg0], nArgs, 0, Name \
     171             :                }
     172             : 
     173             : #define SFX_SLOT( aShellClass, id, GroupId, ExecMethodPtr, StateMethodPtr, Flags, ItemClass ) \
     174             :                { id, GroupId, id, Flags, \
     175             :                  0, 0, \
     176             :                  ExecMethodPtr, \
     177             :                  StateMethodPtr, \
     178             :                  (const SfxType*) &a##ItemClass##_Impl, \
     179             :                  0, 0, 0, 0, 0 \
     180             :                }
     181             : 
     182             : #define SFX_NEW_SLOT_ARG( aShellClass, id, hid, GroupId, pLinked, pNext, ExecMethodPtr, StateMethodPtr, Flags, DisableFlags, ItemClass, nArg0, nArgs, Prop, UnoName ) \
     183             :                { id, GroupId, hid, Flags | Prop, \
     184             :                  USHRT_MAX, 0, \
     185             :                  ExecMethodPtr, \
     186             :                  StateMethodPtr, \
     187             :                  (const SfxType*) &a##ItemClass##_Impl, \
     188             :                  pLinked, pNext, \
     189             :                  &a##aShellClass##Args_Impl[nArg0], nArgs, DisableFlags, UnoName \
     190             :                }
     191             : 
     192             : #define SFX_NEW_SLOT_ENUM( SlaveId, hid, GroupId, pMaster, pNext, MasterId, Value, Flags, DisableFlags, UnoName  ) \
     193             :                { SlaveId, GroupId, hid, Flags,   \
     194             :                  MasterId,  Value, \
     195             :                  0, \
     196             :                  0, \
     197             :                  (const SfxType*) &aSfxBoolItem_Impl, \
     198             :                  pMaster, \
     199             :                  pNext, \
     200             :                  0, 0, DisableFlags, UnoName \
     201             :                }
     202             : 
     203             : class SfxPoolItem;
     204             : 
     205             : struct SfxFormalArgument
     206             : {
     207             :     const SfxType*  pType;    // Type of the parameter (SfxPoolItem subclass)
     208             :     const char*     pName;    // Name of the sParameters
     209             :     sal_uInt16      nSlotId;  // Slot-Id for identification of the Parameters
     210             : 
     211             :     const TypeId&           Type() const
     212             :                             { return pType->aTypeId; }
     213      481094 :     SfxPoolItem*            CreateItem() const
     214      481094 :                             { return static_cast<SfxPoolItem*>(pType->aTypeId()); }
     215             : };
     216             : 
     217             : 
     218             : 
     219             : class SfxSlot
     220             : {
     221             : public:
     222             :     sal_uInt16    nSlotId;   // Unique slot-ID in Shell
     223             :     sal_uInt16    nGroupId;  // for configuration region
     224             :     sal_uIntPtr   nHelpId;   // Usually == nSlotId
     225             :     SfxSlotMode   nFlags;    // artihmetic ordered Flags
     226             : 
     227             :     sal_uInt16    nMasterSlotId;  // Enum-Slot for example Which-Id
     228             :     sal_uInt16    nValue;         // Value, in case of Enum-Slot
     229             : 
     230             :     SfxExecFunc   fnExec;   // Function to be executed
     231             :     SfxStateFunc  fnState;  // Function for Status
     232             : 
     233             :     const SfxType*  pType;       // SfxPoolItem-Type (Status)
     234             : 
     235             :     const SfxSlot*  pLinkedSlot; // Master-Slot for Enum value
     236             :     const SfxSlot*  pNextSlot;   // with the same Status-Method
     237             : 
     238             :     const SfxFormalArgument*  pFirstArgDef;  // first formal Argument-Definition
     239             :     sal_uInt16                nArgDefCount;  // Number of formal Argumentents
     240             :     long                      nDisableFlags; // DisableFlags that need to be
     241             :                                              // present, so that the Slot
     242             :                                              // can be enabled
     243             :     const char*     pUnoName;      // UnoName for the Slots
     244             : 
     245             : public:
     246             : 
     247             :     SfxSlotKind         GetKind() const;
     248             :     sal_uInt16          GetSlotId() const;
     249             :     sal_uIntPtr         GetHelpId() const;
     250             :     SfxSlotMode         GetMode() const;
     251             :     bool                IsMode( SfxSlotMode nMode ) const;
     252             :     sal_uInt16          GetGroupId() const;
     253             :     sal_uInt16          GetMasterSlotId() const { return nMasterSlotId; }
     254             :     sal_uInt16          GetWhich( const SfxItemPool &rPool ) const;
     255        1232 :     sal_uInt16          GetValue() const { return nValue; }
     256      135760 :     const SfxType*  GetType() const { return pType; }
     257   281882514 :     const char*     GetUnoName() const { return pUnoName; }
     258             :     SFX2_DLLPUBLIC OString    GetCommand() const;
     259             :     SFX2_DLLPUBLIC OUString    GetCommandString() const;
     260             : 
     261       32656 :     sal_uInt16          GetFormalArgumentCount() const { return nArgDefCount; }
     262      294604 :     const SfxFormalArgument& GetFormalArgument( sal_uInt16 nNo ) const
     263      294604 :                     { return pFirstArgDef[nNo]; }
     264             : 
     265      189842 :     SfxExecFunc     GetExecFnc() const { return fnExec; }
     266      220993 :     SfxStateFunc    GetStateFnc() const { return fnState; }
     267             : 
     268      116578 :     const SfxSlot*  GetLinkedSlot() const { return pLinkedSlot; }
     269      461661 :     const SfxSlot*  GetNextSlot() const { return pNextSlot; }
     270             : };
     271             : 
     272             : 
     273             : 
     274             : // returns the id of the function
     275             : 
     276    67310142 : inline sal_uInt16 SfxSlot::GetSlotId() const
     277             : {
     278    67310142 :     return nSlotId;
     279             : }
     280             : 
     281             : // returns the help-id of the slot
     282             : 
     283             : inline sal_uIntPtr SfxSlot::GetHelpId() const
     284             : {
     285             :     return nHelpId;
     286             : }
     287             : 
     288             : 
     289             : 
     290             : // returns  a bitfield with flags
     291             : 
     292           0 : inline SfxSlotMode SfxSlot::GetMode() const
     293             : {
     294           0 :     return nFlags;
     295             : }
     296             : 
     297             : 
     298             : // determines if the specified mode is assigned
     299             : 
     300      560262 : inline bool SfxSlot::IsMode( SfxSlotMode nMode ) const
     301             : {
     302      560262 :     return bool(nFlags & nMode);
     303             : }
     304             : 
     305             : 
     306             : // returns the id of the associated group
     307             : 
     308      493111 : inline sal_uInt16 SfxSlot::GetGroupId() const
     309             : {
     310      493111 :     return nGroupId;
     311             : 
     312             : }
     313             : 
     314             : #endif
     315             : 
     316             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11