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