summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAriel Constenla-Haile <arielch@apache.org>2012-12-06 12:29:42 +0000
committerCaolán McNamara <caolanm@redhat.com>2013-05-21 14:01:18 +0100
commit25ec90bfa85ab829e47f442742c63dd41960b973 (patch)
tree3d75fe9c0baae5d6db2f6f04cf5ea1fbd7f0ea8a
parentcfaac477e2a23880310070690beb3222b1c8227c (diff)
Related: #i121442# Adapt existing code in other modules
(cherry picked from commit 6c640ee420df6f7c9f3ab981e49ee304f1d2319e) Conflicts: reportdesign/source/ui/misc/statusbarcontroller.cxx sfx2/inc/sfx2/stbitem.hxx svtools/inc/svtools/statusbarcontroller.hxx svtools/source/uno/statusbarcontroller.cxx Change-Id: If03a201214a4afe09efa4e3e996aded9b6a57bdf
-rw-r--r--include/sfx2/stbitem.hxx8
-rw-r--r--include/svtools/statusbarcontroller.hxx15
-rw-r--r--reportdesign/source/ui/inc/statusbarcontroller.hxx15
-rw-r--r--reportdesign/source/ui/misc/statusbarcontroller.cxx64
-rw-r--r--sfx2/source/statbar/stbitem.cxx7
-rw-r--r--svtools/source/uno/statusbarcontroller.cxx73
6 files changed, 92 insertions, 90 deletions
diff --git a/include/sfx2/stbitem.hxx b/include/sfx2/stbitem.hxx
index d94e76841045..0512c310d3b7 100644
--- a/include/sfx2/stbitem.hxx
+++ b/include/sfx2/stbitem.hxx
@@ -90,10 +90,10 @@ protected:
::sal_Bool bMouseEvent,
const ::com::sun::star::uno::Any& aData ) throw (::com::sun::star::uno::RuntimeException);
virtual void SAL_CALL paint( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XGraphics >& xGraphics,
- const ::com::sun::star::awt::Rectangle& rOutputRectangle,
- ::sal_Int32 nItemId, ::sal_Int32 nStyle ) throw (::com::sun::star::uno::RuntimeException);
- virtual void SAL_CALL click() throw (::com::sun::star::uno::RuntimeException);
- virtual void SAL_CALL doubleClick() throw (::com::sun::star::uno::RuntimeException);
+ const ::com::sun::star::awt::Rectangle& rOutputRectangle,
+ ::sal_Int32 nStyle ) throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL click( const ::com::sun::star::awt::Point& aPos ) throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL doubleClick( const ::com::sun::star::awt::Point& aPos ) throw (::com::sun::star::uno::RuntimeException);
// Old sfx2 interface
virtual void StateChanged( sal_uInt16 nSID, SfxItemState eState,
diff --git a/include/svtools/statusbarcontroller.hxx b/include/svtools/statusbarcontroller.hxx
index eba45e543525..9d094fa151b8 100644
--- a/include/svtools/statusbarcontroller.hxx
+++ b/include/svtools/statusbarcontroller.hxx
@@ -21,12 +21,10 @@
#define _SVTOOLS_STATUSBARCONTROLLER_HXX
#include "svtools/svtdllapi.h"
+#include <com/sun/star/ui/XStatusbarItem.hpp>
#include <com/sun/star/lang/XMultiServiceFactory.hpp>
-#include <com/sun/star/lang/XInitialization.hpp>
-#include <com/sun/star/util/XUpdatable.hpp>
#include <com/sun/star/frame/XFrame.hpp>
#include <com/sun/star/frame/XDispatch.hpp>
-#include <com/sun/star/frame/XStatusListener.hpp>
#include <com/sun/star/frame/XStatusbarController.hpp>
#include <com/sun/star/util/XURLTransformer.hpp>
#include <com/sun/star/frame/XLayoutManager.hpp>
@@ -41,10 +39,8 @@
namespace svt
{
-class SVT_DLLPUBLIC StatusbarController : public ::com::sun::star::frame::XStatusListener,
+class SVT_DLLPUBLIC StatusbarController :
public ::com::sun::star::frame::XStatusbarController,
- public ::com::sun::star::lang::XInitialization,
- public ::com::sun::star::util::XUpdatable,
public ::com::sun::star::lang::XComponent,
public ::comphelper::OBaseMutex,
public ::cppu::OWeakObject
@@ -94,9 +90,9 @@ class SVT_DLLPUBLIC StatusbarController : public ::com::sun::star::frame::XStatu
const ::com::sun::star::uno::Any& aData ) throw (::com::sun::star::uno::RuntimeException);
virtual void SAL_CALL paint( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XGraphics >& xGraphics,
const ::com::sun::star::awt::Rectangle& rOutputRectangle,
- ::sal_Int32 nItemId, ::sal_Int32 nStyle ) throw (::com::sun::star::uno::RuntimeException);
- virtual void SAL_CALL click() throw (::com::sun::star::uno::RuntimeException);
- virtual void SAL_CALL doubleClick() throw (::com::sun::star::uno::RuntimeException);
+ ::sal_Int32 nStyle ) throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL click( const ::com::sun::star::awt::Point& aPos ) throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL doubleClick( const ::com::sun::star::awt::Point& aPos ) throw (::com::sun::star::uno::RuntimeException);
protected:
struct Listener
@@ -132,6 +128,7 @@ class SVT_DLLPUBLIC StatusbarController : public ::com::sun::star::frame::XStatu
URLToDispatchMap m_aListenerMap;
::cppu::OMultiTypeInterfaceContainerHelper m_aListenerContainer; /// container for ALL Listener
mutable ::com::sun::star::uno::Reference< ::com::sun::star::util::XURLTransformer > m_xURLTransformer;
+ ::com::sun::star::uno::Reference< ::com::sun::star::ui::XStatusbarItem > m_xStatusbarItem;
};
}
diff --git a/reportdesign/source/ui/inc/statusbarcontroller.hxx b/reportdesign/source/ui/inc/statusbarcontroller.hxx
index 413cca6d2ac9..6e6fda959e5d 100644
--- a/reportdesign/source/ui/inc/statusbarcontroller.hxx
+++ b/reportdesign/source/ui/inc/statusbarcontroller.hxx
@@ -23,20 +23,19 @@
#include <comphelper/uno3.hxx>
#include <com/sun/star/lang/XServiceInfo.hpp>
#include <cppuhelper/implbase1.hxx>
-#include <comphelper/implementationreference.hxx>
class SfxStatusBarControl;
namespace rptui
{
- typedef ::comphelper::ImplementationReference<SfxStatusBarControl,::com::sun::star::frame::XStatusbarController> TStatusbarHelper;
+ typedef com::sun::star::uno::Reference< com::sun::star::frame::XStatusbarController > TStatusbarRef;
typedef ::cppu::ImplHelper1 < ::com::sun::star::lang::XServiceInfo> OStatusbarController_BASE;
class OStatusbarController : public ::svt::StatusbarController,
public OStatusbarController_BASE
{
- TStatusbarHelper m_pController;
- sal_uInt16 m_nSlotId;
- sal_uInt16 m_nId;
+ TStatusbarRef m_rController;
+ sal_uInt16 m_nSlotId;
+ sal_uInt16 m_nId;
public:
OStatusbarController(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxORB);
@@ -75,9 +74,9 @@ namespace rptui
const ::com::sun::star::uno::Any& aData ) throw (::com::sun::star::uno::RuntimeException);
virtual void SAL_CALL paint( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XGraphics >& xGraphics,
const ::com::sun::star::awt::Rectangle& rOutputRectangle,
- ::sal_Int32 nItemId, ::sal_Int32 nStyle ) throw (::com::sun::star::uno::RuntimeException);
- virtual void SAL_CALL click() throw (::com::sun::star::uno::RuntimeException);
- virtual void SAL_CALL doubleClick() throw (::com::sun::star::uno::RuntimeException);
+ ::sal_Int32 nStyle ) throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL click( const ::com::sun::star::awt::Point& aPos ) throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL doubleClick( const ::com::sun::star::awt::Point& aPos ) throw (::com::sun::star::uno::RuntimeException);
};
}
#endif // DBAUI_STATUSBARCONTROLLER_HXX
diff --git a/reportdesign/source/ui/misc/statusbarcontroller.cxx b/reportdesign/source/ui/misc/statusbarcontroller.cxx
index 6f73dadbdcd5..9bb946e7f132 100644
--- a/reportdesign/source/ui/misc/statusbarcontroller.cxx
+++ b/reportdesign/source/ui/misc/statusbarcontroller.cxx
@@ -99,19 +99,25 @@ void SAL_CALL OStatusbarController::initialize( const Sequence< Any >& _rArgumen
break;
}
}
+
+ SfxStatusBarControl *pController = 0;
if ( m_aCommandURL == ".uno:ZoomSlider" )
{
- m_pController = TStatusbarHelper::createFromQuery(new SvxZoomSliderControl(m_nSlotId = SID_ATTR_ZOOMSLIDER,m_nId,*pStatusBar));
+ pController = new SvxZoomSliderControl(m_nSlotId = SID_ATTR_ZOOMSLIDER,m_nId,*pStatusBar);
}
else if ( m_aCommandURL == ".uno:Zoom" )
{
- m_pController = TStatusbarHelper::createFromQuery(new SvxZoomStatusBarControl(m_nSlotId = SID_ATTR_ZOOM,m_nId,*pStatusBar));
+ pController = new SvxZoomStatusBarControl(m_nSlotId = SID_ATTR_ZOOM,m_nId,*pStatusBar);
}
- if ( m_pController.is() )
+ if ( pController )
{
- m_pController->initialize(_rArguments);
- m_pController->update();
+ m_rController.set( pController );
+ if ( m_rController.is() )
+ {
+ m_rController->initialize(_rArguments);
+ m_rController->update();
+ }
}
addStatusListener(m_aCommandURL);
@@ -124,7 +130,7 @@ void SAL_CALL OStatusbarController::statusChanged( const FeatureStateEvent& _aEv
SolarMutexGuard aSolarGuard;
::osl::MutexGuard aGuard(m_aMutex);
- if ( m_pController.is() )
+ if ( m_rController.is() )
{
if ( m_aCommandURL == ".uno:ZoomSlider" )
{
@@ -133,7 +139,7 @@ void SAL_CALL OStatusbarController::statusChanged( const FeatureStateEvent& _aEv
{
SvxZoomSliderItem aZoomSlider(100,20,400);
aZoomSlider.PutValue(_aEvent.State);
- static_cast<SvxZoomSliderControl*>(m_pController.get())->StateChanged(m_nSlotId,SFX_ITEM_AVAILABLE,&aZoomSlider);
+ static_cast<SvxZoomSliderControl*>(m_rController.get())->StateChanged(m_nSlotId,SFX_ITEM_AVAILABLE,&aZoomSlider);
}
}
else if ( m_aCommandURL == ".uno:Zoom" )
@@ -143,7 +149,7 @@ void SAL_CALL OStatusbarController::statusChanged( const FeatureStateEvent& _aEv
{
SvxZoomItem aZoom;
aZoom.PutValue(_aEvent.State);
- static_cast<SvxZoomStatusBarControl*>(m_pController.get())->StateChanged(m_nSlotId,SFX_ITEM_AVAILABLE,&aZoom);
+ static_cast<SvxZoomStatusBarControl*>(m_rController.get())->StateChanged(m_nSlotId,SFX_ITEM_AVAILABLE,&aZoom);
}
}
}
@@ -152,17 +158,17 @@ void SAL_CALL OStatusbarController::statusChanged( const FeatureStateEvent& _aEv
// XStatusbarController
::sal_Bool SAL_CALL OStatusbarController::mouseButtonDown(const ::com::sun::star::awt::MouseEvent& _aEvent)throw (::com::sun::star::uno::RuntimeException)
{
- return m_pController.is() && m_pController.getRef()->mouseButtonDown(_aEvent);
+ return m_rController.is() && m_rController->mouseButtonDown(_aEvent);
}
::sal_Bool SAL_CALL OStatusbarController::mouseMove( const ::com::sun::star::awt::MouseEvent& _aEvent)throw (::com::sun::star::uno::RuntimeException)
{
- return m_pController.is() && m_pController.getRef()->mouseMove(_aEvent);
+ return m_rController.is() && m_rController->mouseMove(_aEvent);
}
::sal_Bool SAL_CALL OStatusbarController::mouseButtonUp( const ::com::sun::star::awt::MouseEvent& _aEvent)throw (::com::sun::star::uno::RuntimeException)
{
- return m_pController.is() && m_pController.getRef()->mouseButtonUp(_aEvent);
+ return m_rController.is() && m_rController->mouseButtonUp(_aEvent);
}
void SAL_CALL OStatusbarController::command(
@@ -172,47 +178,49 @@ void SAL_CALL OStatusbarController::command(
const ::com::sun::star::uno::Any& aData )
throw (::com::sun::star::uno::RuntimeException)
{
- if ( m_pController.is() )
- m_pController.getRef()->command( aPos, nCommand, bMouseEvent, aData );
+ if ( m_rController.is() )
+ m_rController->command( aPos, nCommand, bMouseEvent, aData );
}
void SAL_CALL OStatusbarController::paint(
const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XGraphics >& xGraphics,
const ::com::sun::star::awt::Rectangle& rOutputRectangle,
- ::sal_Int32 nItemId,
::sal_Int32 nStyle )
throw (::com::sun::star::uno::RuntimeException)
{
- if ( m_pController.is() )
- m_pController.getRef()->paint( xGraphics, rOutputRectangle, nItemId, nStyle );
+ if ( m_rController.is() )
+ m_rController->paint( xGraphics, rOutputRectangle, nStyle );
}
-void SAL_CALL OStatusbarController::click() throw (::com::sun::star::uno::RuntimeException)
+void SAL_CALL OStatusbarController::click(
+ const ::com::sun::star::awt::Point& aPos )
+throw (::com::sun::star::uno::RuntimeException)
{
- if ( m_pController.is() )
- m_pController.getRef()->click();
+ if ( m_rController.is() )
+ m_rController->click( aPos );
}
-void SAL_CALL OStatusbarController::doubleClick() throw (::com::sun::star::uno::RuntimeException)
+void SAL_CALL OStatusbarController::doubleClick(
+ const ::com::sun::star::awt::Point& aPos )
+throw (::com::sun::star::uno::RuntimeException)
{
- if ( m_pController.is() )
- m_pController.getRef()->doubleClick();
+ if ( m_rController.is() )
+ m_rController->doubleClick( aPos );
}
// -----------------------------------------------------------------------------
void SAL_CALL OStatusbarController::update() throw ( RuntimeException )
{
::svt::StatusbarController::update();
- Reference< XUpdatable > xUp(m_pController.getRef(),UNO_QUERY);
- if ( xUp.is() )
- xUp->update();
+ if ( m_rController.is() )
+ m_rController->update();
}
// -----------------------------------------------------------------------------
// XComponent
void SAL_CALL OStatusbarController::dispose() throw (::com::sun::star::uno::RuntimeException)
{
- Reference< XComponent > xComp( m_pController.getRef(), UNO_QUERY );
- ::comphelper::disposeComponent(xComp);
- m_pController.dispose();
+ if ( m_rController.is() )
+ ::comphelper::disposeComponent( m_rController );
+
svt::StatusbarController::dispose();
}
// =============================================================================
diff --git a/sfx2/source/statbar/stbitem.cxx b/sfx2/source/statbar/stbitem.cxx
index 63c1cdcc219b..609550496a5c 100644
--- a/sfx2/source/statbar/stbitem.cxx
+++ b/sfx2/source/statbar/stbitem.cxx
@@ -387,7 +387,6 @@ throw (::com::sun::star::uno::RuntimeException)
void SAL_CALL SfxStatusBarControl::paint(
const uno::Reference< awt::XGraphics >& xGraphics,
const awt::Rectangle& rOutputRectangle,
- ::sal_Int32 nItemId,
::sal_Int32 nStyle )
throw ( ::uno::RuntimeException )
{
@@ -397,14 +396,14 @@ throw ( ::uno::RuntimeException )
if ( pOutDev )
{
::Rectangle aRect = VCLRectangle( rOutputRectangle );
- UserDrawEvent aUserDrawEvent( pOutDev, aRect, (sal_uInt16)nItemId, (sal_uInt16)nStyle );
+ UserDrawEvent aUserDrawEvent( pOutDev, aRect, pBar->GetCurItemId(), (sal_uInt16)nStyle );
Paint( aUserDrawEvent );
}
}
//--------------------------------------------------------------------
-void SAL_CALL SfxStatusBarControl::click()
+void SAL_CALL SfxStatusBarControl::click( const awt::Point& )
throw ( uno::RuntimeException )
{
SolarMutexGuard aGuard;
@@ -413,7 +412,7 @@ throw ( uno::RuntimeException )
//--------------------------------------------------------------------
-void SAL_CALL SfxStatusBarControl::doubleClick()
+void SAL_CALL SfxStatusBarControl::doubleClick( const awt::Point& )
throw ( uno::RuntimeException )
{
SolarMutexGuard aGuard;
diff --git a/svtools/source/uno/statusbarcontroller.cxx b/svtools/source/uno/statusbarcontroller.cxx
index cee30a4f2d63..d93feed5ff78 100644
--- a/svtools/source/uno/statusbarcontroller.cxx
+++ b/svtools/source/uno/statusbarcontroller.cxx
@@ -30,7 +30,7 @@
#include <vcl/status.hxx>
#include <svtools/imgdef.hxx>
#include <svtools/miscopt.hxx>
-#include <toolkit/unohlp.hxx>
+#include <toolkit/helper/vclunohelper.hxx>
#include <comphelper/processfactory.hxx>
using namespace ::cppu;
@@ -153,6 +153,8 @@ throw ( Exception, RuntimeException )
aPropValue.Value >>= m_xParentWindow;
else if ( aPropValue.Name == "Identifier" )
aPropValue.Value >>= m_nID;
+ else if ( aPropValue.Name == "StatusbarItem" )
+ aPropValue.Value >>= m_xStatusbarItem;
}
}
@@ -220,6 +222,7 @@ throw (::com::sun::star::uno::RuntimeException)
m_xServiceManager.clear();
m_xFrame.clear();
m_xParentWindow.clear();
+ m_xStatusbarItem.clear();
m_bDisposed = sal_True;
}
@@ -240,26 +243,31 @@ throw ( RuntimeException )
void SAL_CALL StatusbarController::disposing( const EventObject& Source )
throw ( RuntimeException )
{
- Reference< XInterface > xSource( Source.Source );
-
SolarMutexGuard aSolarMutexGuard;
if ( m_bDisposed )
return;
+ Reference< XFrame > xFrame( Source.Source, UNO_QUERY );
+ if ( xFrame.is() )
+ {
+ if ( xFrame == m_xFrame )
+ m_xFrame.clear();
+ return;
+ }
+
+ Reference< XDispatch > xDispatch( Source.Source, UNO_QUERY );
+ if ( !xDispatch.is() )
+ return;
+
URLToDispatchMap::iterator pIter = m_aListenerMap.begin();
while ( pIter != m_aListenerMap.end() )
{
// Compare references and release dispatch references if they are equal.
- Reference< XInterface > xIfac( pIter->second, UNO_QUERY );
- if ( xSource == xIfac )
+ if ( xDispatch == pIter->second )
pIter->second.clear();
++pIter;
}
-
- Reference< XInterface > xIfac( m_xFrame, UNO_QUERY );
- if ( xIfac == xSource )
- m_xFrame.clear();
}
// XStatusListener
@@ -318,18 +326,17 @@ throw (::com::sun::star::uno::RuntimeException)
void SAL_CALL StatusbarController::paint(
const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XGraphics >&,
const ::com::sun::star::awt::Rectangle&,
- ::sal_Int32,
::sal_Int32 )
throw (::com::sun::star::uno::RuntimeException)
{
}
-void SAL_CALL StatusbarController::click()
+void SAL_CALL StatusbarController::click( const ::com::sun::star::awt::Point& )
throw (::com::sun::star::uno::RuntimeException)
{
}
-void SAL_CALL StatusbarController::doubleClick() throw (::com::sun::star::uno::RuntimeException)
+void SAL_CALL StatusbarController::doubleClick( const ::com::sun::star::awt::Point& ) throw (::com::sun::star::uno::RuntimeException)
{
SolarMutexGuard aSolarMutexGuard;
@@ -465,37 +472,29 @@ void StatusbarController::bindListener()
}
// Call without locked mutex as we are called back from dispatch implementation
- if ( xStatusListener.is() )
+ if ( !xStatusListener.is() )
+ return;
+
+ for ( sal_uInt32 i = 0; i < aDispatchVector.size(); i++ )
{
try
{
- for ( sal_uInt32 i = 0; i < aDispatchVector.size(); i++ )
+ Listener& rListener = aDispatchVector[i];
+ if ( rListener.xDispatch.is() )
+ rListener.xDispatch->addStatusListener( xStatusListener, rListener.aURL );
+ else if ( rListener.aURL.Complete == m_aCommandURL )
{
- Listener& rListener = aDispatchVector[i];
- if ( rListener.xDispatch.is() )
- rListener.xDispatch->addStatusListener( xStatusListener, rListener.aURL );
- else if ( rListener.aURL.Complete == m_aCommandURL )
- {
- try
- {
- // Send status changed for the main URL, if we cannot get a valid dispatch object.
- // UI disables the button. Catch exception as we release our mutex, it is possible
- // that someone else already disposed this instance!
- FeatureStateEvent aFeatureStateEvent;
- aFeatureStateEvent.IsEnabled = sal_False;
- aFeatureStateEvent.FeatureURL = rListener.aURL;
- aFeatureStateEvent.State = Any();
- xStatusListener->statusChanged( aFeatureStateEvent );
- }
- catch ( Exception& )
- {
- }
- }
+ // Send status changed for the main URL, if we cannot get a valid dispatch object.
+ // UI disables the button. Catch exception as we release our mutex, it is possible
+ // that someone else already disposed this instance!
+ FeatureStateEvent aFeatureStateEvent;
+ aFeatureStateEvent.IsEnabled = sal_False;
+ aFeatureStateEvent.FeatureURL = rListener.aURL;
+ aFeatureStateEvent.State = Any();
+ xStatusListener->statusChanged( aFeatureStateEvent );
}
}
- catch ( Exception& )
- {
- }
+ catch ( ... ){}
}
}