1*353d8f4dSAndrew Rist /**************************************************************
2cdf0e10cSrcweir *
3*353d8f4dSAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one
4*353d8f4dSAndrew Rist * or more contributor license agreements. See the NOTICE file
5*353d8f4dSAndrew Rist * distributed with this work for additional information
6*353d8f4dSAndrew Rist * regarding copyright ownership. The ASF licenses this file
7*353d8f4dSAndrew Rist * to you under the Apache License, Version 2.0 (the
8*353d8f4dSAndrew Rist * "License"); you may not use this file except in compliance
9*353d8f4dSAndrew Rist * with the License. You may obtain a copy of the License at
10*353d8f4dSAndrew Rist *
11*353d8f4dSAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0
12*353d8f4dSAndrew Rist *
13*353d8f4dSAndrew Rist * Unless required by applicable law or agreed to in writing,
14*353d8f4dSAndrew Rist * software distributed under the License is distributed on an
15*353d8f4dSAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*353d8f4dSAndrew Rist * KIND, either express or implied. See the License for the
17*353d8f4dSAndrew Rist * specific language governing permissions and limitations
18*353d8f4dSAndrew Rist * under the License.
19*353d8f4dSAndrew Rist *
20*353d8f4dSAndrew Rist *************************************************************/
21*353d8f4dSAndrew Rist
22*353d8f4dSAndrew Rist
23cdf0e10cSrcweir #ifndef _SFX_BINDINGS_HXX
24cdf0e10cSrcweir #define _SFX_BINDINGS_HXX
25cdf0e10cSrcweir
26cdf0e10cSrcweir #include "sal/config.h"
27cdf0e10cSrcweir #include "sfx2/dllapi.h"
28cdf0e10cSrcweir #include "sal/types.h"
29cdf0e10cSrcweir #include <com/sun/star/frame/XFrame.hpp>
30cdf0e10cSrcweir #include <com/sun/star/frame/XDispatchProvider.hpp>
31cdf0e10cSrcweir #include <com/sun/star/uno/Reference.h>
32cdf0e10cSrcweir #include <com/sun/star/frame/XDispatchRecorderSupplier.hpp>
33cdf0e10cSrcweir
34cdf0e10cSrcweir //________________________________________________________________________________________________________________
35cdf0e10cSrcweir // some other includes
36cdf0e10cSrcweir //________________________________________________________________________________________________________________
37cdf0e10cSrcweir
38cdf0e10cSrcweir #include <sfx2/minarray.hxx>
39cdf0e10cSrcweir #include <sfx2/viewfrm.hxx>
40cdf0e10cSrcweir
41cdf0e10cSrcweir //________________________________________________________________________________________________________________
42cdf0e10cSrcweir // forwards, typedefs, declarations
43cdf0e10cSrcweir //________________________________________________________________________________________________________________
44cdf0e10cSrcweir
45cdf0e10cSrcweir class SfxConfigManager;
46cdf0e10cSrcweir class SystemWindow;
47cdf0e10cSrcweir class SfxArg;
48cdf0e10cSrcweir class SfxSlot;
49cdf0e10cSrcweir class SfxSlotServer;
50cdf0e10cSrcweir class SfxControllerItem;
51cdf0e10cSrcweir class SfxStateCache;
52cdf0e10cSrcweir class SfxItemSet;
53cdf0e10cSrcweir class SfxDispatcher;
54cdf0e10cSrcweir class SfxBindings;
55cdf0e10cSrcweir class SfxBindings_Impl;
56cdf0e10cSrcweir class Timer;
57cdf0e10cSrcweir struct SfxFoundCache_Impl;
58cdf0e10cSrcweir class SfxFoundCacheArr_Impl;
59cdf0e10cSrcweir class SfxWorkWindow;
60cdf0e10cSrcweir class SfxUnoControllerItem;
61cdf0e10cSrcweir typedef SfxUnoControllerItem* SfxUnoControllerItemPtr;
62cdf0e10cSrcweir SV_DECL_PTRARR( SfxUnoControllerArr_Impl, SfxUnoControllerItemPtr, 20, 20 )
63cdf0e10cSrcweir
64cdf0e10cSrcweir //________________________________________________________________________________________________________________
65cdf0e10cSrcweir // defines
66cdf0e10cSrcweir //________________________________________________________________________________________________________________
67cdf0e10cSrcweir
68cdf0e10cSrcweir #define SFX_CALLMODE_SLOT 0x00 // sync/async vom Slot
69cdf0e10cSrcweir #define SFX_CALLMODE_SYNCHRON 0x01 // synchron im selben Stackframe
70cdf0e10cSrcweir #define SFX_CALLMODE_ASYNCHRON 0x02 // asynchron per AppEvent
71cdf0e10cSrcweir #define SFX_CALLMODE_RECORD 0x04 // beim Recorden ber"ucksichtigen
72cdf0e10cSrcweir #define SFX_CALLMODE_API 0x08 // Call von der API (silent)
73cdf0e10cSrcweir #define SFX_CALLMODE_MODAL 0x10 // trotz ModalMode
74cdf0e10cSrcweir
75cdf0e10cSrcweir #define SFX_CALLMODE_STANDARD SFX_CALLMODE_RECORD
76cdf0e10cSrcweir typedef sal_uInt16 SfxCallMode;
77cdf0e10cSrcweir
78cdf0e10cSrcweir enum SfxPopupAction
79cdf0e10cSrcweir {
80cdf0e10cSrcweir SFX_POPUP_DELETE,
81cdf0e10cSrcweir SFX_POPUP_HIDE,
82cdf0e10cSrcweir SFX_POPUP_SHOW
83cdf0e10cSrcweir };
84cdf0e10cSrcweir
85cdf0e10cSrcweir //====================================================================
86cdf0e10cSrcweir class SFX2_DLLPUBLIC SfxBindings: public SfxBroadcaster
87cdf0e10cSrcweir
88cdf0e10cSrcweir /* [Beschreibung]
89cdf0e10cSrcweir
90cdf0e10cSrcweir In jeder SFx-Applikation existiert "uber die Laufzeit von vor
91cdf0e10cSrcweir <SfxApplication::Init()> bis nach <SfxApplication::Exit()> eine Instanz
92cdf0e10cSrcweir der Klasse SfxBindings. Sie wird von der SfxApplication automatisch
93cdf0e10cSrcweir angelegt und zerst"ort. Instanzen werden aber i.d.R. "uber das
94cdf0e10cSrcweir Makro <SFX_BINDINGS> oder den zugeh"origen <SfxViewFrame> besorgt
95cdf0e10cSrcweir werden.
96cdf0e10cSrcweir
97cdf0e10cSrcweir Die SfxBindings verwalten alle in den an ihr angemeldeten Controllern
98cdf0e10cSrcweir gebundenen Slot-Ids und cachen die jeweiligen <Slot-Server>
99cdf0e10cSrcweir (so nenne wir die Kombination aus SfxShell-Instanz und SfxSlot).
100cdf0e10cSrcweir In den SfxBindings ist gespeichert, ob und welche Controller dirty
101cdf0e10cSrcweir sind sowie welche Slot-Server-Caches jeweils dirty sind. Sie fa"st
102cdf0e10cSrcweir Status-Anfragen (Aufrufe der in der IDL genannten Status-Methoden)
103cdf0e10cSrcweir zusammen, die von derselben Status-Methode bedient werden, und sorgt
104cdf0e10cSrcweir f"ur die Simulation der <Pseudo-Slots>.
105cdf0e10cSrcweir */
106cdf0e10cSrcweir
107cdf0e10cSrcweir {
108cdf0e10cSrcweir friend class SfxApplication;
109cdf0e10cSrcweir friend class SfxShell;
110cdf0e10cSrcweir friend class SfxBindings_Impl;
111cdf0e10cSrcweir
112cdf0e10cSrcweir SfxBindings_Impl*pImp; // Daten der Bindings-Instanz
113cdf0e10cSrcweir SfxDispatcher* pDispatcher; // zu verwendender Dispatcher
114cdf0e10cSrcweir sal_uInt16 nRegLevel; // Lock-Level waehrend Reconfig
115cdf0e10cSrcweir
116cdf0e10cSrcweir //#if 0 // _SOLAR__PRIVATE
117cdf0e10cSrcweir private:
118cdf0e10cSrcweir SAL_DLLPRIVATE const SfxPoolItem* Execute_Impl( sal_uInt16 nSlot, const SfxPoolItem **pArgs, sal_uInt16 nModi,
119cdf0e10cSrcweir SfxCallMode nCall, const SfxPoolItem **pInternalArgs, sal_Bool bGlobalOnly=sal_False);
120cdf0e10cSrcweir SAL_DLLPRIVATE void SetSubBindings_Impl( SfxBindings* );
121cdf0e10cSrcweir SAL_DLLPRIVATE void UpdateSlotServer_Impl(); // SlotServer aktualisieren
122cdf0e10cSrcweir SAL_DLLPRIVATE SfxItemSet* CreateSet_Impl( SfxStateCache* &pCache,
123cdf0e10cSrcweir const SfxSlot* &pRealSlot,
124cdf0e10cSrcweir const SfxSlotServer**,
125cdf0e10cSrcweir SfxFoundCacheArr_Impl& );
126cdf0e10cSrcweir SAL_DLLPRIVATE sal_uInt16 GetSlotPos( sal_uInt16 nId, sal_uInt16 nStartSearchAt = 0 );
127cdf0e10cSrcweir SAL_DLLPRIVATE void Update_Impl( SfxStateCache* pCache );
128cdf0e10cSrcweir SAL_DLLPRIVATE void UpdateControllers_Impl(
129cdf0e10cSrcweir const SfxInterface* pIF,
130cdf0e10cSrcweir const SfxFoundCache_Impl* pFound,
131cdf0e10cSrcweir const SfxPoolItem *pItem,
132cdf0e10cSrcweir SfxItemState eItemState );
133cdf0e10cSrcweir DECL_DLLPRIVATE_LINK( NextJob_Impl, Timer * );
134cdf0e10cSrcweir //#endif
135cdf0e10cSrcweir
136cdf0e10cSrcweir public:
137cdf0e10cSrcweir SfxBindings();
138cdf0e10cSrcweir ~SfxBindings();
139cdf0e10cSrcweir
140cdf0e10cSrcweir void HidePopups( bool bHide = true );
141cdf0e10cSrcweir SAL_DLLPRIVATE void HidePopupCtrls_Impl( int bHide = sal_True );
142cdf0e10cSrcweir
143cdf0e10cSrcweir void SetDispatcher(SfxDispatcher *pDisp);
144cdf0e10cSrcweir
145cdf0e10cSrcweir void Update( sal_uInt16 nId ); // z.B. aus Menu::Activate
146cdf0e10cSrcweir void Update();
147cdf0e10cSrcweir SAL_DLLPRIVATE void StartUpdate_Impl(sal_Bool bComplete=sal_False);
148cdf0e10cSrcweir void Invalidate( sal_uInt16 nId );
149cdf0e10cSrcweir void Invalidate( const sal_uInt16* pIds );
150cdf0e10cSrcweir void InvalidateShell( const SfxShell &rSh, sal_Bool bDeep = sal_False );
151cdf0e10cSrcweir void InvalidateAll( sal_Bool bWithMsg );
152cdf0e10cSrcweir void SetState( const SfxItemSet &rSet );
153cdf0e10cSrcweir void SetState( const SfxPoolItem &rItem );
154cdf0e10cSrcweir void Invalidate( sal_uInt16 nId, sal_Bool bWithItem, sal_Bool bWithMsg=sal_False);
155cdf0e10cSrcweir void Invalidate( sal_uInt16 nId, sal_Bool bWithMsg);
156cdf0e10cSrcweir sal_Bool IsInUpdate() const;
157cdf0e10cSrcweir void SetVisibleState( sal_uInt16 nId, sal_Bool bShow );
158cdf0e10cSrcweir
159cdf0e10cSrcweir sal_Bool IsBound( sal_uInt16 nMsgId, sal_uInt16 nStartSearchAt = 0 );
160cdf0e10cSrcweir
161cdf0e10cSrcweir const SfxSlot* GetSlot( sal_uInt16 nMsgId );
162cdf0e10cSrcweir SfxStateCache* GetStateCache( sal_uInt16 nId, sal_uInt16 *pPos = 0 );
163cdf0e10cSrcweir SAL_DLLPRIVATE SfxStateCache* GetAnyStateCache_Impl( sal_uInt16 nId );
164cdf0e10cSrcweir SfxItemState QueryState( sal_uInt16 nSID, SfxPoolItem* &rpState );
165cdf0e10cSrcweir
166cdf0e10cSrcweir const SfxPoolItem* ExecuteSynchron( sal_uInt16 nSlot,
167cdf0e10cSrcweir const SfxPoolItem **pArgs = 0,
168cdf0e10cSrcweir sal_uInt16 nModi = 0,
169cdf0e10cSrcweir const SfxPoolItem **pInternalArgs = 0);
170cdf0e10cSrcweir sal_Bool Execute( sal_uInt16 nSlot,
171cdf0e10cSrcweir const SfxPoolItem **pArgs = 0,
172cdf0e10cSrcweir sal_uInt16 nModi = 0,
173cdf0e10cSrcweir SfxCallMode nCall = SFX_CALLMODE_SLOT,
174cdf0e10cSrcweir const SfxPoolItem **pInternalArgs = 0);
175cdf0e10cSrcweir
176cdf0e10cSrcweir SAL_DLLPRIVATE void SetDispatchProvider_Impl( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatchProvider > & rFrame );
177cdf0e10cSrcweir SAL_DLLPRIVATE const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatchProvider > & GetDispatchProvider_Impl() const;
178cdf0e10cSrcweir void SetActiveFrame( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame > & rFrame );
179cdf0e10cSrcweir const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame > GetActiveFrame() const;
180cdf0e10cSrcweir // Reconfig
181cdf0e10cSrcweir int IsInRegistrations() const;
182cdf0e10cSrcweir sal_uInt16 EnterRegistrations(const char *pFile = 0, int nLine = 0);
183cdf0e10cSrcweir void LeaveRegistrations( sal_uInt16 nLevel = USHRT_MAX, const char *pFile = 0, int nLine = 0 );
184cdf0e10cSrcweir void Register( SfxControllerItem& rBinding );
185cdf0e10cSrcweir void Release( SfxControllerItem& rBinding );
186cdf0e10cSrcweir SystemWindow* GetSystemWindow() const;
GetDispatcher() const187cdf0e10cSrcweir SfxDispatcher* GetDispatcher() const
188cdf0e10cSrcweir { return pDispatcher; }
189cdf0e10cSrcweir com::sun::star::uno::Reference< com::sun::star::frame::XDispatchRecorder > GetRecorder() const;
190cdf0e10cSrcweir com::sun::star::uno::Reference < com::sun::star::frame::XDispatch >
191cdf0e10cSrcweir GetDispatch( const SfxSlot*, const com::sun::star::util::URL& aURL, sal_Bool bMasterCommand );
192cdf0e10cSrcweir //#if 0 // _SOLAR__PRIVATE
193cdf0e10cSrcweir SAL_DLLPRIVATE void ContextChanged_Impl();
194cdf0e10cSrcweir SAL_DLLPRIVATE void Execute_Impl( SfxRequest& rReq, const SfxSlot* pSlot, SfxShell* pShell );
195cdf0e10cSrcweir SAL_DLLPRIVATE void DeleteControllers_Impl();
196cdf0e10cSrcweir SAL_DLLPRIVATE SfxPopupAction GetPopupAction_Impl() const;
GetDispatcher_Impl()197cdf0e10cSrcweir SAL_DLLPRIVATE SfxDispatcher* GetDispatcher_Impl() { return pDispatcher; }
198cdf0e10cSrcweir SAL_DLLPRIVATE void ClearCache_Impl( sal_uInt16 nSlotId );
IsInUpdate_Impl() const199cdf0e10cSrcweir SAL_DLLPRIVATE sal_Bool IsInUpdate_Impl() const{ return IsInUpdate(); }
200cdf0e10cSrcweir SAL_DLLPRIVATE void RegisterInternal_Impl( SfxControllerItem& rBinding );
201cdf0e10cSrcweir SAL_DLLPRIVATE void Register_Impl( SfxControllerItem& rBinding, sal_Bool );
202cdf0e10cSrcweir SAL_DLLPRIVATE SfxWorkWindow* GetWorkWindow_Impl() const;
203cdf0e10cSrcweir SAL_DLLPRIVATE void SetWorkWindow_Impl( SfxWorkWindow* );
204cdf0e10cSrcweir SAL_DLLPRIVATE SfxBindings* GetSubBindings_Impl( sal_Bool bTop = sal_False ) const;
205cdf0e10cSrcweir SAL_DLLPRIVATE void InvalidateUnoControllers_Impl();
206cdf0e10cSrcweir SAL_DLLPRIVATE void RegisterUnoController_Impl( SfxUnoControllerItem* );
207cdf0e10cSrcweir SAL_DLLPRIVATE void ReleaseUnoController_Impl( SfxUnoControllerItem* );
208cdf0e10cSrcweir SAL_DLLPRIVATE sal_Bool ExecuteCommand_Impl( const String& rCommand );
209cdf0e10cSrcweir SAL_DLLPRIVATE void SetRecorder_Impl( com::sun::star::uno::Reference< com::sun::star::frame::XDispatchRecorder >& );
210cdf0e10cSrcweir SAL_DLLPRIVATE void ExecuteGlobal_Impl( sal_uInt16 nId );
211cdf0e10cSrcweir SAL_DLLPRIVATE void InvalidateSlotsInMap_Impl();
212cdf0e10cSrcweir SAL_DLLPRIVATE void AddSlotToInvalidateSlotsMap_Impl( sal_uInt16 nId );
213cdf0e10cSrcweir //#endif
214cdf0e10cSrcweir };
215cdf0e10cSrcweir
216cdf0e10cSrcweir #ifdef DBG_UTIL
217cdf0e10cSrcweir #define ENTERREGISTRATIONS() EnterRegistrations(__FILE__, __LINE__)
218cdf0e10cSrcweir #define LEAVEREGISTRATIONS() LeaveRegistrations(USHRT_MAX, __FILE__, __LINE__)
219cdf0e10cSrcweir #define DENTERREGISTRATIONS( ) \
220cdf0e10cSrcweir EnterRegistrations( (ByteString(__FILE__).Append('(').Append(ByteString::CreateFromInt64((sal_uIntPtr)this).Append(')'))).GetBufferAccess(), __LINE__ )
221cdf0e10cSrcweir #define DLEAVEREGISTRATIONS( ) \
222cdf0e10cSrcweir LeaveRegistrations( USHRT_MAX, (ByteString(__FILE__).Append('(').Append(ByteString::CreateFromInt64((sal_uIntPtr)this).Append(')'))).GetBufferAccess(), __LINE__ )
223cdf0e10cSrcweir #else
224cdf0e10cSrcweir #define ENTERREGISTRATIONS() EnterRegistrations()
225cdf0e10cSrcweir #define LEAVEREGISTRATIONS() LeaveRegistrations()
226cdf0e10cSrcweir #define DENTERREGISTRATIONS( ) EnterRegistrations()
227cdf0e10cSrcweir #define DLEAVEREGISTRATIONS( ) LeaveRegistrations()
228cdf0e10cSrcweir #endif
229cdf0e10cSrcweir
230cdf0e10cSrcweir //--------------------------------------------------------------------
231cdf0e10cSrcweir
IsInRegistrations() const232cdf0e10cSrcweir inline int SfxBindings::IsInRegistrations() const
233cdf0e10cSrcweir
234cdf0e10cSrcweir /* [Beschreibung]
235cdf0e10cSrcweir
236cdf0e10cSrcweir Stellt fest, ob an der SfxBindings Instanz gerade <SfxContollerItems>
237cdf0e10cSrcweir an- oder abgemeldet werden, also noch <SfxBindings::EnterRegistrations()>
238cdf0e10cSrcweir Aufrufe nicht mit <SfxBindings::EnterRegistrations()> geschlo"sen wurden.
239cdf0e10cSrcweir
240cdf0e10cSrcweir [R"uckgabewert]
241cdf0e10cSrcweir
242cdf0e10cSrcweir int sal_True
243cdf0e10cSrcweir Die SfxBindings Instanz ist gerade im Registrierungs-
244cdf0e10cSrcweir Modus. Es erfolgen also keine Status-Updates.
245cdf0e10cSrcweir
246cdf0e10cSrcweir sal_False
247cdf0e10cSrcweir Die SfxBindings Instanz ist gerade im normalen
248cdf0e10cSrcweir Modus. Es k"oennen also Status-Updates erfolgen.
249cdf0e10cSrcweir */
250cdf0e10cSrcweir
251cdf0e10cSrcweir {
252cdf0e10cSrcweir return 0 != nRegLevel;
253cdf0e10cSrcweir }
254cdf0e10cSrcweir
255cdf0e10cSrcweir //--------------------------------------------------------------------
256cdf0e10cSrcweir
257cdf0e10cSrcweir #endif
258cdf0e10cSrcweir
259