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 _SFXOBJFACE_HXX
20 : #define _SFXOBJFACE_HXX
21 :
22 : #include "sal/config.h"
23 :
24 : #include "rtl/ustring.hxx"
25 : #include "sfx2/dllapi.h"
26 : #include "sal/types.h"
27 : #include <tools/string.hxx>
28 : #include <tools/resid.hxx>
29 :
30 : #include <sfx2/msg.hxx>
31 :
32 : struct SfxFormalArgument;
33 : struct SfxInterface_Impl;
34 : class SfxConfigItem;
35 : class SfxModule;
36 : class SvStream;
37 :
38 : class SFX2_DLLPUBLIC SfxInterface
39 : {
40 : friend class SfxSlotPool;
41 :
42 : const char* pName; // Sfx-internal name of interface
43 : const SfxInterface* pGenoType; // base interface
44 : SfxSlot* pSlots; // SlotMap
45 : sal_uInt16 nCount; // number of slots in SlotMap
46 : SfxInterfaceId nClassId; // Id of interface
47 : ResId aNameResId; // ResId of external interface name
48 : SfxInterface_Impl* pImpData;
49 :
50 : SfxSlot* operator[]( sal_uInt16 nPos ) const;
51 :
52 : public:
53 : SfxInterface( const char *pClass,
54 : const ResId& rResId,
55 : SfxInterfaceId nClassId,
56 : const SfxInterface* pGeno,
57 : SfxSlot &rMessages, sal_uInt16 nMsgCount );
58 : virtual ~SfxInterface();
59 :
60 : void SetSlotMap( SfxSlot& rMessages, sal_uInt16 nMsgCount );
61 : inline sal_uInt16 Count() const;
62 :
63 : const SfxSlot* GetRealSlot( const SfxSlot * ) const;
64 : const SfxSlot* GetRealSlot( sal_uInt16 nSlotId ) const;
65 : virtual const SfxSlot* GetSlot( sal_uInt16 nSlotId ) const;
66 : const SfxSlot* GetSlot( const String& rCommand ) const;
67 :
68 : const char* GetClassName() const { return pName; }
69 42352 : bool HasName() const { return 0 != aNameResId.GetId(); }
70 : OUString GetName() const
71 : { return HasName() ? aNameResId.toString() : OUString(); }
72 60 : ResMgr* GetResMgr() const
73 60 : { return aNameResId.GetResMgr(); }
74 :
75 208 : const SfxInterface* GetGenoType() const { return pGenoType; }
76 : const SfxInterface* GetRealInterfaceForSlot( const SfxSlot* ) const;
77 :
78 : void RegisterObjectBar( sal_uInt16, const ResId&, const String* pST=0 );
79 : void RegisterObjectBar( sal_uInt16, const ResId&, sal_uInt32 nFeature, const String* pST=0 );
80 : void RegisterChildWindow( sal_uInt16, sal_Bool bContext, const String* pST=0 );
81 : void RegisterChildWindow( sal_uInt16, sal_Bool bContext, sal_uInt32 nFeature, const String* pST=0 );
82 : void RegisterStatusBar( const ResId& );
83 : const ResId& GetObjectBarResId( sal_uInt16 nNo ) const;
84 : sal_uInt16 GetObjectBarPos( sal_uInt16 nNo ) const;
85 : sal_uInt32 GetObjectBarFeature( sal_uInt16 nNo ) const;
86 : sal_uInt16 GetObjectBarCount() const;
87 : void SetObjectBarPos( sal_uInt16 nPos, sal_uInt16 nId );
88 : const String* GetObjectBarName( sal_uInt16 nNo ) const;
89 : sal_Bool IsObjectBarVisible( sal_uInt16 nNo) const;
90 : sal_uInt32 GetChildWindowFeature( sal_uInt16 nNo ) const;
91 : sal_uInt32 GetChildWindowId( sal_uInt16 nNo ) const;
92 : sal_uInt16 GetChildWindowCount() const;
93 : void RegisterPopupMenu( const ResId& );
94 : const ResId& GetPopupMenuResId() const;
95 : const ResId& GetStatusBarResId() const;
96 :
97 : void Register( SfxModule* );
98 :
99 0 : SAL_DLLPRIVATE int ContainsSlot_Impl( const SfxSlot *pSlot ) const
100 0 : { return pSlot >= pSlots && pSlot < pSlots + Count(); }
101 : SAL_DLLPRIVATE ResMgr* GetResManager_Impl() const
102 : { return aNameResId.GetResMgr(); }
103 : };
104 :
105 : //--------------------------------------------------------------------
106 :
107 : // returns the number of functions in this cluster
108 :
109 162000 : inline sal_uInt16 SfxInterface::Count() const
110 : {
111 162000 : return nCount;
112 : }
113 :
114 : //--------------------------------------------------------------------
115 :
116 : // returns a function by position in the array
117 :
118 178943 : inline SfxSlot* SfxInterface::operator[]( sal_uInt16 nPos ) const
119 : {
120 178943 : return nPos < nCount? pSlots+nPos: 0;
121 : }
122 :
123 : #endif
124 :
125 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|