xref: /trunk/main/sfx2/source/statbar/stbitem.cxx (revision 1ecadb572e7010ff3b3382ad9bf179dbc6efadbb)
1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 // MARKER(update_precomp.py): autogen include statement, do not remove
29 #include "precompiled_sfx2.hxx"
30 #include <svl/stritem.hxx>
31 #ifndef GCC
32 #endif
33 #include <com/sun/star/util/URL.hpp>
34 #include <com/sun/star/util/XURLTransformer.hpp>
35 #include <com/sun/star/frame/XController.hpp>
36 #include <com/sun/star/lang/XUnoTunnel.hpp>
37 #include <com/sun/star/frame/status/ItemStatus.hpp>
38 #include <com/sun/star/frame/status/ItemState.hpp>
39 #include <com/sun/star/awt/MouseButton.hpp>
40 
41 #include <vcl/status.hxx>
42 
43 #include <sfx2/app.hxx>
44 #include "sfx2/stbitem.hxx"
45 #include "sfxtypes.hxx"
46 #include <sfx2/msg.hxx>
47 #include "arrdecl.hxx"
48 #include <sfx2/bindings.hxx>
49 #include <sfx2/msgpool.hxx>
50 #include <sfx2/module.hxx>
51 #include <sfx2/dispatch.hxx>
52 #include <sfx2/unoctitm.hxx>
53 #include <sfx2/objsh.hxx>
54 #include <sfx2/sfx.hrc>
55 
56 #include <comphelper/processfactory.hxx>
57 #include <svl/eitem.hxx>
58 #include <svl/stritem.hxx>
59 #include <svl/intitem.hxx>
60 #ifndef _TOOLKIT_HELPER_VCLUNOHELPER_HXX_
61 #include <toolkit/unohlp.hxx>
62 #endif
63 #include <toolkit/helper/convert.hxx>
64 
65 using namespace ::com::sun::star;
66 
67 //--------------------------------------------------------------------
68 
69 sal_uInt16 SfxStatusBarControl::convertAwtToVCLMouseButtons( sal_Int16 nAwtMouseButtons )
70 {
71     sal_uInt16 nVCLMouseButtons( 0 );
72 
73     if ( nAwtMouseButtons & awt::MouseButton::LEFT )
74         nVCLMouseButtons |= MOUSE_LEFT;
75     if ( nAwtMouseButtons & awt::MouseButton::RIGHT )
76         nVCLMouseButtons |= MOUSE_RIGHT;
77     if ( nAwtMouseButtons & awt::MouseButton::MIDDLE )
78         nVCLMouseButtons |= MOUSE_MIDDLE;
79 
80     return nVCLMouseButtons;
81 }
82 
83 //--------------------------------------------------------------------
84 
85 svt::StatusbarController* SAL_CALL SfxStatusBarControllerFactory(
86     const uno::Reference< frame::XFrame >& rFrame,
87     StatusBar* pStatusBar,
88     unsigned short nID,
89     const ::rtl::OUString& aCommandURL )
90 {
91     ::vos::OGuard aGuard( Application::GetSolarMutex() );
92 
93     util::URL aTargetURL;
94     aTargetURL.Complete = aCommandURL;
95     uno::Reference < util::XURLTransformer > xTrans( ::comphelper::getProcessServiceFactory()->createInstance(
96         rtl::OUString::createFromAscii( "com.sun.star.util.URLTransformer" )), uno::UNO_QUERY );
97     xTrans->parseStrict( aTargetURL );
98 
99     SfxObjectShell* pObjShell = NULL;
100     uno::Reference < frame::XController > xController;
101     uno::Reference < frame::XModel > xModel;
102     if ( rFrame.is() )
103     {
104         xController = rFrame->getController();
105         if ( xController.is() )
106             xModel = xController->getModel();
107     }
108 
109     if ( xModel.is() )
110     {
111         // Get tunnel from model to retrieve the SfxObjectShell pointer from it
112         ::com::sun::star::uno::Reference < ::com::sun::star::lang::XUnoTunnel > xObj( xModel, uno::UNO_QUERY );
113         ::com::sun::star::uno::Sequence < sal_Int8 > aSeq = SvGlobalName( SFX_GLOBAL_CLASSID ).GetByteSequence();
114         if ( xObj.is() )
115         {
116             sal_Int64 nHandle = xObj->getSomething( aSeq );
117             if ( nHandle )
118                         pObjShell = reinterpret_cast< SfxObjectShell* >( sal::static_int_cast< sal_IntPtr >( nHandle ));
119         }
120     }
121 
122     SfxModule*     pModule   = pObjShell ? pObjShell->GetModule() : NULL;
123     SfxSlotPool*   pSlotPool = 0;
124 
125     if ( pModule )
126         pSlotPool = pModule->GetSlotPool();
127     else
128         pSlotPool = &(SfxSlotPool::GetSlotPool( NULL ));
129 
130     const SfxSlot* pSlot = pSlotPool->GetUnoSlot( aTargetURL.Path );
131     if ( pSlot )
132     {
133         sal_uInt16 nSlotId = pSlot->GetSlotId();
134         if ( nSlotId > 0 )
135         {
136             rtl::OString aCmd(".uno:");
137             aCmd += pSlot->GetUnoName();
138             pStatusBar->SetHelpId( nSlotId, aCmd );
139             return SfxStatusBarControl::CreateControl( nSlotId, nID, pStatusBar, pModule );
140         }
141     }
142 
143     return NULL;
144 }
145 
146 //--------------------------------------------------------------------
147 
148 SfxStatusBarControl::SfxStatusBarControl
149 (
150     sal_uInt16      nSlotID,            /* Slot-Id, mit der diese Instanz
151                                        verbunden wird. Wurde bei der
152                                        Registrierung eine Slot-Id != 0
153                                        angegeben, ist dies immer die dort
154                                        angegebene. */
155     sal_uInt16      nCtrlID,            /* ID of this controller in the status bar */
156 
157     StatusBar&  rBar                /* Referenz auf die StatusBar, f"ur die
158                                        dieses Control erzeugt wurde. */
159 )
160 
161 /*  [Beschreibung]
162 
163     Konstruktor der Klasse SfxStatusBarControl. Die Subclasses werden
164     bei Bedarf per Factory vom SFx erzeugt.
165 
166     Instanzen dieser Basisklasse werden f"ur alle StatusBar-Felder
167     erzeugt, f"ur die keine speziellen registriert wurden.
168 */
169 
170 :   svt::StatusbarController(),
171     nSlotId( nSlotID ),
172     nId( nCtrlID ),
173     pBar( &rBar )
174 {
175 }
176 
177 //--------------------------------------------------------------------
178 
179 SfxStatusBarControl::~SfxStatusBarControl()
180 
181 /*  [Beschreibung]
182 
183     Destruktor der Klasse SfxStatusBarControl. Die Instanzen dieser
184     Klasse und deren Subklassen werden vom SFx zerst"ort.
185 */
186 
187 {}
188 
189 //--------------------------------------------------------------------
190 // XInterface
191 uno::Any SAL_CALL SfxStatusBarControl::queryInterface( const uno::Type & rType )
192 throw( uno::RuntimeException)
193 {
194     return svt::StatusbarController::queryInterface( rType );
195 }
196 
197 void SAL_CALL SfxStatusBarControl::acquire() throw()
198 {
199     OWeakObject::acquire();
200 }
201 
202 void SAL_CALL SfxStatusBarControl::release() throw()
203 {
204     OWeakObject::release();
205 }
206 
207 //--------------------------------------------------------------------
208 // XEventListener
209 void SAL_CALL SfxStatusBarControl::disposing( const lang::EventObject& aEvent )
210 throw( uno::RuntimeException )
211 {
212     svt::StatusbarController::disposing( aEvent );
213 }
214 
215 //--------------------------------------------------------------------
216 // XComponent
217 void SAL_CALL SfxStatusBarControl::dispose()
218 throw (uno::RuntimeException)
219 {
220     svt::StatusbarController::dispose();
221 }
222 
223 //--------------------------------------------------------------------
224 // XStatusListener
225 void SAL_CALL SfxStatusBarControl::statusChanged( const frame::FeatureStateEvent& rEvent )
226 throw ( ::com::sun::star::uno::RuntimeException )
227 {
228     SfxViewFrame* pViewFrame = NULL;
229     uno::Reference < frame::XController > xController;
230 
231     ::vos::OGuard aGuard( Application::GetSolarMutex() );
232     if ( m_xFrame.is() )
233         xController = m_xFrame->getController();
234 
235     uno::Reference < frame::XDispatchProvider > xProvider( xController, uno::UNO_QUERY );
236     if ( xProvider.is() )
237     {
238         uno::Reference < frame::XDispatch > xDisp = xProvider->queryDispatch( rEvent.FeatureURL, ::rtl::OUString(), 0 );
239         if ( xDisp.is() )
240         {
241             uno::Reference< lang::XUnoTunnel > xTunnel( xDisp, uno::UNO_QUERY );
242             SfxOfficeDispatch* pDisp = NULL;
243             if ( xTunnel.is() )
244             {
245                 sal_Int64 nImplementation = xTunnel->getSomething(SfxOfficeDispatch::impl_getStaticIdentifier());
246                 pDisp = reinterpret_cast< SfxOfficeDispatch* >(sal::static_int_cast< sal_IntPtr >( nImplementation ));
247             }
248 
249             if ( pDisp )
250                 pViewFrame = pDisp->GetDispatcher_Impl()->GetFrame();
251         }
252     }
253 
254     sal_uInt16 nSlotID = 0;
255     SfxSlotPool& rPool = SfxSlotPool::GetSlotPool( pViewFrame );
256     const SfxSlot* pSlot = rPool.GetUnoSlot( rEvent.FeatureURL.Path );
257     if ( pSlot )
258         nSlotID = pSlot->GetSlotId();
259 
260     if ( nSlotID > 0 )
261     {
262         if ( rEvent.Requery )
263             svt::StatusbarController::statusChanged( rEvent );
264         else
265         {
266             SfxItemState eState = SFX_ITEM_DISABLED;
267             SfxPoolItem* pItem = NULL;
268             if ( rEvent.IsEnabled )
269             {
270                 eState = SFX_ITEM_AVAILABLE;
271                 uno::Type pType = rEvent.State.getValueType();
272 
273                 if ( pType == ::getVoidCppuType() )
274                 {
275                     pItem = new SfxVoidItem( nSlotID );
276                     eState = SFX_ITEM_UNKNOWN;
277                 }
278                 else if ( pType == ::getBooleanCppuType() )
279                 {
280                     sal_Bool bTemp = 0;
281                     rEvent.State >>= bTemp ;
282                     pItem = new SfxBoolItem( nSlotID, bTemp );
283                 }
284                 else if ( pType == ::getCppuType((const sal_uInt16*)0) )
285                 {
286                     sal_uInt16 nTemp = 0;
287                     rEvent.State >>= nTemp ;
288                     pItem = new SfxUInt16Item( nSlotID, nTemp );
289                 }
290                 else if ( pType == ::getCppuType((const sal_uInt32*)0) )
291                 {
292                     sal_uInt32 nTemp = 0;
293                     rEvent.State >>= nTemp ;
294                     pItem = new SfxUInt32Item( nSlotID, nTemp );
295                 }
296                 else if ( pType == ::getCppuType((const ::rtl::OUString*)0) )
297                 {
298                     ::rtl::OUString sTemp ;
299                     rEvent.State >>= sTemp ;
300                     pItem = new SfxStringItem( nSlotID, sTemp );
301                 }
302                 else if ( pType == ::getCppuType((const ::com::sun::star::frame::status::ItemStatus*)0) )
303                 {
304                     frame::status::ItemStatus aItemStatus;
305                     rEvent.State >>= aItemStatus;
306                     eState = aItemStatus.State;
307                     pItem = new SfxVoidItem( nSlotID );
308                 }
309                 else
310                 {
311                     if ( pSlot )
312                         pItem = pSlot->GetType()->CreateItem();
313                     if ( pItem )
314                     {
315                         pItem->SetWhich( nSlotID );
316                         pItem->PutValue( rEvent.State );
317                     }
318                     else
319                         pItem = new SfxVoidItem( nSlotID );
320                 }
321             }
322 
323             StateChanged( nSlotID, eState, pItem );
324             delete pItem;
325         }
326     }
327 }
328 
329 //--------------------------------------------------------------------
330 // XStatusbarController
331 
332 ::sal_Bool SAL_CALL SfxStatusBarControl::mouseButtonDown(
333     const awt::MouseEvent& rMouseEvent )
334 throw ( uno::RuntimeException )
335 {
336     ::vos::OGuard aGuard( Application::GetSolarMutex() );
337     ::Point aPos( rMouseEvent.X, rMouseEvent.Y );
338 
339     ::MouseEvent aMouseEvent( aPos,
340                               (sal_uInt16)rMouseEvent.ClickCount,
341                               0,
342                               convertAwtToVCLMouseButtons( rMouseEvent.Buttons ),
343                               0 );
344 
345     return MouseButtonDown( aMouseEvent );
346 }
347 
348 //--------------------------------------------------------------------
349 
350 ::sal_Bool SAL_CALL SfxStatusBarControl::mouseMove(
351     const awt::MouseEvent& rMouseEvent )
352 throw (uno::RuntimeException)
353 {
354     ::vos::OGuard aGuard( Application::GetSolarMutex() );
355     ::Point aPos( rMouseEvent.X, rMouseEvent.Y );
356 
357     ::MouseEvent aMouseEvent( aPos,
358                               (sal_uInt16)rMouseEvent.ClickCount,
359                               0,
360                               convertAwtToVCLMouseButtons( rMouseEvent.Buttons ),
361                               0 );
362     return MouseMove( aMouseEvent );
363 }
364 
365 //--------------------------------------------------------------------
366 
367 ::sal_Bool SAL_CALL SfxStatusBarControl::mouseButtonUp(
368     const ::awt::MouseEvent& rMouseEvent )
369 throw ( uno::RuntimeException )
370 {
371     ::vos::OGuard aGuard( Application::GetSolarMutex() );
372     ::Point aPos( rMouseEvent.X, rMouseEvent.Y );
373 
374     ::MouseEvent aMouseEvent( aPos,
375                               (sal_uInt16)rMouseEvent.ClickCount,
376                               0,
377                               convertAwtToVCLMouseButtons( rMouseEvent.Buttons ),
378                               0 );
379     return MouseButtonUp( aMouseEvent );
380 }
381 
382 //--------------------------------------------------------------------
383 
384 void SAL_CALL SfxStatusBarControl::command(
385     const awt::Point& rPos,
386     ::sal_Int32 nCommand,
387     ::sal_Bool /*bMouseEvent*/,
388     const ::com::sun::star::uno::Any& /*aData*/ )
389 throw (::com::sun::star::uno::RuntimeException)
390 {
391     ::vos::OGuard aGuard( Application::GetSolarMutex() );
392     ::Point aPos( rPos.X, rPos.Y );
393     CommandEvent aCmdEvent( aPos, (sal_uInt16)nCommand, sal_True, NULL );
394 
395     Command( aCmdEvent );
396 }
397 
398 //--------------------------------------------------------------------
399 
400 void SAL_CALL SfxStatusBarControl::paint(
401     const uno::Reference< awt::XGraphics >& xGraphics,
402     const awt::Rectangle& rOutputRectangle,
403     ::sal_Int32 nItemId,
404     ::sal_Int32 nStyle )
405 throw ( ::uno::RuntimeException )
406 {
407     ::vos::OGuard aGuard( Application::GetSolarMutex() );
408 
409     OutputDevice* pOutDev = VCLUnoHelper::GetOutputDevice( xGraphics );;
410     if ( pOutDev )
411     {
412         ::Rectangle aRect = VCLRectangle( rOutputRectangle );
413         UserDrawEvent aUserDrawEvent( pOutDev, aRect, (sal_uInt16)nItemId, (sal_uInt16)nStyle );
414         Paint( aUserDrawEvent );
415     }
416 }
417 
418 //--------------------------------------------------------------------
419 
420 void SAL_CALL SfxStatusBarControl::click()
421 throw ( uno::RuntimeException )
422 {
423     ::vos::OGuard aGuard( Application::GetSolarMutex() );
424     Click();
425 }
426 
427 //--------------------------------------------------------------------
428 
429 void SAL_CALL SfxStatusBarControl::doubleClick()
430 throw ( uno::RuntimeException )
431 {
432     ::vos::OGuard aGuard( Application::GetSolarMutex() );
433     DoubleClick();
434 }
435 
436 //--------------------------------------------------------------------
437 // old sfx2 interface
438 //--------------------------------------------------------------------
439 
440 void SfxStatusBarControl::StateChanged
441 (
442     sal_uInt16              nSID,
443     SfxItemState        eState,
444     const SfxPoolItem*  pState  /* Zeiger auf ein SfxPoolItem, welches nur
445                                    innerhalb dieses Methodenaufrufs g"ultig
446                                    ist. Es kann ein 0-Pointer, ein Pointer
447                                    auf ein SfxVoidItem oder auf den Typ, f"ur
448                                    den die Subclass von SfxStatusBarControl
449                                    registriert ist vorkommen. */
450 )
451 
452 /*  [Beschreibung]
453 
454     Die Basisimplementation versteht Items vom Type SfxStringItem, bei
455     denen der Text in das Status-Zeilen-Feld eingetragen wird und
456     SfxVoidItem, bei denen das Feld geleert wird. Die Basisimplementierng
457     sollte in "uberladenen Methoden nicht gerufen werden.
458 */
459 
460 {
461     DBG_MEMTEST();
462     DBG_ASSERT( pBar != 0, "setting state to dangling StatusBar" );
463 
464     const SfxStringItem* pStr = PTR_CAST( SfxStringItem, pState );
465     if ( eState == SFX_ITEM_AVAILABLE && pStr )
466         pBar->SetItemText( nSID, pStr->GetValue() );
467     else
468     {
469         DBG_ASSERT( eState != SFX_ITEM_AVAILABLE || pState->ISA(SfxVoidItem),
470                     "wrong SfxPoolItem subclass in SfxStatusBarControl" );
471         pBar->SetItemText( nSID, String() );
472     }
473 }
474 
475 //--------------------------------------------------------------------
476 
477 sal_Bool SfxStatusBarControl::MouseButtonDown( const MouseEvent & )
478 
479 /*  [Beschreibung]
480 
481     Diese virtuelle Methode ist eine Weiterleitung des Events
482     MouseButtonDown() der StatusBar, falls die Maus-Position innerhalb
483     des Bereichs des betreffenden Items ist, oder die Maus von diesem
484     Control mit <SfxStatusBarControl::CaptureMouse()> gecaptured wurde.
485 
486     Die Defaultimplementierung ist leer und gibt FALSE zur"uck.
487 
488 
489     [Rueckgabewert]
490 
491     sal_Bool                TRUE
492                         das Event wurde bearbeitet und soll nicht an
493                         die StatusBar weitergeleitet werden
494 
495                         FALSE
496                         das Event wurde nicht bearbeitet und soll an
497                         die StatusBar weitergeleitet werden
498 */
499 
500 {
501     return sal_False;
502 }
503 
504 //--------------------------------------------------------------------
505 
506 sal_Bool SfxStatusBarControl::MouseMove( const MouseEvent & )
507 
508 /*  [Beschreibung]
509 
510     Diese virtuelle Methode ist eine Weiterleitung des Events
511     MouseMove() der StatusBar, falls die Maus-Position innerhalb
512     des Bereichs des betreffenden Items ist, oder die Maus von diesem
513     Control mit <SfxStatusBarControl::CaptureMouse()> gecaptured wurde.
514 
515     Die Defaultimplementierung ist leer und gibt FALSE zur"uck.
516 
517 
518     [Rueckgabewert]
519 
520     sal_Bool                TRUE
521                         das Event wurde bearbeitet und soll nicht an
522                         die StatusBar weitergeleitet werden
523 
524                         FALSE
525                         das Event wurde nicht bearbeitet und soll an
526                         die StatusBar weitergeleitet werden
527 */
528 
529 {
530     return sal_False;
531 }
532 
533 //--------------------------------------------------------------------
534 
535 sal_Bool SfxStatusBarControl::MouseButtonUp( const MouseEvent & )
536 
537 /*  [Beschreibung]
538 
539     Diese virtuelle Methode ist eine Weiterleitung des Events
540     MouseButtonUp() der StatusBar, falls die Maus-Position innerhalb
541     des Bereichs des betreffenden Items ist, oder die Maus von diesem
542     Control mit <SfxStatusBarControl::CaptureMouse()> gecaptured wurde.
543 
544     Die Defaultimplementierung ist leer und gibt FALSE zur"uck.
545 
546 
547     [Rueckgabewert]
548 
549     sal_Bool                TRUE
550                         das Event wurde bearbeitet und soll nicht an
551                         die StatusBar weitergeleitet werden
552 
553                         FALSE
554                         das Event wurde nicht bearbeitet und soll an
555                         die StatusBar weitergeleitet werden
556 */
557 
558 {
559     return sal_False;
560 }
561 
562 //--------------------------------------------------------------------
563 
564 void SfxStatusBarControl::Command( const CommandEvent& )
565 
566 /*  [Beschreibung]
567 
568     Diese virtuelle Methode wird gerufen, wenn f"ur dieses SfxStatusBarControl
569     ein CommandEvent f"ur erkannt wurde.
570 
571     Die Defaultimplementierung ist leer.
572 */
573 
574 {
575 }
576 
577 //--------------------------------------------------------------------
578 
579 void SfxStatusBarControl::Click()
580 
581 /*  [Beschreibung]
582 
583     Diese virtuelle Methode wird gerufen, wenn der Anwender mit der Maus
584     in das zu diesem Control geh"orige Feld der Statuszeile klickt.
585 
586     Die Defaultimplementierung ist leer.
587 */
588 
589 {
590 }
591 
592 //--------------------------------------------------------------------
593 
594 void SfxStatusBarControl::DoubleClick()
595 
596 /*  [Beschreibung]
597 
598     Diese virtuelle Methode wird gerufen, wenn der Anwender mit der Maus
599     in das zu diesem Control geh"orige Feld der Statuszeile doppel-klickt.
600 */
601 
602 {
603     ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > aArgs;
604     execute( aArgs );
605 }
606 
607 //--------------------------------------------------------------------
608 
609 void SfxStatusBarControl::Paint
610 (
611     const UserDrawEvent& /* Referenz auf einen UserDrawEvent */
612 )
613 
614 /*  [Beschreibung]
615 
616     Diese virtuelle Methode wird gerufen, falls das betreffende Feld
617     mit SIB_USERDRAW gekennzeichnet ist, um den Inhalt zu zeichnen.
618     Die Ausgabe mu"s auf dem in durch rUDEvt.GetDevice() erh"altlichen
619     OutputDevice innerhalb des durch rUDEvt.GetRect() angegebenenen
620     Rechtecks erfolgen.
621 
622     Die Defaultimplementierung ist leer.
623 */
624 
625 {
626 }
627 
628 //--------------------------------------------------------------------
629 
630 void SfxStatusBarControl::CaptureMouse()
631 {
632 }
633 
634 //--------------------------------------------------------------------
635 
636 void SfxStatusBarControl::ReleaseMouse()
637 {
638 }
639 
640 //--------------------------------------------------------------------
641 
642 SfxStatusBarControl* SfxStatusBarControl::CreateControl
643 (
644     sal_uInt16     nSlotID,
645     sal_uInt16     nStbId,
646     StatusBar* pBar,
647     SfxModule* pMod
648 )
649 {
650     ::vos::OGuard aGuard( Application::GetSolarMutex() );
651     SfxApplication *pApp = SFX_APP();
652 
653     SfxSlotPool *pSlotPool;
654     if ( pMod )
655         pSlotPool = pMod->GetSlotPool();
656     else
657         pSlotPool = &SfxSlotPool::GetSlotPool();
658 
659     TypeId aSlotType = pSlotPool->GetSlotType(nSlotID);
660     if ( aSlotType )
661     {
662         if ( pMod )
663         {
664             SfxStbCtrlFactArr_Impl *pFactories = pMod->GetStbCtrlFactories_Impl();
665             if ( pFactories )
666             {
667                 SfxStbCtrlFactArr_Impl &rFactories = *pFactories;
668                 for ( sal_uInt16 nFactory = 0; nFactory < rFactories.Count(); ++nFactory )
669                 if ( rFactories[nFactory]->nTypeId == aSlotType &&
670                      ( ( rFactories[nFactory]->nSlotId == 0 ) ||
671                      ( rFactories[nFactory]->nSlotId == nSlotID) ) )
672                     return rFactories[nFactory]->pCtor( nSlotID, nStbId, *pBar );
673             }
674         }
675 
676         SfxStbCtrlFactArr_Impl &rFactories = pApp->GetStbCtrlFactories_Impl();
677         for ( sal_uInt16 nFactory = 0; nFactory < rFactories.Count(); ++nFactory )
678         if ( rFactories[nFactory]->nTypeId == aSlotType &&
679              ( ( rFactories[nFactory]->nSlotId == 0 ) ||
680              ( rFactories[nFactory]->nSlotId == nSlotID) ) )
681             return rFactories[nFactory]->pCtor( nSlotID, nStbId, *pBar );
682     }
683 
684     return NULL;
685 }
686 
687 //--------------------------------------------------------------------
688 void SfxStatusBarControl::RegisterStatusBarControl(SfxModule* pMod, SfxStbCtrlFactory* pFact)
689 {
690     SFX_APP()->RegisterStatusBarControl_Impl( pMod, pFact );
691 }
692 //--------------------------------------------------------------------
693