diff options
author | Noel Grandin <noel@peralex.com> | 2013-06-03 15:34:00 +0200 |
---|---|---|
committer | Noel Grandin <noel@peralex.com> | 2013-06-05 08:13:22 +0200 |
commit | cee55a2c5463134c3a394bf6eda22998bc6cb2c9 (patch) | |
tree | b3a065a8d3670d2a2b63616b61c514b65b220248 /extensions | |
parent | dcbaf7c253031a8f7b568c57397c663edfa26e5b (diff) |
fdo#46808, Convert a copy of ComponentContext to XComponentContext
Looks like this extensions had a modified copy of
comphelper::ComponentContext in it.
Change-Id: I7e29aea4e6480a619f3148530fe6d784efe260e1
Diffstat (limited to 'extensions')
19 files changed, 102 insertions, 340 deletions
diff --git a/extensions/Library_pcr.mk b/extensions/Library_pcr.mk index f74a14250b3d..a0ae1af8c345 100644 --- a/extensions/Library_pcr.mk +++ b/extensions/Library_pcr.mk @@ -77,7 +77,6 @@ $(eval $(call gb_Library_add_exception_objects,pcr,\ extensions/source/propctrlr/newdatatype \ extensions/source/propctrlr/objectinspectormodel \ extensions/source/propctrlr/pcrcommon \ - extensions/source/propctrlr/pcrcomponentcontext \ extensions/source/propctrlr/pcrservices \ extensions/source/propctrlr/pcrunodialogs \ extensions/source/propctrlr/propcontroller \ diff --git a/extensions/source/propctrlr/browserview.cxx b/extensions/source/propctrlr/browserview.cxx index f9ae3cf101bf..05a41eb5bb02 100644 --- a/extensions/source/propctrlr/browserview.cxx +++ b/extensions/source/propctrlr/browserview.cxx @@ -37,10 +37,8 @@ namespace pcr //======================================================================== DBG_NAME(OPropertyBrowserView) //------------------------------------------------------------------------ - OPropertyBrowserView::OPropertyBrowserView( const Reference< XMultiServiceFactory >& _rxORB, - Window* _pParent, WinBits nBits) + OPropertyBrowserView::OPropertyBrowserView(Window* _pParent, WinBits nBits) :Window(_pParent, nBits | WB_3DLOOK) - ,m_xORB(_rxORB) ,m_nActivePage(0) { DBG_CTOR(OPropertyBrowserView,NULL); @@ -72,7 +70,6 @@ namespace pcr ::std::auto_ptr<Window> aTemp(m_pPropBox); m_pPropBox = NULL; } - m_xORB = NULL; DBG_DTOR(OPropertyBrowserView, NULL); } diff --git a/extensions/source/propctrlr/browserview.hxx b/extensions/source/propctrlr/browserview.hxx index 8b7358d43afd..88a150fab092 100644 --- a/extensions/source/propctrlr/browserview.hxx +++ b/extensions/source/propctrlr/browserview.hxx @@ -21,7 +21,6 @@ #define _EXTENSIONS_PROPCTRLR_BROWSERVIEW_HXX_ #include <com/sun/star/beans/XPropertySet.hpp> -#include <com/sun/star/lang/XMultiServiceFactory.hpp> #include <vcl/window.hxx> #include <tools/resid.hxx> #include <com/sun/star/awt/Size.hpp> @@ -38,8 +37,6 @@ namespace pcr //======================================================================== class OPropertyBrowserView : public Window { - ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > m_xORB; - OPropertyEditor* m_pPropBox; sal_uInt16 m_nActivePage; Link m_aPageActivationHandler; @@ -50,8 +47,7 @@ namespace pcr virtual long Notify( NotifyEvent& _rNEvt ); public: - OPropertyBrowserView(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _xORB, - Window* pParent, WinBits nBits = 0); + OPropertyBrowserView( Window* pParent, WinBits nBits = 0); virtual ~OPropertyBrowserView(); diff --git a/extensions/source/propctrlr/buttonnavigationhandler.cxx b/extensions/source/propctrlr/buttonnavigationhandler.cxx index d4b25c2f84ec..382451a04dc3 100644 --- a/extensions/source/propctrlr/buttonnavigationhandler.cxx +++ b/extensions/source/propctrlr/buttonnavigationhandler.cxx @@ -52,11 +52,9 @@ namespace pcr { DBG_CTOR( ButtonNavigationHandler, NULL ); - m_aContext.createComponent( - OUString( "com.sun.star.form.inspection.FormComponentPropertyHandler" ), - m_xSlaveHandler ); - if ( !m_xSlaveHandler.is() ) - throw RuntimeException(); + m_xSlaveHandler.set( m_xContext->getServiceManager()->createInstanceWithContext( + OUString( "com.sun.star.form.inspection.FormComponentPropertyHandler" ), m_xContext ), + UNO_QUERY_THROW); } //-------------------------------------------------------------------- diff --git a/extensions/source/propctrlr/eformspropertyhandler.cxx b/extensions/source/propctrlr/eformspropertyhandler.cxx index 063735450d2b..789d3a85acfa 100644 --- a/extensions/source/propctrlr/eformspropertyhandler.cxx +++ b/extensions/source/propctrlr/eformspropertyhandler.cxx @@ -497,7 +497,7 @@ namespace pcr try { Reference< XExecutableDialog > xDialog; - m_aContext.createComponent( "com.sun.star.xforms.ui.dialogs.AddCondition", xDialog ); + xDialog.set( m_xContext->getServiceManager()->createInstanceWithContext( "com.sun.star.xforms.ui.dialogs.AddCondition", m_xContext ), UNO_QUERY ); Reference< XPropertySet > xDialogProps( xDialog, UNO_QUERY_THROW ); // the model for the dialog to work with diff --git a/extensions/source/propctrlr/eventhandler.cxx b/extensions/source/propctrlr/eventhandler.cxx index fb058aa74279..eb1c4adb1956 100644 --- a/extensions/source/propctrlr/eventhandler.cxx +++ b/extensions/source/propctrlr/eventhandler.cxx @@ -495,7 +495,7 @@ namespace pcr //-------------------------------------------------------------------- EventHandler::EventHandler( const Reference< XComponentContext >& _rxContext ) :EventHandler_Base( m_aMutex ) - ,m_aContext( _rxContext ) + ,m_xContext( _rxContext ) ,m_aPropertyListeners( m_aMutex ) ,m_bEventsMapInitialized( false ) ,m_bIsDialogElement( false ) @@ -637,9 +637,7 @@ namespace pcr else impl_setFormComponentScriptEvent_nothrow( aNewScriptEvent ); - Reference< XModifiable > xDoc( m_aContext.getContextValueByAsciiName( "ContextDocument" ), UNO_QUERY ); - if ( xDoc.is() ) - xDoc->setModified( sal_True ); + PropertyHandlerHelper::setContextDocumentModified( m_xContext ); PropertyChangeEvent aEvent; aEvent.Source = m_xComponent; @@ -697,7 +695,7 @@ namespace pcr try { // parse - Reference< XUriReferenceFactory > xUriRefFac = UriReferenceFactory::create( m_aContext.getUNOContext() ); + Reference< XUriReferenceFactory > xUriRefFac = UriReferenceFactory::create( m_xContext ); Reference< XVndSunStarScriptUrlReference > xScriptUri( xUriRefFac->parse( sScript ), UNO_QUERY_THROW ); OUStringBuffer aComposeBuffer; @@ -919,7 +917,7 @@ namespace pcr return InteractiveSelectionResult_Cancelled; ::std::auto_ptr< VclAbstractDialog > pDialog( pFactory->CreateSvxMacroAssignDlg( - PropertyHandlerHelper::getDialogParentWindow( m_aContext ), + PropertyHandlerHelper::getDialogParentWindow( m_xContext ), impl_getContextFrame_nothrow(), m_bIsDialogElement, pEventHolder.get(), @@ -988,7 +986,7 @@ namespace pcr try { - Reference< XModel > xContextDocument( m_aContext.getContextValueByAsciiName( "ContextDocument" ), UNO_QUERY_THROW ); + Reference< XModel > xContextDocument( PropertyHandlerHelper::getContextDocument(m_xContext), UNO_QUERY_THROW ); Reference< XController > xController( xContextDocument->getCurrentController(), UNO_SET_THROW ); xContextFrame.set( xController->getFrame(), UNO_SET_THROW ); } @@ -1052,7 +1050,7 @@ namespace pcr // we use a set to avoid duplicates TypeBag aListeners; - Reference< XIntrospection > xIntrospection = Introspection::create( m_aContext.getUNOContext() ); + Reference< XIntrospection > xIntrospection = Introspection::create( m_xContext ); // --- model listeners lcl_addListenerTypesFor_throw( @@ -1110,7 +1108,7 @@ namespace pcr if ( xComponentAsForm.is() ) { Reference< XTabControllerModel > xComponentAsTCModel( m_xComponent, UNO_QUERY_THROW ); - Reference< XFormController > xController = FormController::create( m_aContext.getUNOContext() ); + Reference< XFormController > xController = FormController::create( m_xContext ); xController->setModel( xComponentAsTCModel ); xReturn = xController; @@ -1120,7 +1118,7 @@ namespace pcr OUString sControlService; OSL_VERIFY( m_xComponent->getPropertyValue( PROPERTY_DEFAULTCONTROL ) >>= sControlService ); - xReturn = m_aContext.createComponent( sControlService ); + xReturn = m_xContext->getServiceManager()->createInstanceWithContext( sControlService, m_xContext ); } return xReturn; } @@ -1198,7 +1196,7 @@ namespace pcr xEventManager->revokeScriptEvents( nObjectIndex ); xEventManager->registerScriptEvents( nObjectIndex, aEvents ); - PropertyHandlerHelper::setContextDocumentModified( m_aContext ); + PropertyHandlerHelper::setContextDocumentModified( m_xContext ); } catch( const Exception& ) { diff --git a/extensions/source/propctrlr/eventhandler.hxx b/extensions/source/propctrlr/eventhandler.hxx index 291075611eef..ecb6aa9f5841 100644 --- a/extensions/source/propctrlr/eventhandler.hxx +++ b/extensions/source/propctrlr/eventhandler.hxx @@ -20,7 +20,6 @@ #ifndef EXTENSIONS_SOURCE_PROPCTRLR_EVENTHANDLER_HXX #define EXTENSIONS_SOURCE_PROPCTRLR_EVENTHANDLER_HXX -#include "pcrcomponentcontext.hxx" #include "pcrcommontypes.hxx" #include "pcrcommon.hxx" @@ -29,6 +28,7 @@ #include <com/sun/star/inspection/XPropertyHandler.hpp> #include <com/sun/star/beans/XPropertySet.hpp> #include <com/sun/star/frame/XFrame.hpp> +#include <com/sun/star/uno/XComponentContext.hpp> #include <cppuhelper/compbase2.hxx> #include <comphelper/listenernotification.hxx> @@ -80,7 +80,7 @@ namespace pcr mutable ::osl::Mutex m_aMutex; /// the context in which the instance was created - ComponentContext m_aContext; + ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > m_xContext; /// the properties of the object we're handling ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > m_xComponent; /// our XPropertyChangeListener(s) diff --git a/extensions/source/propctrlr/formcomponenthandler.cxx b/extensions/source/propctrlr/formcomponenthandler.cxx index cf199753581c..cd1311cdb41f 100644 --- a/extensions/source/propctrlr/formcomponenthandler.cxx +++ b/extensions/source/propctrlr/formcomponenthandler.cxx @@ -529,7 +529,7 @@ namespace pcr if ( !sControlValue.isEmpty() ) { - Reference< XDatabaseContext > xDatabaseContext = sdb::DatabaseContext::create( m_aContext.getUNOContext() ); + Reference< XDatabaseContext > xDatabaseContext = sdb::DatabaseContext::create( m_xContext ); if ( !xDatabaseContext->hasByName( sControlValue ) ) { ::svt::OFileNotation aTransformer(sControlValue); @@ -1361,7 +1361,7 @@ namespace pcr ::std::vector< OUString > aListEntries; - Reference< XDatabaseContext > xDatabaseContext = sdb::DatabaseContext::create( m_aContext.getUNOContext() ); + Reference< XDatabaseContext > xDatabaseContext = sdb::DatabaseContext::create( m_xContext ); Sequence< OUString > aDatasources = xDatabaseContext->getElementNames(); aListEntries.resize( aDatasources.getLength() ); ::std::copy( aDatasources.getConstArray(), aDatasources.getConstArray() + aDatasources.getLength(), @@ -2379,7 +2379,7 @@ namespace pcr //------------------------------------------------------------------------ void FormComponentPropertyHandler::impl_displaySQLError_nothrow( const ::dbtools::SQLExceptionInfo& _rErrorDescriptor ) const { - ::dbtools::showError( _rErrorDescriptor, VCLUnoHelper::GetInterface( impl_getDefaultDialogParent_nothrow() ), m_aContext.getUNOContext() ); + ::dbtools::showError( _rErrorDescriptor, VCLUnoHelper::GetInterface( impl_getDefaultDialogParent_nothrow() ), m_xContext ); } //------------------------------------------------------------------------ @@ -2387,7 +2387,9 @@ namespace pcr { if ( !m_xRowSetConnection.is() ) { - uno::Reference<sdbc::XConnection> xConnection(m_aContext.getContextValueByAsciiName( "ActiveConnection" ),uno::UNO_QUERY); + uno::Reference<sdbc::XConnection> xConnection; + Any any = m_xContext->getValueByName( "ActiveConnection" ); + any >>= xConnection; m_xRowSetConnection.reset(xConnection,::dbtools::SharedConnection::NoTakeOwnership); } if ( m_xRowSetConnection.is() ) @@ -2403,7 +2405,7 @@ namespace pcr if ( xRowSetProps.is() ) { WaitCursor aWaitCursor( impl_getDefaultDialogParent_nothrow() ); - m_xRowSetConnection = ::dbtools::ensureRowSetConnection( xRowSet, m_aContext.getUNOContext(), false ); + m_xRowSetConnection = ::dbtools::ensureRowSetConnection( xRowSet, m_xContext, false ); } } catch ( const SQLException& ) { aError = SQLExceptionInfo( ::cppu::getCaughtException() ); } @@ -2621,7 +2623,7 @@ namespace pcr return false; // get a composer for the statement which the form is currently based on - Reference< XSingleSelectQueryComposer > xComposer( ::dbtools::getCurrentSettingsComposer( m_xComponent, m_aContext.getUNOContext() ) ); + Reference< XSingleSelectQueryComposer > xComposer( ::dbtools::getCurrentSettingsComposer( m_xComponent, m_xContext ) ); OSL_ENSURE( xComposer.is(), "FormComponentPropertyHandler::impl_dialogFilterOrSort_nothrow: could not obtain a composer!" ); if ( !xComposer.is() ) return false; @@ -2632,11 +2634,11 @@ namespace pcr Reference< XExecutableDialog > xDialog; if ( _bFilter) { - xDialog.set( sdb::FilterDialog::createDefault(m_aContext.getUNOContext()) ); + xDialog.set( sdb::FilterDialog::createDefault(m_xContext) ); } else { - xDialog.set( sdb::OrderDialog::createDefault(m_aContext.getUNOContext()) ); + xDialog.set( sdb::OrderDialog::createDefault(m_xContext) ); } @@ -2677,7 +2679,7 @@ namespace pcr return false; - FormLinkDialog aDialog( impl_getDefaultDialogParent_nothrow(), m_xComponent, xMasterProp, m_aContext.getUNOContext() ); + FormLinkDialog aDialog( impl_getDefaultDialogParent_nothrow(), m_xComponent, xMasterProp, m_xContext ); _rClearBeforeDialog.clear(); return ( RET_OK == aDialog.Execute() ); } @@ -2803,7 +2805,7 @@ namespace pcr Graphic aGraphic; aFileDlg.GetGraphic( aGraphic ); - Reference< graphic::XGraphicObject > xGrfObj = graphic::GraphicObject::create( m_aContext.getUNOContext() ); + Reference< graphic::XGraphicObject > xGrfObj = graphic::GraphicObject::create( m_xContext ); xGrfObj->setGraphic( aGraphic.GetXGraphic() ); @@ -2933,9 +2935,9 @@ namespace pcr //------------------------------------------------------------------------ Reference< XControlContainer > FormComponentPropertyHandler::impl_getContextControlContainer_nothrow() const { - Reference< XControlContainer > xControlContext( - m_aContext.getContextValueByAsciiName( "ControlContext" ), - UNO_QUERY ); + Reference< XControlContainer > xControlContext; + Any any = m_xContext->getValueByName( "ControlContext" ); + any >>= xControlContext; return xControlContext; } @@ -2949,7 +2951,7 @@ namespace pcr impl_getDefaultDialogParent_nothrow(), xTabControllerModel, impl_getContextControlContainer_nothrow(), - m_aContext.getUNOContext() + m_xContext ); _rClearBeforeDialog.clear(); return ( RET_OK == aDialog.Execute() ); @@ -3202,7 +3204,7 @@ namespace pcr return false; } - m_xCommandDesigner.set( new SQLCommandDesigner( m_aContext.getUNOContext(), xCommandUI.get(), m_xRowSetConnection, LINK( this, FormComponentPropertyHandler, OnDesignerClosed ) ) ); + m_xCommandDesigner.set( new SQLCommandDesigner( m_xContext, xCommandUI.get(), m_xRowSetConnection, LINK( this, FormComponentPropertyHandler, OnDesignerClosed ) ) ); DBG_ASSERT( _rxInspectorUI.is(), "FormComponentPropertyHandler::OnDesignerClosed: no access to the property browser ui!" ); if ( m_xCommandDesigner->isActive() && _rxInspectorUI.is() ) diff --git a/extensions/source/propctrlr/formgeometryhandler.cxx b/extensions/source/propctrlr/formgeometryhandler.cxx index ae513295893f..e08f75bd8522 100644 --- a/extensions/source/propctrlr/formgeometryhandler.cxx +++ b/extensions/source/propctrlr/formgeometryhandler.cxx @@ -296,7 +296,9 @@ namespace pcr Reference< XGridColumnFactory > xCheckGrid( xCompChild->getParent(), UNO_QUERY ); if ( !xCheckGrid.is() ) { - Reference< XMap > xControlMap( m_aContext.getContextValueByAsciiName( "ControlShapeAccess" ), UNO_QUERY_THROW ); + Reference< XMap > xControlMap; + Any any = m_xContext->getValueByName( "ControlShapeAccess" ); + any >>= xControlMap; m_xAssociatedShape.set( xControlMap->get( makeAny( xControlModel ) ), UNO_QUERY_THROW ); m_xShapeProperties.set( m_xAssociatedShape, UNO_QUERY_THROW ); } diff --git a/extensions/source/propctrlr/genericpropertyhandler.cxx b/extensions/source/propctrlr/genericpropertyhandler.cxx index cb9d4704e8c9..d474093b93f3 100644 --- a/extensions/source/propctrlr/genericpropertyhandler.cxx +++ b/extensions/source/propctrlr/genericpropertyhandler.cxx @@ -215,9 +215,9 @@ namespace pcr > UrlClickHandler_Base; class UrlClickHandler : public UrlClickHandler_Base { - ComponentContext m_aContext; + Reference<XComponentContext> m_xContext; public: - UrlClickHandler( const ComponentContext& _rContext, const Reference< XHyperlinkControl >& _rxControl ); + UrlClickHandler( const Reference<XComponentContext>& _rContext, const Reference< XHyperlinkControl >& _rxControl ); protected: ~UrlClickHandler(); @@ -235,8 +235,8 @@ namespace pcr //-------------------------------------------------------------------- DBG_NAME( UrlClickHandler ) //-------------------------------------------------------------------- - UrlClickHandler::UrlClickHandler( const ComponentContext& _rContext, const Reference< XHyperlinkControl >& _rxControl ) - :m_aContext( _rContext ) + UrlClickHandler::UrlClickHandler( const Reference<XComponentContext>& _rContext, const Reference< XHyperlinkControl >& _rxControl ) + :m_xContext( _rContext ) { if ( !_rxControl.is() ) throw NullPointerException(); @@ -282,11 +282,11 @@ namespace pcr //-------------------------------------------------------------------- void UrlClickHandler::impl_dispatch_throw( const OUString& _rURL ) { - Reference< XURLTransformer > xTransformer( URLTransformer::create(m_aContext.getUNOContext()) ); + Reference< XURLTransformer > xTransformer( URLTransformer::create(m_xContext) ); URL aURL; aURL.Complete = OUString( ".uno:OpenHyperlink" ); xTransformer->parseStrict( aURL ); - Reference< XDesktop2 > xDispProv = Desktop::create( m_aContext.getUNOContext() ); + Reference< XDesktop2 > xDispProv = Desktop::create( m_xContext ); Reference< XDispatch > xDispatch( xDispProv->queryDispatch( aURL, OUString(), 0 ), UNO_QUERY_THROW ); Sequence< PropertyValue > aDispatchArgs(1); @@ -303,7 +303,7 @@ namespace pcr //-------------------------------------------------------------------- GenericPropertyHandler::GenericPropertyHandler( const Reference< XComponentContext >& _rxContext ) :GenericPropertyHandler_Base( m_aMutex ) - ,m_aContext( _rxContext ) + ,m_xContext( _rxContext ) ,m_aPropertyListeners( m_aMutex ) ,m_bPropertyMapInitialized( false ) { @@ -376,7 +376,7 @@ namespace pcr m_xPropertyState.clear(); // create an introspection adapter for the component - Reference< XIntrospection > xIntrospection = Introspection::create( m_aContext.getUNOContext() ); + Reference< XIntrospection > xIntrospection = Introspection::create( m_xContext ); Reference< XIntrospectionAccess > xIntrospectionAccess( xIntrospection->inspect( makeAny( _rxIntrospectee ) ) ); if ( !xIntrospectionAccess.is() ) @@ -420,7 +420,7 @@ namespace pcr { ::rtl::Reference< IPropertyEnumRepresentation >& rConverter = m_aEnumConverters[ _rEnumType ]; if ( !rConverter.is() ) - rConverter = new EnumRepresentation( m_aContext.getUNOContext(), _rEnumType ); + rConverter = new EnumRepresentation( m_xContext, _rEnumType ); return rConverter; } @@ -446,7 +446,7 @@ namespace pcr impl_getEnumConverter( pos->second.Type )->getValueFromDescription( sControlValue, aPropertyValue ); } else - aPropertyValue = PropertyHandlerHelper::convertToPropertyValue( m_aContext.getContext(),m_xTypeConverter, pos->second, _rControlValue ); + aPropertyValue = PropertyHandlerHelper::convertToPropertyValue( m_xContext, m_xTypeConverter, pos->second, _rControlValue ); return aPropertyValue; } @@ -471,7 +471,7 @@ namespace pcr aControlValue <<= impl_getEnumConverter( pos->second.Type )->getDescriptionForValue( _rPropertyValue ); } else - aControlValue = PropertyHandlerHelper::convertToControlValue( m_aContext.getContext(),m_xTypeConverter, _rPropertyValue, _rControlValueType ); + aControlValue = PropertyHandlerHelper::convertToControlValue( m_xContext, m_xTypeConverter, _rPropertyValue, _rControlValueType ); return aControlValue; } @@ -656,7 +656,7 @@ namespace pcr PropertyControlType::HyperlinkField, PropertyHandlerHelper::requiresReadOnlyControl( pos->second.Attributes ) ); Reference< XHyperlinkControl > xControl( aDescriptor.Control, UNO_QUERY_THROW ); - Reference< XActionListener > xEnsureDelete( new UrlClickHandler( m_aContext, xControl ) ); + Reference< XActionListener > xEnsureDelete( new UrlClickHandler( m_xContext, xControl ) ); } } break; diff --git a/extensions/source/propctrlr/genericpropertyhandler.hxx b/extensions/source/propctrlr/genericpropertyhandler.hxx index f054a30c1dac..04ed0ff7f57d 100644 --- a/extensions/source/propctrlr/genericpropertyhandler.hxx +++ b/extensions/source/propctrlr/genericpropertyhandler.hxx @@ -23,7 +23,6 @@ #include "propertyhandler.hxx" #include "pcrcommontypes.hxx" #include "pcrcommon.hxx" -#include "pcrcomponentcontext.hxx" #include <com/sun/star/beans/XPropertyState.hpp> #include <com/sun/star/lang/XServiceInfo.hpp> @@ -61,7 +60,7 @@ namespace pcr private: /// the service factory for creating services - ComponentContext m_aContext; + ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > m_xContext; /// need this to keep alive as long as m_xComponent lives ::com::sun::star::uno::Reference< ::com::sun::star::beans::XIntrospectionAccess > m_xComponentIntrospectionAccess; /// the properties of the object we're handling diff --git a/extensions/source/propctrlr/handlerhelper.cxx b/extensions/source/propctrlr/handlerhelper.cxx index 8561f818d6d6..7a257bc6ae57 100644 --- a/extensions/source/propctrlr/handlerhelper.cxx +++ b/extensions/source/propctrlr/handlerhelper.cxx @@ -24,7 +24,6 @@ #include "modulepcr.hxx" #include "enumrepresentation.hxx" #include "formmetadata.hxx" -#include "pcrcomponentcontext.hxx" #include "com/sun/star/inspection/StringRepresentation.hpp" #include <com/sun/star/beans/PropertyAttribute.hpp> @@ -241,11 +240,11 @@ namespace pcr } //-------------------------------------------------------------------- - void PropertyHandlerHelper::setContextDocumentModified( const ComponentContext& _rContext ) + void PropertyHandlerHelper::setContextDocumentModified( const Reference<XComponentContext> & _rContext ) { try { - Reference< XModifiable > xDocumentModifiable( _rContext.getContextValueByAsciiName( "ContextDocument" ), UNO_QUERY_THROW ); + Reference< XModifiable > xDocumentModifiable( getContextDocument_throw(_rContext), UNO_QUERY_THROW ); xDocumentModifiable->setModified( sal_True ); } catch( const Exception& ) @@ -254,13 +253,35 @@ namespace pcr } } + Reference< XInterface > PropertyHandlerHelper::getContextDocument( const Reference<XComponentContext> & _rContext ) + { + Reference< XInterface > xI; + try + { + xI = getContextDocument_throw( _rContext ); + } + catch( const Exception& ) + { + OSL_FAIL( "PropertyHandler::getContextValueByName: caught an exception!" ); + } + return xI; + } + + Reference< XInterface > PropertyHandlerHelper::getContextDocument_throw( const Reference<XComponentContext> & _rContext ) throw (RuntimeException) + { + Reference< XInterface > xI; + Any aReturn = _rContext->getValueByName( "ContextDocument" ); + aReturn >>= xI; + return xI; + } + //-------------------------------------------------------------------- - Window* PropertyHandlerHelper::getDialogParentWindow( const ComponentContext& _rContext ) + Window* PropertyHandlerHelper::getDialogParentWindow( const Reference<XComponentContext>& _rContext ) { Window* pInspectorWindow = NULL; try { - Reference< XWindow > xInspectorWindow( _rContext.getContextValueByAsciiName( "DialogParentWindow" ), UNO_QUERY_THROW ); + Reference< XWindow > xInspectorWindow( _rContext->getValueByName( "DialogParentWindow" ), UNO_QUERY_THROW ); pInspectorWindow = VCLUnoHelper::GetWindow( xInspectorWindow ); } catch( const Exception& ) diff --git a/extensions/source/propctrlr/handlerhelper.hxx b/extensions/source/propctrlr/handlerhelper.hxx index b9a1d1aff5c9..30182fa1ea9e 100644 --- a/extensions/source/propctrlr/handlerhelper.hxx +++ b/extensions/source/propctrlr/handlerhelper.hxx @@ -41,8 +41,6 @@ namespace pcr { //........................................................................ - class ComponentContext; - //==================================================================== //= PropertyHandlerHelper //==================================================================== @@ -166,9 +164,13 @@ namespace pcr the component context which was used to create the component calling this method */ static void setContextDocumentModified( - const ComponentContext& _rContext + const css::uno::Reference< css::uno::XComponentContext > & _rContext ); + static css::uno::Reference< css::uno::XInterface > getContextDocument( const css::uno::Reference<css::uno::XComponentContext> & _rContext ); + + static css::uno::Reference< css::uno::XInterface > getContextDocument_throw( const css::uno::Reference<css::uno::XComponentContext> & _rContext ) throw (css::uno::RuntimeException); + /** gets the window of the ObjectInspector in which an property handler lives The method looks up a value called "DialogParentWindow" in the given UNO copmonent context, @@ -178,7 +180,7 @@ namespace pcr @param _rContext the component context which was used to create the component calling this method */ - static Window* getDialogParentWindow( const ComponentContext& _rContext ); + static Window* getDialogParentWindow( const css::uno::Reference< css::uno::XComponentContext > & _rContext ); /** determines whether given PropertyAttributes require a to-be-created diff --git a/extensions/source/propctrlr/pcrcomponentcontext.cxx b/extensions/source/propctrlr/pcrcomponentcontext.cxx deleted file mode 100644 index 95af777606c0..000000000000 --- a/extensions/source/propctrlr/pcrcomponentcontext.cxx +++ /dev/null @@ -1,93 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -#include "pcrcomponentcontext.hxx" - -#include <com/sun/star/lang/NullPointerException.hpp> -#include <com/sun/star/lang/ServiceNotRegisteredException.hpp> -#include <com/sun/star/beans/XPropertySet.hpp> - -//........................................................................ -namespace pcr -{ -//........................................................................ - - using ::com::sun::star::uno::Reference; - using ::com::sun::star::uno::XComponentContext; - using ::com::sun::star::lang::NullPointerException; - using ::com::sun::star::lang::ServiceNotRegisteredException; - using ::com::sun::star::uno::Exception; - using ::com::sun::star::uno::Any; - using ::com::sun::star::uno::XInterface; - using ::com::sun::star::uno::UNO_QUERY_THROW; - using ::com::sun::star::lang::XMultiServiceFactory; - using ::com::sun::star::beans::XPropertySet; - using ::com::sun::star::uno::UNO_QUERY; - using ::com::sun::star::uno::RuntimeException; - - //==================================================================== - //= ComponentContext - //==================================================================== - //-------------------------------------------------------------------- - ComponentContext::ComponentContext( const Reference< XComponentContext >& _rxContext ) - :m_xContext( _rxContext ) - { - if ( m_xContext.is() ) - m_xORB = m_xContext->getServiceManager(); - if ( !m_xORB.is() ) - throw NullPointerException(); - } - - //------------------------------------------------------------------------ - Any ComponentContext::getContextValueByName( const OUString& _rName ) const - { - Any aReturn; - try - { - aReturn = m_xContext->getValueByName( _rName ); - } - catch( const Exception& ) - { - OSL_FAIL( "PropertyHandler::getContextValueByName: caught an exception!" ); - } - return aReturn; - } - - //------------------------------------------------------------------------ - Reference< XInterface > ComponentContext::createComponent( const OUString& _rServiceName ) const - { - Reference< XInterface > xComponent( - m_xORB->createInstanceWithContext( _rServiceName, m_xContext ) - ); - if ( !xComponent.is() ) - throw ServiceNotRegisteredException( _rServiceName, NULL ); - return xComponent; - } - - //------------------------------------------------------------------------ - Reference< XMultiServiceFactory > ComponentContext::getLegacyServiceFactory() const - { - return Reference< XMultiServiceFactory >( m_xORB, UNO_QUERY_THROW ); - } - -//........................................................................ -} // namespace pcr -//........................................................................ - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/extensions/source/propctrlr/pcrcomponentcontext.hxx b/extensions/source/propctrlr/pcrcomponentcontext.hxx deleted file mode 100644 index e26a675e6d1b..000000000000 --- a/extensions/source/propctrlr/pcrcomponentcontext.hxx +++ /dev/null @@ -1,159 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -#ifndef EXTENSIONS_SOURCE_PROPCTRLR_PCROMPONENTCONTEXT_HXX -#define EXTENSIONS_SOURCE_PROPCTRLR_PCROMPONENTCONTEXT_HXX - -#include <com/sun/star/uno/XComponentContext.hpp> -#include <com/sun/star/lang/XMultiServiceFactory.hpp> - -//........................................................................ -namespace pcr -{ -//........................................................................ - - //==================================================================== - //= ComponentContext - //==================================================================== - /** a helper class for working with a component context - */ - class ComponentContext - { - private: - ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > m_xContext; - ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiComponentFactory > m_xORB; - - public: - /** constructs an instance - @param _rxContext - the component context to manage - @throws ::com::sun::star::lang::NullPointerException - if the given context, or its component factory, are <NULL/> - */ - ComponentContext( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& _rxContext ); - - /** returns the ->XComponentContext interface - */ - inline ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > - getUNOContext() const { return m_xContext; } - - /** determines whether the context is not <NULL/> - */ - inline sal_Bool is() const - { - return m_xContext.is(); - } - - /** creates a component using our component factory/context - @throws ::com::sun::star::uno::Exception - @return - <TRUE/> if and only if the component could be successfully created - */ - template < class INTERFACE > - bool createComponent( const OUString& _rServiceName, ::com::sun::star::uno::Reference< INTERFACE >& _out_rxComponent ) const - { - _out_rxComponent.clear(); - _out_rxComponent = _out_rxComponent.query( - m_xORB->createInstanceWithContext( _rServiceName, m_xContext ) - ); - return _out_rxComponent.is(); - } - - /** creates a component using our component factory/context - @throws ::com::sun::star::uno::Exception - @return - <TRUE/> if and only if the component could be successfully created - */ - template < class INTERFACE > - bool createComponent( const sal_Char* _pAsciiServiceName, ::com::sun::star::uno::Reference< INTERFACE >& _out_rxComponent ) const - { - return createComponent( OUString::createFromAscii( _pAsciiServiceName ), _out_rxComponent ); - } - - /** creates a component using our component factory/context - - @throws ::com::sun::star::lang::ServiceNotRegisteredException - if the given service is not registered - @throws Exception - if an exception occurred during creating the component - @return - the newly created component. Is never <NULL/>. - */ - ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > createComponent( const OUString& _rServiceName ) const; - - /** creates a component using our component factory/context - - @throws ::com::sun::star::lang::ServiceNotRegisteredException - if the given service is not registered - @throws Exception - if an exception occurred during creating the component - @return - the newly created component. Is never <NULL/>. - */ - ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > createComponent( const sal_Char* _pAsciiServiceName ) const - { - return createComponent( OUString::createFromAscii( _pAsciiServiceName ) ); - } - - /** returns the ->XMultiServiceFactory interface of ->m_xORB, for passing to - older code which does not yet support ->XMultiComponentFactory - @throws ::com::sun::star::uno::RuntimeException - if our our component factory does not support this interface - */ - ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > - getLegacyServiceFactory() const; - - /** retrieves a value from our component context - @param _rName - the name of the value to retrieve - @return - the context value with the given name - @seealso XComponentContext::getValueByName - @seealso getContextValueByAsciiName - */ - ::com::sun::star::uno::Any - getContextValueByName( const OUString& _rName ) const; - - /** retrieves a value from our component context, specified by 8-bit ASCII string - @param _rName - the name of the value to retrieve, as ASCII character string - @return - the context value with the given name - @seealso XComponentContext::getValueByName - @seealso getContextValueByName - */ - inline ::com::sun::star::uno::Any - getContextValueByAsciiName( const sal_Char* _pAsciiName ) const - { - return getContextValueByName( OUString::createFromAscii( _pAsciiName ) ); - } - - /** retrieve context to create interfaces by the ctors - */ - ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > getContext() const { return m_xContext;} - - }; - -//........................................................................ -} // namespace pcr -//........................................................................ - -#endif // EXTENSIONS_SOURCE_PROPCTRLR_PCROMPONENTCONTEXT_HXX - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/extensions/source/propctrlr/propcontroller.cxx b/extensions/source/propctrlr/propcontroller.cxx index 6c628a1c8250..312e6e25a8d5 100644 --- a/extensions/source/propctrlr/propcontroller.cxx +++ b/extensions/source/propctrlr/propcontroller.cxx @@ -83,7 +83,7 @@ namespace pcr DBG_NAME(OPropertyBrowserController) //------------------------------------------------------------------------ OPropertyBrowserController::OPropertyBrowserController( const Reference< XComponentContext >& _rxContext ) - :m_aContext(_rxContext) + :m_xContext(_rxContext) ,m_aDisposeListeners( m_aMutex ) ,m_aControlObservers( m_aMutex ) ,m_pView(NULL) @@ -708,7 +708,7 @@ namespace pcr DBG_ASSERT(!haveView(), "OPropertyBrowserController::Construct: already have a view!"); DBG_ASSERT(_pParentWin, "OPropertyBrowserController::Construct: invalid parent window!"); - m_pView = new OPropertyBrowserView(m_aContext.getLegacyServiceFactory(), _pParentWin); + m_pView = new OPropertyBrowserView(_pParentWin); m_pView->setPageActivationHandler(LINK(this, OPropertyBrowserController, OnPageActivation)); // add as dispose listener for our view. The view is disposed by the frame we're plugged into, @@ -1450,7 +1450,7 @@ namespace pcr //------------------------------------------------------------------------ namespace { - Reference< XPropertyHandler > lcl_createHandler( const ComponentContext& _rContext, const Any& _rFactoryDescriptor ) + Reference< XPropertyHandler > lcl_createHandler( const Reference<XComponentContext>& _rContext, const Any& _rFactoryDescriptor ) { Reference< XPropertyHandler > xHandler; @@ -1459,11 +1459,11 @@ namespace pcr Reference< XSingleComponentFactory > xComponentFac; if ( _rFactoryDescriptor >>= sServiceName ) - _rContext.createComponent( sServiceName, xHandler ); + xHandler.set( _rContext->getServiceManager()->createInstanceWithContext( sServiceName, _rContext ), UNO_QUERY ); else if ( _rFactoryDescriptor >>= xServiceFac ) xHandler = xHandler.query( xServiceFac->createInstance() ); else if ( _rFactoryDescriptor >>= xComponentFac ) - xHandler = xHandler.query( xComponentFac->createInstanceWithContext( _rContext.getUNOContext() ) ); + xHandler = xHandler.query( xComponentFac->createInstanceWithContext( _rContext ) ); OSL_ENSURE(xHandler.is(),"lcl_createHandler: Can not create handler"); return xHandler; } @@ -1478,10 +1478,12 @@ namespace pcr // create a component context for the handlers, containing some information about where // they live - Reference< XComponentContext > xHandlerContext( m_aContext.getUNOContext() ); + Reference< XComponentContext > xHandlerContext( m_xContext ); // if our own creator did not pass a dialog parent window, use our own view for this - Reference< XWindow > xParentWindow( m_aContext.getContextValueByAsciiName( "DialogParentWindow" ), UNO_QUERY ); + Reference< XWindow > xParentWindow; + Any any = m_xContext->getValueByName( "DialogParentWindow" ); + any >>= xParentWindow; if ( !xParentWindow.is() ) { ::cppu::ContextEntry_Init aHandlerContextInfo[] = @@ -1490,7 +1492,7 @@ namespace pcr }; xHandlerContext = ::cppu::createComponentContext( aHandlerContextInfo, SAL_N_ELEMENTS( aHandlerContextInfo ), - m_aContext.getUNOContext() ); + m_xContext ); } Sequence< Any > aHandlerFactories; @@ -1504,7 +1506,7 @@ namespace pcr { if ( _rObjects.size() == 1 ) { // we're inspecting only one object -> one handler - Reference< XPropertyHandler > xHandler( lcl_createHandler( m_aContext, *pHandlerFactory ) ); + Reference< XPropertyHandler > xHandler( lcl_createHandler( m_xContext, *pHandlerFactory ) ); if ( xHandler.is() ) { xHandler->inspect( _rObjects[0] ); @@ -1522,7 +1524,7 @@ namespace pcr for ( ; pObject != pObjectEnd; ++pObject ) { - *pHandler = lcl_createHandler( m_aContext, *pHandlerFactory ); + *pHandler = lcl_createHandler( m_xContext, *pHandlerFactory ); if ( pHandler->is() ) { (*pHandler)->inspect( *pObject ); diff --git a/extensions/source/propctrlr/propcontroller.hxx b/extensions/source/propctrlr/propcontroller.hxx index 0aaf5356b834..49d5fc98811b 100644 --- a/extensions/source/propctrlr/propcontroller.hxx +++ b/extensions/source/propctrlr/propcontroller.hxx @@ -28,7 +28,6 @@ #include "browserview.hxx" #include "modulepcr.hxx" #include "propertyinfo.hxx" -#include "pcrcomponentcontext.hxx" #include <com/sun/star/awt/XFocusListener.hpp> #include <com/sun/star/beans/XPropertyState.hpp> @@ -106,7 +105,7 @@ namespace pcr InterfaceArray; protected: - ComponentContext m_aContext; + ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > m_xContext; private: ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame > m_xFrame; diff --git a/extensions/source/propctrlr/propertyhandler.cxx b/extensions/source/propctrlr/propertyhandler.cxx index d6c0649af8d6..78359d4659cc 100644 --- a/extensions/source/propctrlr/propertyhandler.cxx +++ b/extensions/source/propctrlr/propertyhandler.cxx @@ -60,7 +60,7 @@ namespace pcr :PropertyHandler_Base( m_aMutex ) ,m_bSupportedPropertiesAreKnown( false ) ,m_aPropertyListeners( m_aMutex ) - ,m_aContext( _rxContext ) + ,m_xContext( _rxContext ) ,m_pInfoService ( new OPropertyInfoService ) { DBG_CTOR( PropertyHandler, NULL ); @@ -163,7 +163,7 @@ namespace pcr } else aPropertyValue = PropertyHandlerHelper::convertToPropertyValue( - m_aContext.getContext(),m_xTypeConverter, aProperty, _rControlValue ); + m_xContext, m_xTypeConverter, aProperty, _rControlValue ); return aPropertyValue; } @@ -184,7 +184,7 @@ namespace pcr } return PropertyHandlerHelper::convertToControlValue( - m_aContext.getContext(),m_xTypeConverter, _rPropertyValue, _rControlValueType ); + m_xContext, m_xTypeConverter, _rPropertyValue, _rControlValueType ); } //-------------------------------------------------------------------- @@ -339,7 +339,7 @@ namespace pcr //------------------------------------------------------------------------ Window* PropertyHandler::impl_getDefaultDialogParent_nothrow() const { - return PropertyHandlerHelper::getDialogParentWindow( m_aContext ); + return PropertyHandlerHelper::getDialogParentWindow( m_xContext ); } //------------------------------------------------------------------------ @@ -407,7 +407,7 @@ namespace pcr if ( !(sConfigurationLocation.isEmpty() || sConfigurationProperty.isEmpty()) ) { ::utl::OConfigurationTreeRoot aConfigTree( ::utl::OConfigurationTreeRoot::createWithComponentContext( - m_aContext.getUNOContext(), sConfigurationLocation, -1, ::utl::OConfigurationTreeRoot::CM_READONLY ) ); + m_xContext, sConfigurationLocation, -1, ::utl::OConfigurationTreeRoot::CM_READONLY ) ); sal_Int32 nUnitAsInt = (sal_Int32)FUNIT_NONE; aConfigTree.getNodeValue( sConfigurationProperty ) >>= nUnitAsInt; diff --git a/extensions/source/propctrlr/propertyhandler.hxx b/extensions/source/propctrlr/propertyhandler.hxx index cfdee15f9b7a..35a7c0c1dbba 100644 --- a/extensions/source/propctrlr/propertyhandler.hxx +++ b/extensions/source/propctrlr/propertyhandler.hxx @@ -20,7 +20,6 @@ #ifndef EXTENSIONS_SOURCE_PROPCTRLR_PROPERTYHANDLER_HXX #define EXTENSIONS_SOURCE_PROPCTRLR_PROPERTYHANDLER_HXX -#include "pcrcomponentcontext.hxx" #include "pcrcommon.hxx" #include "modulepcr.hxx" @@ -87,7 +86,7 @@ namespace pcr protected: mutable ::osl::Mutex m_aMutex; /// the context in which the instance was created - ComponentContext m_aContext; + ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > m_xContext; /// the component we're inspecting ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > m_xComponent; /// info about our component's properties @@ -271,7 +270,7 @@ namespace pcr impl_getContextDocument_nothrow() const { return ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel >( - m_aContext.getContextValueByAsciiName( "ContextDocument" ), ::com::sun::star::uno::UNO_QUERY ); + m_xContext->getValueByName( "ContextDocument" ), ::com::sun::star::uno::UNO_QUERY ); } /** marks the context document as modified |