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