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