fdo#74697 Add Bluez 5 support for impress remote.
[LibreOffice.git] / include / sfx2 / bindings.hxx
blob664673cf66d55a5ade284a0b82f4d0293d4deef4
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
19 #ifndef _SFX_BINDINGS_HXX
20 #define _SFX_BINDINGS_HXX
22 #include "sal/config.h"
23 #include "sfx2/dllapi.h"
24 #include "sal/types.h"
25 #include "rtl/strbuf.hxx"
26 #include <tools/link.hxx>
27 #include <com/sun/star/frame/XFrame.hpp>
28 #include <com/sun/star/frame/XDispatchProvider.hpp>
29 #include <com/sun/star/uno/Reference.h>
30 #include <com/sun/star/frame/XDispatchRecorderSupplier.hpp>
31 #include <vector>
33 //________________________________________________________________________________________________________________
34 // some other includes
35 //________________________________________________________________________________________________________________
37 #include <sfx2/viewfrm.hxx>
39 //________________________________________________________________________________________________________________
40 // forwards, typedefs, declarations
41 //________________________________________________________________________________________________________________
43 class SystemWindow;
44 class SfxSlot;
45 class SfxSlotServer;
46 class SfxControllerItem;
47 class SfxStateCache;
48 class SfxItemSet;
49 class SfxDispatcher;
50 class SfxBindings;
51 class SfxBindings_Impl;
52 class Timer;
53 struct SfxFoundCache_Impl;
54 class SfxFoundCacheArr_Impl;
55 class SfxWorkWindow;
56 class SfxUnoControllerItem;
58 typedef std::vector<SfxUnoControllerItem*> SfxUnoControllerArr_Impl;
60 #define SFX_CALLMODE_SLOT 0x00 // sync/async from Slot
61 #define SFX_CALLMODE_SYNCHRON 0x01 // synchronously in the same Stackframe
62 #define SFX_CALLMODE_ASYNCHRON 0x02 // asynchronously via AppEvent
63 #define SFX_CALLMODE_RECORD 0x04 // take into accont while recording
64 #define SFX_CALLMODE_API 0x08 // API call (silent)
65 #define SFX_CALLMODE_MODAL 0x10 // despite ModalMode
67 #define SFX_CALLMODE_STANDARD SFX_CALLMODE_RECORD
68 typedef sal_uInt16 SfxCallMode;
70 enum SfxPopupAction
72 SFX_POPUP_DELETE,
73 SFX_POPUP_HIDE,
74 SFX_POPUP_SHOW
77 //====================================================================
78 class SFX2_DLLPUBLIC SfxBindings: public SfxBroadcaster
80 /* [Description]
82 In each SFx application one instance of the SfxBindings-Class will
83 exists from <SfxApplication::Init()> until <SfxApplication::Exit()>.
84 This instance is automatically created and destroyed by SfxApplication.
85 However these instances will be handled by the Macro <SFX_BINDINGS>
86 or the associated <SfxViewFrame>.
88 The SfxBindings manages all of its Slot-Ids bound by the registerd
89 controllers and keeps a cache of the <Slot-Server> respectively.
90 (it is what we call the combination of SfxShell instance and SfxSlot).
91 In the SfxBindings it is stored, if and in this case which controllers
92 that are dirty and which Slot-Server-Caches are dirty respectively.
93 It summarizes status queries (calls to the status methods specified
94 in the IDL) that are served by the same state methods, and handles
95 the simulation of <Pseudo-Slots>.
99 friend class SfxApplication;
100 friend class SfxShell;
101 friend class SfxBindings_Impl;
103 SfxBindings_Impl*pImp; // Data of the Bindings instance
104 SfxDispatcher* pDispatcher; // Dispatcher, to be used
105 sal_uInt16 nRegLevel; // Lock-Level while Reconfig
107 private:
108 SAL_DLLPRIVATE const SfxPoolItem* Execute_Impl( sal_uInt16 nSlot, const SfxPoolItem **pArgs, sal_uInt16 nModi,
109 SfxCallMode nCall, const SfxPoolItem **pInternalArgs, sal_Bool bGlobalOnly=sal_False);
110 SAL_DLLPRIVATE void SetSubBindings_Impl( SfxBindings* );
111 SAL_DLLPRIVATE void UpdateSlotServer_Impl(); // Update SlotServer
112 SAL_DLLPRIVATE SfxItemSet* CreateSet_Impl( SfxStateCache* &pCache,
113 const SfxSlot* &pRealSlot,
114 const SfxSlotServer**,
115 SfxFoundCacheArr_Impl& );
116 SAL_DLLPRIVATE sal_uInt16 GetSlotPos( sal_uInt16 nId, sal_uInt16 nStartSearchAt = 0 );
117 SAL_DLLPRIVATE void Update_Impl( SfxStateCache* pCache );
118 SAL_DLLPRIVATE void UpdateControllers_Impl(
119 const SfxInterface* pIF,
120 const SfxFoundCache_Impl* pFound,
121 const SfxPoolItem *pItem,
122 SfxItemState eItemState );
123 SAL_DLLPRIVATE SfxStateCache* GetStateCache( sal_uInt16 nId, sal_uInt16 *pPos);
124 DECL_DLLPRIVATE_LINK( NextJob_Impl, Timer * );
126 public:
127 SfxBindings();
128 ~SfxBindings();
130 void HidePopups( bool bHide = true );
131 SAL_DLLPRIVATE void HidePopupCtrls_Impl( bool bHide = true );
133 void SetDispatcher(SfxDispatcher *pDisp);
135 void Update( sal_uInt16 nId ); // For example, from Menu::Activate
136 void Update();
137 SAL_DLLPRIVATE void StartUpdate_Impl(sal_Bool bComplete=sal_False);
138 void Invalidate( sal_uInt16 nId );
139 void Invalidate( const sal_uInt16* pIds );
140 void InvalidateShell( const SfxShell &rSh, sal_Bool bDeep = sal_False );
141 void InvalidateAll( sal_Bool bWithMsg );
142 void SetState( const SfxItemSet &rSet );
143 void SetState( const SfxPoolItem &rItem );
144 void Invalidate( sal_uInt16 nId, sal_Bool bWithItem, sal_Bool bWithMsg=sal_False);
145 void Invalidate( sal_uInt16 nId, sal_Bool bWithMsg);
146 sal_Bool IsInUpdate() const;
147 void SetVisibleState( sal_uInt16 nId, sal_Bool bShow );
149 sal_Bool IsBound( sal_uInt16 nMsgId, sal_uInt16 nStartSearchAt = 0 );
151 const SfxSlot* GetSlot( sal_uInt16 nMsgId );
152 SfxStateCache* GetStateCache( sal_uInt16 nId);
153 SAL_DLLPRIVATE SfxStateCache* GetAnyStateCache_Impl( sal_uInt16 nId );
155 * @param rpState the caller has to delete the pointer
157 SfxItemState QueryState( sal_uInt16 nSID, SfxPoolItem* &rpState );
159 const SfxPoolItem* ExecuteSynchron( sal_uInt16 nSlot,
160 const SfxPoolItem **pArgs = 0,
161 sal_uInt16 nModi = 0,
162 const SfxPoolItem **pInternalArgs = 0);
163 sal_Bool Execute( sal_uInt16 nSlot,
164 const SfxPoolItem **pArgs = 0,
165 sal_uInt16 nModi = 0,
166 SfxCallMode nCall = SFX_CALLMODE_SLOT,
167 const SfxPoolItem **pInternalArgs = 0);
169 SAL_DLLPRIVATE void SetDispatchProvider_Impl( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatchProvider > & rFrame );
170 SAL_DLLPRIVATE const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatchProvider > & GetDispatchProvider_Impl() const;
171 void SetActiveFrame( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame > & rFrame );
172 const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame > GetActiveFrame() const;
173 // Reconfig
174 int IsInRegistrations() const;
175 sal_uInt16 EnterRegistrations(const char *pFile = 0, int nLine = 0);
176 void LeaveRegistrations( sal_uInt16 nLevel = USHRT_MAX, const char *pFile = 0, int nLine = 0 );
177 void Register( SfxControllerItem& rBinding );
178 void Release( SfxControllerItem& rBinding );
179 SystemWindow* GetSystemWindow() const;
180 SfxDispatcher* GetDispatcher() const
181 { return pDispatcher; }
182 com::sun::star::uno::Reference< com::sun::star::frame::XDispatchRecorder > GetRecorder() const;
183 com::sun::star::uno::Reference < com::sun::star::frame::XDispatch >
184 GetDispatch( const SfxSlot*, const com::sun::star::util::URL& aURL, sal_Bool bMasterCommand );
185 SAL_DLLPRIVATE void ContextChanged_Impl();
186 SAL_DLLPRIVATE void Execute_Impl( SfxRequest& rReq, const SfxSlot* pSlot, SfxShell* pShell );
187 SAL_DLLPRIVATE void DeleteControllers_Impl();
188 SAL_DLLPRIVATE SfxDispatcher* GetDispatcher_Impl() { return pDispatcher; }
189 SAL_DLLPRIVATE void ClearCache_Impl( sal_uInt16 nSlotId );
190 SAL_DLLPRIVATE sal_Bool IsInUpdate_Impl() const{ return IsInUpdate(); }
191 SAL_DLLPRIVATE void RegisterInternal_Impl( SfxControllerItem& rBinding );
192 SAL_DLLPRIVATE void Register_Impl( SfxControllerItem& rBinding, sal_Bool );
193 SAL_DLLPRIVATE SfxWorkWindow* GetWorkWindow_Impl() const;
194 SAL_DLLPRIVATE void SetWorkWindow_Impl( SfxWorkWindow* );
195 SAL_DLLPRIVATE SfxBindings* GetSubBindings_Impl( sal_Bool bTop = sal_False ) const;
196 SAL_DLLPRIVATE void InvalidateUnoControllers_Impl();
197 SAL_DLLPRIVATE void RegisterUnoController_Impl( SfxUnoControllerItem* );
198 SAL_DLLPRIVATE void ReleaseUnoController_Impl( SfxUnoControllerItem* );
199 SAL_DLLPRIVATE sal_Bool ExecuteCommand_Impl( const String& rCommand );
200 SAL_DLLPRIVATE void SetRecorder_Impl( com::sun::star::uno::Reference< com::sun::star::frame::XDispatchRecorder >& );
201 SAL_DLLPRIVATE void InvalidateSlotsInMap_Impl();
202 SAL_DLLPRIVATE void AddSlotToInvalidateSlotsMap_Impl( sal_uInt16 nId );
205 #ifdef DBG_UTIL
206 #define ENTERREGISTRATIONS() EnterRegistrations(__FILE__, __LINE__)
207 #define LEAVEREGISTRATIONS() LeaveRegistrations(USHRT_MAX, __FILE__, __LINE__)
208 #define DENTERREGISTRATIONS() \
209 EnterRegistrations( OStringBuffer(__FILE__).append('(').append(reinterpret_cast<sal_Int64>(this)).append(')').getStr(), __LINE__ )
210 #define DLEAVEREGISTRATIONS( ) \
211 LeaveRegistrations( USHRT_MAX, OStringBuffer(__FILE__).append('(').append(reinterpret_cast<sal_Int64>(this)).append(')').getStr(), __LINE__ )
212 #else
213 #define ENTERREGISTRATIONS() EnterRegistrations()
214 #define LEAVEREGISTRATIONS() LeaveRegistrations()
215 #define DENTERREGISTRATIONS() EnterRegistrations()
216 #define DLEAVEREGISTRATIONS() LeaveRegistrations()
217 #endif
219 //--------------------------------------------------------------------
221 inline int SfxBindings::IsInRegistrations() const
223 /* [Description]
225 Determines whether the <SfxContollerItems> SfxBindings instance is
226 registerd or unregisted, i.e. <SfxBindings::EnterRegistrations()>
227 calls that have not been closed by <SfxBindings::LeaveRegistrations()>.
229 [Return value]
231 int sal_True
232 The SfxBindings instance is currently in
233 Registration-Mode. No status updates .
235 int sal_False
236 The SfxBindings instance is the normal mode.
237 Status updates can be done.
241 return 0 != nRegLevel;
244 //--------------------------------------------------------------------
246 #endif
248 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */