xref: /trunk/main/sfx2/source/control/ctrlitem.cxx (revision cf6516809c57e1bb0a940545cca99cdad54d4ce2)
1d119d52dSAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3d119d52dSAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4d119d52dSAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5d119d52dSAndrew Rist  * distributed with this work for additional information
6d119d52dSAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7d119d52dSAndrew Rist  * to you under the Apache License, Version 2.0 (the
8d119d52dSAndrew Rist  * "License"); you may not use this file except in compliance
9d119d52dSAndrew Rist  * with the License.  You may obtain a copy of the License at
10cdf0e10cSrcweir  *
11d119d52dSAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12cdf0e10cSrcweir  *
13d119d52dSAndrew Rist  * Unless required by applicable law or agreed to in writing,
14d119d52dSAndrew Rist  * software distributed under the License is distributed on an
15d119d52dSAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16d119d52dSAndrew Rist  * KIND, either express or implied.  See the License for the
17d119d52dSAndrew Rist  * specific language governing permissions and limitations
18d119d52dSAndrew Rist  * under the License.
19cdf0e10cSrcweir  *
20d119d52dSAndrew Rist  *************************************************************/
21d119d52dSAndrew Rist 
22d119d52dSAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_sfx2.hxx"
26cdf0e10cSrcweir #include <svl/itempool.hxx>
27cdf0e10cSrcweir #ifndef GCC
28cdf0e10cSrcweir #endif
29cdf0e10cSrcweir 
30cdf0e10cSrcweir #include <sfx2/ctrlitem.hxx>
31cdf0e10cSrcweir #include <sfx2/bindings.hxx>
32cdf0e10cSrcweir #include <sfx2/dispatch.hxx>
33cdf0e10cSrcweir #include <sfx2/msgpool.hxx>
34cdf0e10cSrcweir #include "statcach.hxx"
35cdf0e10cSrcweir #include <sfx2/viewfrm.hxx>
36cdf0e10cSrcweir 
37cdf0e10cSrcweir //====================================================================
38cdf0e10cSrcweir 
39cdf0e10cSrcweir DBG_NAME(SfxControllerItem);
40cdf0e10cSrcweir 
41cdf0e10cSrcweir //--------------------------------------------------------------------
42cdf0e10cSrcweir #ifdef DBG_UTIL
43cdf0e10cSrcweir 
CheckConfigure_Impl(sal_uIntPtr nType)44cdf0e10cSrcweir void SfxControllerItem::CheckConfigure_Impl( sal_uIntPtr nType )
45cdf0e10cSrcweir {
46cdf0e10cSrcweir     // echter Slot? (also kein Separator etc.)
47cdf0e10cSrcweir     if ( !nId )
48cdf0e10cSrcweir         return;
49cdf0e10cSrcweir 
50cdf0e10cSrcweir     // ist die Id "uberhaupt in 'nType' konfigurierbar?
51cdf0e10cSrcweir     const SfxSlot *pSlot = SFX_SLOTPOOL().GetSlot(nId);
52cdf0e10cSrcweir     DBG_ASSERTWARNING( pSlot, "SfxControllerItem: binding not existing slot" );
53cdf0e10cSrcweir     if ( pSlot && !pSlot->IsMode(nType) )
54cdf0e10cSrcweir     {
55cdf0e10cSrcweir         DBG_WARNING( "SfxControllerItem: slot without ...Config-flag" );
56cdf0e10cSrcweir         DbgOutf( "SfxControllerItem: Config-flag missing at SID %5d",
57cdf0e10cSrcweir                  pSlot->GetSlotId() );
58cdf0e10cSrcweir     }
59cdf0e10cSrcweir }
60cdf0e10cSrcweir 
61cdf0e10cSrcweir #endif
62cdf0e10cSrcweir 
63cdf0e10cSrcweir //--------------------------------------------------------------------
64cdf0e10cSrcweir 
65cdf0e10cSrcweir // returns the next registered SfxControllerItem with the same id
66cdf0e10cSrcweir 
GetItemLink()67cdf0e10cSrcweir SfxControllerItem* SfxControllerItem::GetItemLink()
68cdf0e10cSrcweir {
69cdf0e10cSrcweir     DBG_MEMTEST();
70cdf0e10cSrcweir     DBG_CHKTHIS(SfxControllerItem, 0);
71cdf0e10cSrcweir     return pNext == this ? 0 : pNext;
72cdf0e10cSrcweir }
73cdf0e10cSrcweir 
74cdf0e10cSrcweir //--------------------------------------------------------------------
75cdf0e10cSrcweir 
76cdf0e10cSrcweir // returns sal_True if this binding is really bound to a function
77cdf0e10cSrcweir 
IsBound() const78cdf0e10cSrcweir sal_Bool SfxControllerItem::IsBound() const
79cdf0e10cSrcweir {
80cdf0e10cSrcweir     DBG_MEMTEST();
81cdf0e10cSrcweir     DBG_CHKTHIS(SfxControllerItem, 0);
82cdf0e10cSrcweir     return pNext != this;
83cdf0e10cSrcweir }
84cdf0e10cSrcweir 
85cdf0e10cSrcweir //--------------------------------------------------------------------
86cdf0e10cSrcweir 
87cdf0e10cSrcweir // returns the associated function-id or 0 if none
88cdf0e10cSrcweir 
89cdf0e10cSrcweir // sal_uInt16 SfxControllerItem::GetId() const;
90cdf0e10cSrcweir 
91cdf0e10cSrcweir //====================================================================
92cdf0e10cSrcweir 
93cdf0e10cSrcweir // registeres with the id at the bindings
94cdf0e10cSrcweir 
Bind(sal_uInt16 nNewId,SfxBindings * pBindinx)95cdf0e10cSrcweir void SfxControllerItem::Bind( sal_uInt16 nNewId, SfxBindings *pBindinx )
96cdf0e10cSrcweir {
97cdf0e10cSrcweir     DBG_MEMTEST();
98cdf0e10cSrcweir     DBG_CHKTHIS(SfxControllerItem, 0);
99cdf0e10cSrcweir     DBG_ASSERT(pBindings || pBindinx, "Keine Bindings");
100cdf0e10cSrcweir 
101cdf0e10cSrcweir     if ( IsBound() ) {
102cdf0e10cSrcweir         DBG_ASSERT(pBindings, "Keine Bindings");
103cdf0e10cSrcweir         pBindings->Release(*this);
104cdf0e10cSrcweir     }
105cdf0e10cSrcweir 
106cdf0e10cSrcweir     nId = nNewId;
107cdf0e10cSrcweir     pNext = 0;
108cdf0e10cSrcweir 
109cdf0e10cSrcweir     if (pBindinx)
110cdf0e10cSrcweir         pBindings = pBindinx;
111cdf0e10cSrcweir     pBindings->Register(*this);
112cdf0e10cSrcweir }
113cdf0e10cSrcweir 
BindInternal_Impl(sal_uInt16 nNewId,SfxBindings * pBindinx)114cdf0e10cSrcweir void SfxControllerItem::BindInternal_Impl( sal_uInt16 nNewId, SfxBindings *pBindinx )
115cdf0e10cSrcweir {
116cdf0e10cSrcweir     DBG_MEMTEST();
117cdf0e10cSrcweir     DBG_CHKTHIS(SfxControllerItem, 0);
118cdf0e10cSrcweir     DBG_ASSERT(pBindings || pBindinx, "Keine Bindings");
119cdf0e10cSrcweir 
120cdf0e10cSrcweir     if ( IsBound() ) {
121cdf0e10cSrcweir         DBG_ASSERT(pBindings, "Keine Bindings");
122cdf0e10cSrcweir         pBindings->Release(*this);
123cdf0e10cSrcweir     }
124cdf0e10cSrcweir 
125cdf0e10cSrcweir     nId = nNewId;
126cdf0e10cSrcweir     pNext = 0;
127cdf0e10cSrcweir 
128cdf0e10cSrcweir     if (pBindinx)
129cdf0e10cSrcweir         pBindings = pBindinx;
130cdf0e10cSrcweir     pBindings->RegisterInternal_Impl(*this);
131cdf0e10cSrcweir }
132cdf0e10cSrcweir 
133cdf0e10cSrcweir 
134cdf0e10cSrcweir //====================================================================
135cdf0e10cSrcweir 
UnBind()136cdf0e10cSrcweir void SfxControllerItem::UnBind()
137cdf0e10cSrcweir 
138cdf0e10cSrcweir /*  [Beschreibung]
139cdf0e10cSrcweir 
140cdf0e10cSrcweir     "ost die Verbindung dieses SfxControllerItems mit der SfxBindings-Instanz,
141cdf0e10cSrcweir     an der es zur Zeit gebunden ist. Ab diesem Zeitpunkt erh"alt es keine
142cdf0e10cSrcweir     Statusbenachrichtigungen (<SfxControllerItem::StateChented()>) mehr.
143cdf0e10cSrcweir 
144cdf0e10cSrcweir 
145cdf0e10cSrcweir     [Querverweise]
146cdf0e10cSrcweir 
147cdf0e10cSrcweir     <SfxControllerItem::ReBind()>
148cdf0e10cSrcweir     <SfxControllerItem::ClearCache()>
149cdf0e10cSrcweir */
150cdf0e10cSrcweir {
151cdf0e10cSrcweir     DBG_MEMTEST();
152cdf0e10cSrcweir     DBG_CHKTHIS(SfxControllerItem, 0);
153cdf0e10cSrcweir     DBG_ASSERT(pBindings, "Keine Bindings");
154cdf0e10cSrcweir     DBG_ASSERT( IsBound(), "unbindings unbound SfxControllerItem" );
155cdf0e10cSrcweir 
156cdf0e10cSrcweir     pBindings->Release(*this);
157cdf0e10cSrcweir     pNext = this;
158cdf0e10cSrcweir }
159cdf0e10cSrcweir 
160cdf0e10cSrcweir //====================================================================
161cdf0e10cSrcweir 
ReBind()162cdf0e10cSrcweir void SfxControllerItem::ReBind()
163cdf0e10cSrcweir 
164cdf0e10cSrcweir /*  [Beschreibung]
165cdf0e10cSrcweir 
166cdf0e10cSrcweir     Binded dieses SfxControllerItem wieder an die SfxBindings-Instanz,
167cdf0e10cSrcweir     an der es zuletzt gebunden war. Ab diesem Zeitpunkt erh"alt es wieder
168cdf0e10cSrcweir     Statusbenachrichtigungen (<SfxControllerItem::StateChented()>).
169cdf0e10cSrcweir 
170cdf0e10cSrcweir 
171cdf0e10cSrcweir     [Querverweise]
172cdf0e10cSrcweir 
173cdf0e10cSrcweir     <SfxControllerItem::UnBind()>
174cdf0e10cSrcweir     <SfxControllerItem::ClearCache()>
175cdf0e10cSrcweir */
176cdf0e10cSrcweir 
177cdf0e10cSrcweir {
178cdf0e10cSrcweir     DBG_MEMTEST();
179cdf0e10cSrcweir DBG_CHKTHIS(SfxControllerItem, 0);
180cdf0e10cSrcweir     DBG_ASSERT(pBindings, "Keine Bindings");
181cdf0e10cSrcweir     DBG_ASSERT( !IsBound(), "bindings rebound SfxControllerItem" );
182cdf0e10cSrcweir 
183cdf0e10cSrcweir     pBindings->Register(*this);
184cdf0e10cSrcweir }
185cdf0e10cSrcweir 
186cdf0e10cSrcweir //====================================================================
187cdf0e10cSrcweir 
UpdateSlot()188cdf0e10cSrcweir void SfxControllerItem::UpdateSlot()
189cdf0e10cSrcweir 
190cdf0e10cSrcweir /*  [Beschreibung]
191cdf0e10cSrcweir 
192cdf0e10cSrcweir     Holt den Status 'hart' neu.
193cdf0e10cSrcweir 
194cdf0e10cSrcweir     [Querverweise]
195cdf0e10cSrcweir 
196cdf0e10cSrcweir     <SfxControllerItem::ClearCache()>
197cdf0e10cSrcweir */
198cdf0e10cSrcweir 
199cdf0e10cSrcweir {
200cdf0e10cSrcweir     DBG_MEMTEST();
201cdf0e10cSrcweir     DBG_CHKTHIS(SfxControllerItem, 0);
202cdf0e10cSrcweir     DBG_ASSERT(pBindings, "Keine Bindings");
203cdf0e10cSrcweir 
204cdf0e10cSrcweir     pBindings->Update( GetId() );
205cdf0e10cSrcweir }
206cdf0e10cSrcweir 
207cdf0e10cSrcweir //--------------------------------------------------------------------
208cdf0e10cSrcweir 
ClearCache()209cdf0e10cSrcweir void SfxControllerItem::ClearCache()
210cdf0e10cSrcweir 
211cdf0e10cSrcweir /*  [Beschreibung]
212cdf0e10cSrcweir 
213cdf0e10cSrcweir     "oscht den Status-Cache f"ur dieses SfxControllerItem. D.h. beim
214cdf0e10cSrcweir     n"achsten Status-Update wird das <SfxPoolItem> auf jeden Fall geschickt,
215cdf0e10cSrcweir     auch wenn zuvor dasselbe geschickt wurde. Dies wird ben"otigt, wenn
216cdf0e10cSrcweir     ein Controller umgeschaltet werden kann und sich diesen Status
217cdf0e10cSrcweir     selbst merkt.
218cdf0e10cSrcweir 
219cdf0e10cSrcweir 
220cdf0e10cSrcweir     [Beispiel]
221cdf0e10cSrcweir 
222cdf0e10cSrcweir     Der Kombi-Controller f"ur das Einstellen des Fl"achentyps und der
223cdf0e10cSrcweir     konkreten Auspr"agung (Farbe blau oder Schraffur X) kann im Typ
224cdf0e10cSrcweir     umgestellt werden, wird jedoch dann bei der n"achsten Selektion
225cdf0e10cSrcweir     wieder benachrichtigt, auch wenn es dieselben Daten sind.
226cdf0e10cSrcweir 
227cdf0e10cSrcweir 
228cdf0e10cSrcweir     [Querverweise]
229cdf0e10cSrcweir 
230cdf0e10cSrcweir     <SfxControllerItem::UnBind()>
231cdf0e10cSrcweir     <SfxControllerItem::ReBind()>
232cdf0e10cSrcweir */
233cdf0e10cSrcweir 
234cdf0e10cSrcweir 
235cdf0e10cSrcweir {
236cdf0e10cSrcweir     DBG_MEMTEST();
237cdf0e10cSrcweir     DBG_CHKTHIS(SfxControllerItem, 0);
238cdf0e10cSrcweir     DBG_ASSERT(pBindings, "Keine Bindings");
239cdf0e10cSrcweir 
240cdf0e10cSrcweir     pBindings->ClearCache_Impl( GetId() );
241cdf0e10cSrcweir }
242cdf0e10cSrcweir 
243cdf0e10cSrcweir //--------------------------------------------------------------------
244cdf0e10cSrcweir 
245cdf0e10cSrcweir // replaces the successor in the list of bindings of the same id
246cdf0e10cSrcweir 
ChangeItemLink(SfxControllerItem * pNewLink)247cdf0e10cSrcweir SfxControllerItem* SfxControllerItem::ChangeItemLink( SfxControllerItem* pNewLink )
248cdf0e10cSrcweir {
249cdf0e10cSrcweir     DBG_MEMTEST();
250cdf0e10cSrcweir     DBG_CHKTHIS(SfxControllerItem, 0);
251cdf0e10cSrcweir     SfxControllerItem* pOldLink = pNext;
252cdf0e10cSrcweir     pNext = pNewLink;
253cdf0e10cSrcweir     return pOldLink == this ? 0 : pOldLink;
254cdf0e10cSrcweir }
255cdf0e10cSrcweir 
256cdf0e10cSrcweir //--------------------------------------------------------------------
257cdf0e10cSrcweir 
258cdf0e10cSrcweir // changes the id of unbound functions (e.g. for sub-menu-ids)
259cdf0e10cSrcweir 
SetId(sal_uInt16 nItemId)260cdf0e10cSrcweir void SfxControllerItem::SetId( sal_uInt16 nItemId )
261cdf0e10cSrcweir {
262cdf0e10cSrcweir     DBG_MEMTEST();
263cdf0e10cSrcweir     DBG_CHKTHIS(SfxControllerItem, 0);
264cdf0e10cSrcweir     DBG_ASSERT( !IsBound(), "changing id of bound binding" );
265cdf0e10cSrcweir     nId = nItemId;
266cdf0e10cSrcweir }
267cdf0e10cSrcweir 
268cdf0e10cSrcweir //--------------------------------------------------------------------
269cdf0e10cSrcweir 
270cdf0e10cSrcweir // creates a atomic item for a controller  without registration
271cdf0e10cSrcweir 
SfxControllerItem()272cdf0e10cSrcweir SfxControllerItem::SfxControllerItem():
273cdf0e10cSrcweir     nId(0),
274cdf0e10cSrcweir     pNext(this),
275cdf0e10cSrcweir     pBindings(0)
276cdf0e10cSrcweir {
277cdf0e10cSrcweir     DBG_MEMTEST();
278cdf0e10cSrcweir     DBG_CTOR(SfxControllerItem, 0);
279cdf0e10cSrcweir }
280cdf0e10cSrcweir 
281cdf0e10cSrcweir //--------------------------------------------------------------------
282cdf0e10cSrcweir 
283cdf0e10cSrcweir // creates a representation of the function nId and registeres it
284cdf0e10cSrcweir 
SfxControllerItem(sal_uInt16 nID,SfxBindings & rBindings)285cdf0e10cSrcweir SfxControllerItem::SfxControllerItem( sal_uInt16 nID, SfxBindings &rBindings ):
286cdf0e10cSrcweir     nId(nID),
287cdf0e10cSrcweir     pNext(this),
288cdf0e10cSrcweir     pBindings(&rBindings)
289cdf0e10cSrcweir {
290cdf0e10cSrcweir     DBG_MEMTEST();
291cdf0e10cSrcweir     DBG_CTOR(SfxControllerItem, 0);
292cdf0e10cSrcweir     Bind(nId, &rBindings);
293cdf0e10cSrcweir }
294cdf0e10cSrcweir 
295cdf0e10cSrcweir //--------------------------------------------------------------------
296cdf0e10cSrcweir 
297cdf0e10cSrcweir // unregisteres the item in the bindings
298cdf0e10cSrcweir 
~SfxControllerItem()299cdf0e10cSrcweir SfxControllerItem::~SfxControllerItem()
300cdf0e10cSrcweir {
301cdf0e10cSrcweir     DBG_MEMTEST();
302cdf0e10cSrcweir     if ( IsBound() )
303cdf0e10cSrcweir         pBindings->Release(*this);
304cdf0e10cSrcweir     DBG_DTOR(SfxControllerItem, 0);
305cdf0e10cSrcweir }
306cdf0e10cSrcweir 
307cdf0e10cSrcweir //--------------------------------------------------------------------
308cdf0e10cSrcweir 
StateChanged(sal_uInt16,SfxItemState,const SfxPoolItem *)309cdf0e10cSrcweir void SfxControllerItem::StateChanged
310cdf0e10cSrcweir (
311cdf0e10cSrcweir     sal_uInt16              ,   // <SID> des ausl"osenden Slot
312cdf0e10cSrcweir     SfxItemState        ,   // <SfxItemState> von 'pState'
313cdf0e10cSrcweir     const SfxPoolItem*      // Slot-Status, ggf. 0 oder IsInvalidItem()
314cdf0e10cSrcweir )
315cdf0e10cSrcweir 
316cdf0e10cSrcweir /*  [Beschreibung]
317cdf0e10cSrcweir 
318cdf0e10cSrcweir     Diese virtuelle Methode wird vom SFx gerufen, um <SfxControllerItem>s
319cdf0e10cSrcweir     dar"uber zu benachrichtigen, da\s sich der Status des Slots 'nSID'
320cdf0e10cSrcweir     ge"andert hat. Der neue Wert sowie der von diesem Wert ermittelte
321cdf0e10cSrcweir     Status wird als 'pState' bzw. 'eState' mitgegeben.
322cdf0e10cSrcweir 
323cdf0e10cSrcweir     Der Status eines Slots kann sich "andern, wenn z.B. das MDI-Fenster
324cdf0e10cSrcweir     gewechselt wird oder der Slot explizit mit <SfxBindings::Invalidate()>
325cdf0e10cSrcweir     invalidiert wurde.
326cdf0e10cSrcweir 
327cdf0e10cSrcweir     Achtung! Die Methode wird nicht gerufen, wenn der Slot ung"ultig wurde,
328cdf0e10cSrcweir     danach jedoch wieder denselben Wert angenommen hat.
329cdf0e10cSrcweir 
330cdf0e10cSrcweir     Diese Basisklasse braucht nicht gerufen zu werden, weitere Zwischenstufen
331cdf0e10cSrcweir     jedoch (z.B. <SfxToolboxControl>) sollten gerufen werden.
332cdf0e10cSrcweir */
333cdf0e10cSrcweir 
334cdf0e10cSrcweir {
335cdf0e10cSrcweir     DBG_MEMTEST();
336cdf0e10cSrcweir     DBG_CHKTHIS(SfxControllerItem, 0);
337cdf0e10cSrcweir }
338cdf0e10cSrcweir 
339cdf0e10cSrcweir //--------------------------------------------------------------------
340cdf0e10cSrcweir 
DeleteFloatingWindow()341cdf0e10cSrcweir void SfxControllerItem::DeleteFloatingWindow()
342cdf0e10cSrcweir {
343cdf0e10cSrcweir     DBG_MEMTEST();
344cdf0e10cSrcweir     DBG_CHKTHIS(SfxControllerItem, 0);
345cdf0e10cSrcweir }
346cdf0e10cSrcweir 
347cdf0e10cSrcweir //--------------------------------------------------------------------
348cdf0e10cSrcweir 
StateChanged(sal_uInt16 nSID,SfxItemState eState,const SfxPoolItem * pState)349cdf0e10cSrcweir void SfxStatusForwarder::StateChanged
350cdf0e10cSrcweir (
351cdf0e10cSrcweir     sal_uInt16              nSID,       // <SID> des ausl"osenden Slot
352cdf0e10cSrcweir     SfxItemState        eState,     // <SfxItemState> von 'pState'
353cdf0e10cSrcweir     const SfxPoolItem*  pState      // Slot-Status, ggf. 0 oder IsInvalidItem()
354cdf0e10cSrcweir )
355cdf0e10cSrcweir 
356cdf0e10cSrcweir {
357cdf0e10cSrcweir     pMaster->StateChanged( nSID, eState, pState );
358cdf0e10cSrcweir }
359cdf0e10cSrcweir 
360cdf0e10cSrcweir //--------------------------------------------------------------------
361cdf0e10cSrcweir 
SfxStatusForwarder(sal_uInt16 nSlotId,SfxControllerItem & rMaster)362cdf0e10cSrcweir SfxStatusForwarder::SfxStatusForwarder(
363cdf0e10cSrcweir             sal_uInt16              nSlotId,
364cdf0e10cSrcweir             SfxControllerItem&  rMaster ):
365cdf0e10cSrcweir     SfxControllerItem( nSlotId, rMaster.GetBindings() ),
366cdf0e10cSrcweir     pMaster( &rMaster )
367cdf0e10cSrcweir {
368cdf0e10cSrcweir }
369cdf0e10cSrcweir 
370cdf0e10cSrcweir //--------------------------------------------------------------------
371cdf0e10cSrcweir 
GetItemState(const SfxPoolItem * pState)372cdf0e10cSrcweir SfxItemState SfxControllerItem::GetItemState
373cdf0e10cSrcweir (
374cdf0e10cSrcweir     const SfxPoolItem* pState   /*  Pointer auf das <SfxPoolItem>, dessen
375cdf0e10cSrcweir                                     Status erfragt werden soll. */
376cdf0e10cSrcweir )
377cdf0e10cSrcweir 
378cdf0e10cSrcweir /*  [Beschreibung]
379cdf0e10cSrcweir 
380cdf0e10cSrcweir     Statische Methode zum Ermitteln des Status des SfxPoolItem-Pointers,
381cdf0e10cSrcweir     in der Methode <SfxControllerItem::StateChanged(const SfxPoolItem*)>
382cdf0e10cSrcweir     zu verwenden.
383cdf0e10cSrcweir 
384cdf0e10cSrcweir     [R"uckgabewert]
385cdf0e10cSrcweir 
386cdf0e10cSrcweir     SfxItemState        SFX_ITEM_UNKNOWN
387cdf0e10cSrcweir                         Enabled, aber keine weitere Statusinformation
388cdf0e10cSrcweir                         verf"ugbar. Typisch f"ur <Slot>s, die allenfalls
389cdf0e10cSrcweir                         zeitweise disabled sind, aber ihre Darstellung sonst
390cdf0e10cSrcweir                         nicht "andern.
391cdf0e10cSrcweir 
392cdf0e10cSrcweir                         SFX_ITEM_DISABLED
393cdf0e10cSrcweir                         Disabled und keine weiter Statusinformation
394cdf0e10cSrcweir                         verf"ugbar. Alle anderen ggf. angezeigten Werte sollten
395cdf0e10cSrcweir                         auf den Default zur"uckgesetzt werden.
396cdf0e10cSrcweir 
397cdf0e10cSrcweir                         SFX_ITEM_DONTCARE
398cdf0e10cSrcweir                         Enabled aber es waren nur uneindeutige Werte
399cdf0e10cSrcweir                         verf"ugbar (also keine, die abgefragt werden k"onnen).
400cdf0e10cSrcweir 
401cdf0e10cSrcweir                         SFX_ITEM_AVAILABLE
402cdf0e10cSrcweir                         Enabled und mit verf"ugbarem Wert, der von 'pState'
403cdf0e10cSrcweir                         erfragbar ist. Der Typ ist dabei im gesamten
404cdf0e10cSrcweir                         Programm eindeutig und durch den Slot festgelegt.
405cdf0e10cSrcweir */
406cdf0e10cSrcweir 
407cdf0e10cSrcweir {
408cdf0e10cSrcweir     return !pState
409cdf0e10cSrcweir                 ? SFX_ITEM_DISABLED
410cdf0e10cSrcweir                 : IsInvalidItem(pState)
411cdf0e10cSrcweir                     ? SFX_ITEM_DONTCARE
412cdf0e10cSrcweir                     : pState->ISA(SfxVoidItem) && !pState->Which()
413cdf0e10cSrcweir                         ? SFX_ITEM_UNKNOWN
414cdf0e10cSrcweir                         : SFX_ITEM_AVAILABLE;
415cdf0e10cSrcweir }
416cdf0e10cSrcweir 
417cdf0e10cSrcweir //--------------------------------------------------------------------
418cdf0e10cSrcweir 
GetCoreMetric() const419cdf0e10cSrcweir SfxMapUnit SfxControllerItem::GetCoreMetric() const
420cdf0e10cSrcweir 
421cdf0e10cSrcweir /*  [Beschreibung]
422cdf0e10cSrcweir 
423cdf0e10cSrcweir     Holt vom zust"andigen Pool die Ma\seinheit ab, in der das Status-Item
424cdf0e10cSrcweir     vorliegt.
425cdf0e10cSrcweir */
426cdf0e10cSrcweir 
427cdf0e10cSrcweir {
428cdf0e10cSrcweir     SfxStateCache *pCache = pBindings->GetStateCache( nId );
429cdf0e10cSrcweir     SfxDispatcher *pDispat = pBindings->GetDispatcher_Impl();
430cdf0e10cSrcweir 
431cdf0e10cSrcweir     if ( !pDispat )
432cdf0e10cSrcweir     {
433cdf0e10cSrcweir         SfxViewFrame* pViewFrame = SfxViewFrame::Current();
434cdf0e10cSrcweir         if ( !pViewFrame )
435cdf0e10cSrcweir             SfxViewFrame::GetFirst();
436cdf0e10cSrcweir         if ( pViewFrame )
437cdf0e10cSrcweir             pDispat = pViewFrame->GetDispatcher();
438cdf0e10cSrcweir     }
439cdf0e10cSrcweir 
440cdf0e10cSrcweir     if ( pDispat && pCache )
441cdf0e10cSrcweir     {
442cdf0e10cSrcweir         const SfxSlotServer *pServer = pCache->GetSlotServer( *pDispat );
443cdf0e10cSrcweir         if ( pServer )
444cdf0e10cSrcweir         {
445cdf0e10cSrcweir             SfxShell *pSh = pDispat->GetShell( pServer->GetShellLevel() );
446cdf0e10cSrcweir             SfxItemPool &rPool = pSh->GetPool();
447cdf0e10cSrcweir             sal_uInt16 nWhich = rPool.GetWhich( nId );
448*6837c635SOliver-Rainer Wittmann 
449*6837c635SOliver-Rainer Wittmann             // invalidate slot and its message|slot server as 'global' information
450*6837c635SOliver-Rainer Wittmann             // about the validated message|slot server is not made available
451*6837c635SOliver-Rainer Wittmann             pCache->Invalidate( sal_True );
452*6837c635SOliver-Rainer Wittmann 
453cdf0e10cSrcweir             return rPool.GetMetric( nWhich );
454cdf0e10cSrcweir         }
455cdf0e10cSrcweir     }
456cdf0e10cSrcweir 
457cdf0e10cSrcweir     DBG_WARNING( "W1: Can not find ItemPool!" );
458cdf0e10cSrcweir     return SFX_MAPUNIT_100TH_MM;
459cdf0e10cSrcweir }
460cdf0e10cSrcweir 
461cdf0e10cSrcweir //------------------------------------------------------------------------
462cdf0e10cSrcweir 
463cdf0e10cSrcweir #ifdef _MSC_VER
464cdf0e10cSrcweir #pragma optimize("g",off)
465cdf0e10cSrcweir #endif
466