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