diff options
author | obo <obo@openoffice.org> | 2011-03-16 08:29:30 +0100 |
---|---|---|
committer | obo <obo@openoffice.org> | 2011-03-16 08:29:30 +0100 |
commit | f165e5b06c6c97b1f92ac314a66146af02ccb872 (patch) | |
tree | 2a8d4bea3c1ab0c210b37638a9b09f49fde85a77 /svx | |
parent | d07e4ca3fedf2c59bc4867ed4dd931dd35149cbb (diff) | |
parent | 75daa4905bf769598d4c168d6151f85479020571 (diff) |
CWS-TOOLING: integrate CWS debuglevels
Diffstat (limited to 'svx')
-rw-r--r-- | svx/source/form/fmundo.cxx | 78 | ||||
-rw-r--r-- | svx/source/stbctrls/pszctrl.cxx | 2 | ||||
-rw-r--r-- | svx/source/tbxctrls/itemwin.cxx | 4 |
3 files changed, 29 insertions, 55 deletions
diff --git a/svx/source/form/fmundo.cxx b/svx/source/form/fmundo.cxx index eee61c5c2dee..ecbfc8afbe1a 100644 --- a/svx/source/form/fmundo.cxx +++ b/svx/source/form/fmundo.cxx @@ -66,6 +66,7 @@ #include <comphelper/property.hxx> #include <comphelper/uno3.hxx> #include <comphelper/stl_types.hxx> +#include <comphelper/componentcontext.hxx> using namespace ::com::sun::star::uno; using namespace ::com::sun::star::awt; @@ -88,7 +89,9 @@ typedef cppu::WeakImplHelper1< XScriptListener > ScriptEventListener_BASE; class ScriptEventListenerWrapper : public ScriptEventListener_BASE { public: - ScriptEventListenerWrapper( FmFormModel& _rModel) throw ( RuntimeException ) : pModel(&_rModel) + ScriptEventListenerWrapper( FmFormModel& _rModel) throw ( RuntimeException ) + :m_rModel( _rModel ) + ,m_attemptedListenerCreation( false ) { } @@ -98,7 +101,7 @@ public: // XScriptListener virtual void SAL_CALL firing(const ScriptEvent& evt) throw(RuntimeException) { - setModel(); + attemptListenerCreation(); if ( m_vbaListener.is() ) { m_vbaListener->firing( evt ); @@ -107,7 +110,7 @@ public: virtual Any SAL_CALL approveFiring(const ScriptEvent& evt) throw( com::sun::star::reflection::InvocationTargetException, RuntimeException) { - setModel(); + attemptListenerCreation(); if ( m_vbaListener.is() ) { return m_vbaListener->approveFiring( evt ); @@ -116,61 +119,32 @@ public: } private: - void setModel() + void attemptListenerCreation() { - if ( !m_vbaListener.is() ) - { - Reference < XPropertySet > xProps( - ::comphelper::getProcessServiceFactory(), UNO_QUERY ); - if ( xProps.is() ) - { - Reference< XComponentContext > xCtx( xProps->getPropertyValue( - rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "DefaultContext" ))), UNO_QUERY ); - if ( xCtx.is() ) - { - Reference< XMultiComponentFactory > xMFac( - xCtx->getServiceManager(), UNO_QUERY ); - - // SfxObjectShellRef is good here since the model controls the lifetime of the shell - SfxObjectShellRef xObjSh = pModel->GetObjectShell(); - Reference< XMultiServiceFactory > xDocFac; - if ( xObjSh.Is() ) - xDocFac.set( xObjSh->GetModel(), UNO_QUERY ); + if ( m_attemptedListenerCreation ) + return; + m_attemptedListenerCreation = true; - if ( xMFac.is() ) - { - m_vbaListener.set( xMFac->createInstanceWithContext( - rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( - "ooo.vba.EventListener" ) ), xCtx ), - UNO_QUERY_THROW ); - } - } - } + try + { + ::comphelper::ComponentContext const aContext( ::comphelper::getProcessServiceFactory() ); + Reference< XScriptListener > const xScriptListener( aContext.createComponent( "ooo.vba.EventListener" ), UNO_QUERY_THROW ); + Reference< XPropertySet > const xListenerProps( xScriptListener, UNO_QUERY_THROW ); + // SfxObjectShellRef is good here since the model controls the lifetime of the shell + SfxObjectShellRef const xObjectShell = m_rModel.GetObjectShell(); + ENSURE_OR_THROW( xObjectShell.Is(), "no object shell!" ); + xListenerProps->setPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Model" ) ), makeAny( xObjectShell->GetModel() ) ); + + m_vbaListener = xScriptListener; } - Reference< XPropertySet > xProps( m_vbaListener, UNO_QUERY ); - if ( xProps.is() ) + catch( Exception const & ) { - try - { - // SfxObjectShellRef is good here since the model controls the lifetime of the shell - SfxObjectShellRef xObjSh = pModel->GetObjectShell(); - if ( xObjSh.Is() && m_vbaListener.is() ) - { - Any aVal; - aVal <<= xObjSh->GetModel(); - xProps->setPropertyValue( - ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Model" ) ), - aVal ); - } - } - catch( Exception& ) - { - //swallow any errors - } + DBG_UNHANDLED_EXCEPTION(); } } - FmFormModel* pModel; - Reference< XScriptListener > m_vbaListener; + FmFormModel& m_rModel; + Reference< XScriptListener > m_vbaListener; + bool m_attemptedListenerCreation; }; diff --git a/svx/source/stbctrls/pszctrl.cxx b/svx/source/stbctrls/pszctrl.cxx index 094cfbd96ee5..d1bc7d4d610e 100644 --- a/svx/source/stbctrls/pszctrl.cxx +++ b/svx/source/stbctrls/pszctrl.cxx @@ -78,7 +78,7 @@ String SvxPosSizeStatusBarControl::GetMetricStr_Impl( long nVal ) { // Applikations-Metrik besorgen und setzen - FieldUnit eOutUnit = SfxModule::GetCurrentFieldUnit(); + FieldUnit eOutUnit = SfxModule::GetModuleFieldUnit( getFrameInterface() ); FieldUnit eInUnit = FUNIT_100TH_MM; String sMetric; diff --git a/svx/source/tbxctrls/itemwin.cxx b/svx/source/tbxctrls/itemwin.cxx index 76fd7d423324..7666c1064e15 100644 --- a/svx/source/tbxctrls/itemwin.cxx +++ b/svx/source/tbxctrls/itemwin.cxx @@ -491,7 +491,7 @@ SvxMetricField::SvxMetricField( SetLast( 5000 ); SetFirst( 0 ); - eDlgUnit = SfxModule::GetCurrentFieldUnit(); + eDlgUnit = SfxModule::GetModuleFieldUnit( mxFrame ); SetFieldUnit( *this, eDlgUnit, sal_False ); Show(); } @@ -576,7 +576,7 @@ void SvxMetricField::SetCoreUnit( SfxMapUnit eUnit ) void SvxMetricField::RefreshDlgUnit() { - FieldUnit eTmpUnit = SfxModule::GetCurrentFieldUnit(); + FieldUnit eTmpUnit = SfxModule::GetModuleFieldUnit( mxFrame ); if ( eDlgUnit != eTmpUnit ) { eDlgUnit = eTmpUnit; |