bump product version to 4.1.6.2
[LibreOffice.git] / sfx2 / source / inc / statcach.hxx
blob866c817ebfe8b1802b8b309376a6e805777b61f1
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 _SFXSTATCACH_HXX
20 #define _SFXSTATCACH_HXX
22 #include <com/sun/star/frame/XDispatchProviderInterceptor.hpp>
23 #include <com/sun/star/frame/XDispatch.hpp>
24 #include <com/sun/star/frame/XDispatchProvider.hpp>
25 #include <com/sun/star/frame/XStatusListener.hpp>
26 #include <com/sun/star/frame/FrameSearchFlag.hpp>
27 #include <com/sun/star/frame/XDispatchProviderInterception.hpp>
28 #include <com/sun/star/frame/FeatureStateEvent.hpp>
29 #include <com/sun/star/frame/DispatchDescriptor.hpp>
30 #include <com/sun/star/beans/PropertyValue.hpp>
31 #include <cppuhelper/weak.hxx>
33 #include <sfx2/bindings.hxx>
35 #include "slotserv.hxx"
37 #include <sfx2/sfxuno.hxx>
39 class SfxControllerItem;
40 class SfxDispatcher;
41 class BindDispatch_Impl : public ::com::sun::star::frame::XStatusListener ,
42 public ::com::sun::star::lang::XTypeProvider ,
43 public ::cppu::OWeakObject
45 friend class SfxStateCache;
46 ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatch > xDisp;
47 ::com::sun::star::util::URL aURL;
48 ::com::sun::star::frame::FeatureStateEvent aStatus;
49 SfxStateCache* pCache;
50 const SfxSlot* pSlot;
52 public:
53 BindDispatch_Impl(
54 const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatch > & rDisp,
55 const ::com::sun::star::util::URL& rURL,
56 SfxStateCache* pStateCache, const SfxSlot* pSlot );
58 SFX_DECL_XINTERFACE_XTYPEPROVIDER
60 virtual void SAL_CALL statusChanged( const ::com::sun::star::frame::FeatureStateEvent& Event ) throw ( ::com::sun::star::uno::RuntimeException );
61 virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source ) throw ( ::com::sun::star::uno::RuntimeException );
63 void Release();
64 const ::com::sun::star::frame::FeatureStateEvent& GetStatus() const;
65 void Dispatch( com::sun::star::uno::Sequence < com::sun::star::beans::PropertyValue > aProps, sal_Bool bForceSynchron = sal_False );
68 class SfxStateCache
70 friend class BindDispatch_Impl;
71 BindDispatch_Impl* pDispatch;
72 sal_uInt16 nId; // Slot-Id
73 SfxControllerItem* pInternalController;
74 com::sun::star::uno::Reference < com::sun::star::frame::XDispatch > xMyDispatch;
75 SfxControllerItem* pController; // Pointer to first bound Controller (interlinked with each other)
76 SfxSlotServer aSlotServ; // SlotServer, SlotPtr = 0 -> not on Stack
77 SfxPoolItem* pLastItem; // Last sent Item, never -1
78 SfxItemState eLastState; // Last sent State
79 sal_Bool bCtrlDirty:1; // Update Controller?
80 sal_Bool bSlotDirty:1; // Present Funktion, must be updated
81 sal_Bool bItemVisible:1; // item visibility
82 sal_Bool bItemDirty; // Validity of pLastItem
84 private:
85 SfxStateCache( const SfxStateCache& rOrig ); // inward
86 void SetState_Impl( SfxItemState, const SfxPoolItem*, sal_Bool bMaybeDirty=sal_False );
88 public:
89 SfxStateCache( sal_uInt16 nFuncId );
90 ~SfxStateCache();
92 sal_uInt16 GetId() const;
94 const SfxSlotServer* GetSlotServer( SfxDispatcher &rDispat, const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatchProvider > & xProv );
95 const SfxSlotServer* GetSlotServer( SfxDispatcher &rDispat )
96 { return GetSlotServer( rDispat, ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatchProvider > () ); }
97 ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatch > GetDispatch() const;
98 void Dispatch( const SfxItemSet* pSet, sal_Bool bForceSynchron = sal_False );
99 sal_Bool IsControllerDirty() const
100 { return bCtrlDirty ? sal_True : sal_False; }
101 SfxPoolItem* GetItem() const { return pLastItem; }
102 void ClearCache();
104 void SetState( SfxItemState, const SfxPoolItem*, sal_Bool bMaybeDirty=sal_False );
105 void SetCachedState(sal_Bool bAlways = sal_False);
106 void DeleteFloatingWindows();
107 void Invalidate( sal_Bool bWithSlot );
108 void SetVisibleState( sal_Bool bShow=sal_True );
110 SfxControllerItem* ChangeItemLink( SfxControllerItem* pNewBinding );
111 SfxControllerItem* GetItemLink() const;
112 void SetInternalController( SfxControllerItem* pCtrl )
113 { DBG_ASSERT( !pInternalController, "Only one internal controller allowed!" ); pInternalController = pCtrl; }
114 void ReleaseInternalController() { pInternalController = 0; }
115 SfxControllerItem* GetInternalController() const { return pInternalController; }
116 com::sun::star::uno::Reference < com::sun::star::frame::XDispatch >
117 GetInternalDispatch() const
118 { return xMyDispatch; }
119 void SetInternalDispatch( const com::sun::star::uno::Reference < com::sun::star::frame::XDispatch >& rDisp )
120 { xMyDispatch = rDisp; }
123 //--------------------------------------------------------------------
125 // clears Cached-Item
127 inline void SfxStateCache::ClearCache()
129 bItemDirty = sal_True;
132 //--------------------------------------------------------------------
134 // registeres a item representing this function
136 inline SfxControllerItem* SfxStateCache::ChangeItemLink( SfxControllerItem* pNewBinding )
138 SfxControllerItem* pOldBinding = pController;
139 pController = pNewBinding;
140 if ( pNewBinding )
142 bCtrlDirty = sal_True;
143 bItemDirty = sal_True;
145 return pOldBinding;
147 //--------------------------------------------------------------------
149 // returns the func binding which becomes called on spreading states
151 inline SfxControllerItem* SfxStateCache::GetItemLink() const
153 return pController;
155 //--------------------------------------------------------------------
157 inline sal_uInt16 SfxStateCache::GetId() const
159 return nId;
162 #endif
164 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */