summaryrefslogtreecommitdiff
path: root/sfx2/source/statbar
diff options
context:
space:
mode:
authorOliver Bolte <obo@openoffice.org>2004-09-09 15:56:47 +0000
committerOliver Bolte <obo@openoffice.org>2004-09-09 15:56:47 +0000
commit0fd0c66d1a61755bf6ba97c11bfff71e9ac48fe3 (patch)
treef0d41159a542086b0f43b12f509d5f6c6024016c /sfx2/source/statbar
parentabf5600a009124e839e1471384d4edeeee5ddd0e (diff)
INTEGRATION: CWS toolbars2 (1.2.594); FILE MERGED
2004/08/18 13:41:40 cd 1.2.594.3: #i32219# Adapt SfxStatusBarControl to implement new UNO API - works now as a wrapper 2004/08/11 10:41:00 cd 1.2.594.2: #i32219# Status bar is now controlled by framework based layout manager 2004/08/09 07:48:36 cd 1.2.594.1: #i32219# Adaption for framework based status bar
Diffstat (limited to 'sfx2/source/statbar')
-rw-r--r--sfx2/source/statbar/stbitem.cxx431
1 files changed, 407 insertions, 24 deletions
diff --git a/sfx2/source/statbar/stbitem.cxx b/sfx2/source/statbar/stbitem.cxx
index ced15bd12dc4..396e65b68eb9 100644
--- a/sfx2/source/statbar/stbitem.cxx
+++ b/sfx2/source/statbar/stbitem.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: stbitem.cxx,v $
*
- * $Revision: 1.3 $
+ * $Revision: 1.4 $
*
- * last change: $Author: rt $ $Date: 2004-09-08 15:45:14 $
+ * last change: $Author: obo $ $Date: 2004-09-09 16:56:47 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -66,6 +66,28 @@
#pragma hdrstop
#endif
+#ifndef _COM_SUN_STAR_UTIL_URL_HPP_
+#include <com/sun/star/util/URL.hpp>
+#endif
+#ifndef _COM_SUN_STAR_UTIL_XURLTRANSFORMER_HPP_
+#include <com/sun/star/util/XURLTransformer.hpp>
+#endif
+#ifndef _COM_SUN_STAR_FRAME_XCONTROLLER_HPP_
+#include <com/sun/star/frame/XController.hpp>
+#endif
+#ifndef _COM_SUN_STAR_LANG_XUNOTUNNEL_HPP_
+#include <com/sun/star/lang/XUnoTunnel.hpp>
+#endif
+#ifndef _COM_SUN_STAR_FRAME_STATUS_ITEMSTATUS_HPP_
+#include <com/sun/star/frame/status/ItemStatus.hpp>
+#endif
+#ifndef _COM_SUN_STAR_FRAME_STATUS_ITEMSTATE_HPP_
+#include <com/sun/star/frame/status/ItemState.hpp>
+#endif
+#ifndef _COM_SUN_STAR_AWT_MOUSEBUTTON_HPP_
+#include <com/sun/star/awt/MouseButton.hpp>
+#endif
+
#include "stbitem.hxx"
#include "sfxtypes.hxx"
#include "stbmgr.hxx"
@@ -76,22 +98,115 @@
#include "msgpool.hxx"
#include "module.hxx"
#include "dispatch.hxx"
+#include "unoctitm.hxx"
+#include "objsh.hxx"
#include "sfx.hrc"
+#include <comphelper/processfactory.hxx>
+#ifndef _SFXENUMITEM_HXX //autogen
+#include <svtools/eitem.hxx>
+#endif
+#ifndef _SFXSTRITEM_HXX //autogen
+#include <svtools/stritem.hxx>
+#endif
+#ifndef _SFXINTITEM_HXX
+#include <svtools/intitem.hxx>
+#endif
+#ifndef _TOOLKIT_HELPER_VCLUNOHELPER_HXX_
+#include <toolkit/unohlp.hxx>
+#endif
+
+using namespace ::com::sun::star;
+
+//--------------------------------------------------------------------
+
+USHORT SfxStatusBarControl::convertAwtToVCLMouseButtons( sal_Int16 nAwtMouseButtons )
+{
+ USHORT nVCLMouseButtons( 0 );
+
+ if ( nAwtMouseButtons & awt::MouseButton::LEFT )
+ nVCLMouseButtons |= MOUSE_LEFT;
+ if ( nAwtMouseButtons & awt::MouseButton::RIGHT )
+ nVCLMouseButtons |= MOUSE_RIGHT;
+ if ( nAwtMouseButtons & awt::MouseButton::MIDDLE )
+ nVCLMouseButtons |= MOUSE_MIDDLE;
+
+ return nVCLMouseButtons;
+}
+
+//--------------------------------------------------------------------
+
+svt::StatusbarController* SAL_CALL SfxStatusBarControllerFactory(
+ const uno::Reference< frame::XFrame >& rFrame,
+ StatusBar* pStatusBar,
+ unsigned short nID,
+ const ::rtl::OUString& aCommandURL )
+{
+ ::vos::OGuard aGuard( Application::GetSolarMutex() );
+
+ util::URL aTargetURL;
+ aTargetURL.Complete = aCommandURL;
+ uno::Reference < util::XURLTransformer > xTrans( ::comphelper::getProcessServiceFactory()->createInstance(
+ rtl::OUString::createFromAscii( "com.sun.star.util.URLTransformer" )), uno::UNO_QUERY );
+ xTrans->parseStrict( aTargetURL );
+
+ SfxViewFrame* pViewFrame = NULL;
+ SfxObjectShell* pObjShell = NULL;
+ uno::Reference < frame::XController > xController;
+ uno::Reference < frame::XModel > xModel;
+ if ( rFrame.is() )
+ {
+ xController = rFrame->getController();
+ if ( xController.is() )
+ xModel = xController->getModel();
+ }
+
+ if ( xModel.is() )
+ {
+ // Get tunnel from model to retrieve the SfxObjectShell pointer from it
+ ::com::sun::star::uno::Reference < ::com::sun::star::lang::XUnoTunnel > xObj( xModel, uno::UNO_QUERY );
+ ::com::sun::star::uno::Sequence < sal_Int8 > aSeq( (sal_Int8*) SvGlobalName( SFX_GLOBAL_CLASSID ).GetBytes(), 16 );
+ if ( xObj.is() )
+ {
+ sal_Int64 nHandle = xObj->getSomething( aSeq );
+ if ( nHandle )
+ pObjShell = (SfxObjectShell*) (sal_Int32*) nHandle;
+ }
+ }
+
+ SfxModule* pModule = pObjShell ? pObjShell->GetModule() : NULL;
+ SfxSlotPool* pSlotPool = 0;
+
+ if ( pModule )
+ pSlotPool = pModule->GetSlotPool();
+ else
+ pSlotPool = &(SFX_APP()->GetSlotPool( NULL ));
+
+ const SfxSlot* pSlot = pSlotPool->GetUnoSlot( aTargetURL.Path );
+ if ( pSlot )
+ {
+ USHORT nSlotId = pSlot->GetSlotId();
+ if ( nSlotId > 0 )
+ return SfxStatusBarControl::CreateControl( nSlotId, nID, pStatusBar, pModule );
+ }
+
+ return NULL;
+}
+
//--------------------------------------------------------------------
SfxStatusBarControl::SfxStatusBarControl
(
- USHORT nId, /* Slot-Id, mit der diese Instanz
+ USHORT nSlotId, /* Slot-Id, mit der diese Instanz
verbunden wird. Wurde bei der
Registrierung eine Slot-Id != 0
angegeben, ist dies immer die dort
angegebene. */
+ USHORT nId, /* ID of this controller in the status bar */
- StatusBar& rBar, /* Referenz auf die StatusBar, f"ur die
+ StatusBar& rBar /* Referenz auf die StatusBar, f"ur die
dieses Control erzeugt wurde. */
- SfxBindings& rBindings // Die Bindings dieses Controls
)
/* [Beschreibung]
@@ -103,10 +218,11 @@ SfxStatusBarControl::SfxStatusBarControl
erzeugt, f"ur die keine speziellen registriert wurden.
*/
-: SfxControllerItem(nId, rBindings),
- pBar(&rBar)
+: svt::StatusbarController(),
+ pBar( &rBar ),
+ nSlotId( nSlotId ),
+ nId( nId )
{
- DBG( CheckConfigure_Impl(SFX_SLOT_STATUSBARCONFIG) );
}
//--------------------------------------------------------------------
@@ -122,6 +238,258 @@ SfxStatusBarControl::~SfxStatusBarControl()
{}
//--------------------------------------------------------------------
+// XInterface
+uno::Any SAL_CALL SfxStatusBarControl::queryInterface( const uno::Type & rType )
+throw( uno::RuntimeException)
+{
+ return svt::StatusbarController::queryInterface( rType );
+}
+
+void SAL_CALL SfxStatusBarControl::acquire() throw()
+{
+ OWeakObject::acquire();
+}
+
+void SAL_CALL SfxStatusBarControl::release() throw()
+{
+ OWeakObject::release();
+}
+
+//--------------------------------------------------------------------
+// XEventListener
+void SAL_CALL SfxStatusBarControl::disposing( const lang::EventObject& aEvent )
+throw( uno::RuntimeException )
+{
+ svt::StatusbarController::disposing( aEvent );
+}
+
+//--------------------------------------------------------------------
+// XComponent
+void SAL_CALL SfxStatusBarControl::dispose()
+throw (uno::RuntimeException)
+{
+ svt::StatusbarController::dispose();
+}
+
+//--------------------------------------------------------------------
+// XStatusListener
+void SAL_CALL SfxStatusBarControl::statusChanged( const frame::FeatureStateEvent& rEvent )
+throw ( ::com::sun::star::uno::RuntimeException )
+{
+ SfxViewFrame* pViewFrame = NULL;
+ uno::Reference < frame::XController > xController;
+
+ ::vos::OGuard aGuard( Application::GetSolarMutex() );
+ if ( m_xFrame.is() )
+ xController = m_xFrame->getController();
+
+ uno::Reference < frame::XDispatchProvider > xProvider( xController, uno::UNO_QUERY );
+ if ( xProvider.is() )
+ {
+ uno::Reference < frame::XDispatch > xDisp = xProvider->queryDispatch( rEvent.FeatureURL, ::rtl::OUString(), 0 );
+ if ( xDisp.is() )
+ {
+ uno::Reference< lang::XUnoTunnel > xTunnel( xDisp, uno::UNO_QUERY );
+ SfxOfficeDispatch* pDisp = NULL;
+ if ( xTunnel.is() )
+ {
+ sal_Int64 nImplementation = xTunnel->getSomething(SfxOfficeDispatch::impl_getStaticIdentifier());
+ pDisp = (SfxOfficeDispatch*)(nImplementation);
+ }
+
+ if ( pDisp )
+ pViewFrame = pDisp->GetDispatcher_Impl()->GetFrame();
+ }
+ }
+
+ USHORT nSlotId = 0;
+ SfxSlotPool& rPool = SFX_APP()->GetSlotPool( pViewFrame );
+ const SfxSlot* pSlot = rPool.GetUnoSlot( rEvent.FeatureURL.Path );
+ if ( pSlot )
+ nSlotId = pSlot->GetSlotId();
+
+ if ( nSlotId > 0 )
+ {
+ if ( rEvent.Requery )
+ svt::StatusbarController::statusChanged( rEvent );
+ else
+ {
+ SfxItemState eState = SFX_ITEM_DISABLED;
+ SfxPoolItem* pItem = NULL;
+ if ( rEvent.IsEnabled )
+ {
+ eState = SFX_ITEM_AVAILABLE;
+ uno::Type pType = rEvent.State.getValueType();
+
+ if ( pType == ::getVoidCppuType() )
+ {
+ pItem = new SfxVoidItem( nSlotId );
+ eState = SFX_ITEM_UNKNOWN;
+ }
+ else if ( pType == ::getBooleanCppuType() )
+ {
+ sal_Bool bTemp ;
+ rEvent.State >>= bTemp ;
+ pItem = new SfxBoolItem( nSlotId, bTemp );
+ }
+ else if ( pType == ::getCppuType((const sal_uInt16*)0) )
+ {
+ sal_uInt16 nTemp ;
+ rEvent.State >>= nTemp ;
+ pItem = new SfxUInt16Item( nSlotId, nTemp );
+ }
+ else if ( pType == ::getCppuType((const sal_uInt32*)0) )
+ {
+ sal_uInt32 nTemp ;
+ rEvent.State >>= nTemp ;
+ pItem = new SfxUInt32Item( nSlotId, nTemp );
+ }
+ else if ( pType == ::getCppuType((const ::rtl::OUString*)0) )
+ {
+ ::rtl::OUString sTemp ;
+ rEvent.State >>= sTemp ;
+ pItem = new SfxStringItem( nSlotId, sTemp );
+ }
+ else if ( pType == ::getCppuType((const ::com::sun::star::frame::status::ItemStatus*)0) )
+ {
+ frame::status::ItemStatus aItemStatus;
+ rEvent.State >>= aItemStatus;
+ eState = aItemStatus.State;
+ pItem = new SfxVoidItem( nSlotId );
+ }
+ else
+ {
+ if ( pSlot )
+ pItem = pSlot->GetType()->CreateItem();
+ if ( pItem )
+ {
+ pItem->SetWhich( nSlotId );
+ pItem->PutValue( rEvent.State );
+ }
+ else
+ pItem = new SfxVoidItem( nSlotId );
+ }
+ }
+
+ StateChanged( nSlotId, eState, pItem );
+ delete pItem;
+ }
+ }
+}
+
+//--------------------------------------------------------------------
+// XStatusbarController
+
+::sal_Bool SAL_CALL SfxStatusBarControl::mouseButtonDown(
+ const awt::MouseEvent& rMouseEvent )
+throw ( uno::RuntimeException )
+{
+ ::vos::OGuard aGuard( Application::GetSolarMutex() );
+ ::Point aPos( rMouseEvent.X, rMouseEvent.Y );
+
+ ::MouseEvent aMouseEvent( aPos,
+ (USHORT)rMouseEvent.ClickCount,
+ 0,
+ convertAwtToVCLMouseButtons( rMouseEvent.Buttons ),
+ 0 );
+
+ return MouseButtonDown( aMouseEvent );
+}
+
+//--------------------------------------------------------------------
+
+::sal_Bool SAL_CALL SfxStatusBarControl::mouseMove(
+ const awt::MouseEvent& rMouseEvent )
+throw (uno::RuntimeException)
+{
+ ::vos::OGuard aGuard( Application::GetSolarMutex() );
+ ::Point aPos( rMouseEvent.X, rMouseEvent.Y );
+
+ ::MouseEvent aMouseEvent( aPos,
+ (USHORT)rMouseEvent.ClickCount,
+ 0,
+ convertAwtToVCLMouseButtons( rMouseEvent.Buttons ),
+ 0 );
+ return MouseMove( aMouseEvent );
+}
+
+//--------------------------------------------------------------------
+
+::sal_Bool SAL_CALL SfxStatusBarControl::mouseButtonUp(
+ const ::awt::MouseEvent& rMouseEvent )
+throw ( uno::RuntimeException )
+{
+ ::vos::OGuard aGuard( Application::GetSolarMutex() );
+ ::Point aPos( rMouseEvent.X, rMouseEvent.Y );
+
+ ::MouseEvent aMouseEvent( aPos,
+ (USHORT)rMouseEvent.ClickCount,
+ 0,
+ convertAwtToVCLMouseButtons( rMouseEvent.Buttons ),
+ 0 );
+ return MouseButtonUp( aMouseEvent );
+}
+
+//--------------------------------------------------------------------
+
+void SAL_CALL SfxStatusBarControl::command(
+ const awt::Point& rPos,
+ ::sal_Int32 nCommand,
+ ::sal_Bool bMouseEvent,
+ const ::com::sun::star::uno::Any& aData )
+throw (::com::sun::star::uno::RuntimeException)
+{
+ ::vos::OGuard aGuard( Application::GetSolarMutex() );
+ ::Point aPos( rPos.X, rPos.Y );
+ CommandEvent aCmdEvent( aPos, (USHORT)nCommand, TRUE, NULL );
+
+ Command( aCmdEvent );
+}
+
+//--------------------------------------------------------------------
+
+void SAL_CALL SfxStatusBarControl::paint(
+ const uno::Reference< awt::XGraphics >& xGraphics,
+ const awt::Rectangle& rOutputRectangle,
+ ::sal_Int32 nItemId,
+ ::sal_Int32 nStyle )
+throw ( ::uno::RuntimeException )
+{
+ ::vos::OGuard aGuard( Application::GetSolarMutex() );
+
+ OutputDevice* pOutDev = VCLUnoHelper::GetOutputDevice( xGraphics );;
+ if ( pOutDev )
+ {
+ ::Rectangle aRect( rOutputRectangle.X,
+ rOutputRectangle.Y,
+ rOutputRectangle.Width,
+ rOutputRectangle.Height );
+ UserDrawEvent aUserDrawEvent( pOutDev, aRect, (USHORT)nItemId, (USHORT)nStyle );
+ Paint( aUserDrawEvent );
+ }
+}
+
+//--------------------------------------------------------------------
+
+void SAL_CALL SfxStatusBarControl::click()
+throw ( uno::RuntimeException )
+{
+ ::vos::OGuard aGuard( Application::GetSolarMutex() );
+ Click();
+}
+
+//--------------------------------------------------------------------
+
+void SAL_CALL SfxStatusBarControl::doubleClick()
+throw ( uno::RuntimeException )
+{
+ ::vos::OGuard aGuard( Application::GetSolarMutex() );
+ DoubleClick();
+}
+
+//--------------------------------------------------------------------
+// old sfx2 interface
+//--------------------------------------------------------------------
void SfxStatusBarControl::StateChanged
(
@@ -283,12 +651,11 @@ void SfxStatusBarControl::DoubleClick()
Diese virtuelle Methode wird gerufen, wenn der Anwender mit der Maus
in das zu diesem Control geh"orige Feld der Statuszeile doppel-klickt.
-
- Die Defaultimplementierung ist leer.
*/
{
- GetBindings().Execute( GetId() );
+ ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > aArgs;
+ execute( aArgs );
}
//--------------------------------------------------------------------
@@ -314,24 +681,40 @@ void SfxStatusBarControl::Paint
//--------------------------------------------------------------------
+void SfxStatusBarControl::CaptureMouse()
+{
+// ( (SfxStatusBar_Impl*) pBar )->CaptureMouse(*this);
+}
+
+//--------------------------------------------------------------------
+
+void SfxStatusBarControl::ReleaseMouse()
+{
+// ( (SfxStatusBar_Impl*) pBar )->ReleaseMouse(*this);
+}
+
+//--------------------------------------------------------------------
+
SfxStatusBarControl* SfxStatusBarControl::CreateControl
(
- USHORT nId,
- StatusBar* pBar,
- SfxBindings& rBindings,
- SfxModule* pMod
+ USHORT nSlotId,
+ USHORT nStbId,
+ StatusBar* pBar,
+ SfxModule* pMod
)
{
+ ::vos::OGuard aGuard( Application::GetSolarMutex() );
SfxApplication *pApp = SFX_APP();
+
SfxSlotPool *pSlotPool;
if ( pMod )
pSlotPool = pMod->GetSlotPool();
else
pSlotPool = &pApp->GetSlotPool();
- TypeId aSlotType = pSlotPool->GetSlotType(nId);
+
+ TypeId aSlotType = pSlotPool->GetSlotType(nSlotId);
if ( aSlotType )
{
- rBindings.GetDispatcher_Impl();
if ( pMod )
{
SfxStbCtrlFactArr_Impl *pFactories = pMod->GetStbCtrlFactories_Impl();
@@ -341,8 +724,8 @@ SfxStatusBarControl* SfxStatusBarControl::CreateControl
for ( USHORT nFactory = 0; nFactory < rFactories.Count(); ++nFactory )
if ( rFactories[nFactory]->nTypeId == aSlotType &&
( ( rFactories[nFactory]->nSlotId == 0 ) ||
- ( rFactories[nFactory]->nSlotId == nId) ) )
- return rFactories[nFactory]->pCtor( nId, *pBar, rBindings );
+ ( rFactories[nFactory]->nSlotId == nSlotId) ) )
+ return rFactories[nFactory]->pCtor( nSlotId, nStbId, *pBar );
}
}
@@ -350,10 +733,10 @@ SfxStatusBarControl* SfxStatusBarControl::CreateControl
for ( USHORT nFactory = 0; nFactory < rFactories.Count(); ++nFactory )
if ( rFactories[nFactory]->nTypeId == aSlotType &&
( ( rFactories[nFactory]->nSlotId == 0 ) ||
- ( rFactories[nFactory]->nSlotId == nId) ) )
- return rFactories[nFactory]->pCtor( nId, *pBar, rBindings );
+ ( rFactories[nFactory]->nSlotId == nSlotId) ) )
+ return rFactories[nFactory]->pCtor( nSlotId, nStbId, *pBar );
}
- return new SfxStatusBarControl( nId, *pBar, rBindings );
-}
- //--------------------------------------------------------------------
+ return NULL;
+}
+//--------------------------------------------------------------------