diff options
author | Noel Grandin <noel@peralex.com> | 2013-05-16 14:13:36 +0200 |
---|---|---|
committer | Noel Grandin <noel@peralex.com> | 2013-05-21 08:23:58 +0200 |
commit | 6c61b20a8d4a6dcac28801cde82a211fb7e30654 (patch) | |
tree | d82328eaa120b8bc822f028fa1e62bc7814c9e1b /scripting | |
parent | 6c53dff36ebdac7b6a6cf514ab469b2202d6aa48 (diff) |
fdo#46808, Convert awt::UnoControlDialogModel to new style
Change-Id: I4b912034ef3f4855b87d6d6f18ff13bd1ecc8f72
Diffstat (limited to 'scripting')
-rw-r--r-- | scripting/source/dlgprov/DialogModelProvider.cxx | 9 | ||||
-rw-r--r-- | scripting/source/dlgprov/DialogModelProvider.hxx | 7 | ||||
-rw-r--r-- | scripting/source/dlgprov/dlgprov.cxx | 45 | ||||
-rw-r--r-- | scripting/source/dlgprov/dlgprov.hxx | 21 |
4 files changed, 33 insertions, 49 deletions
diff --git a/scripting/source/dlgprov/DialogModelProvider.cxx b/scripting/source/dlgprov/DialogModelProvider.cxx index aee0a9a16ec5..b7b5de3da34e 100644 --- a/scripting/source/dlgprov/DialogModelProvider.cxx +++ b/scripting/source/dlgprov/DialogModelProvider.cxx @@ -76,12 +76,9 @@ void SAL_CALL DialogModelProvider::initialize(const css::uno::Sequence< uno::Any if ( xInput.is() ) { xStringResourceManager = dlgprov::lcl_getStringResourceManager(m_xContext,sURL); - Any aDialogSourceURLAny; - aDialogSourceURLAny <<= sURL; Reference< frame::XModel > xModel; - m_xDialogModel.set( dlgprov::lcl_createDialogModel( m_xContext, xInput , xModel, xStringResourceManager, aDialogSourceURLAny ), UNO_QUERY_THROW); - m_xDialogModelProp.set(m_xDialogModel, UNO_QUERY_THROW); + m_xDialogModel = dlgprov::lcl_createDialogModel( m_xContext, xInput , xModel, xStringResourceManager, sURL ); } } catch( Exception& ) @@ -135,14 +132,14 @@ void SAL_CALL DialogModelProvider::removeByName(const OUString & aName) throw (c } uno::Reference< beans::XPropertySetInfo > SAL_CALL DialogModelProvider::getPropertySetInfo( ) throw (uno::RuntimeException) { - return m_xDialogModelProp->getPropertySetInfo(); + return m_xDialogModel->getPropertySetInfo(); } void SAL_CALL DialogModelProvider::setPropertyValue( const OUString&, const uno::Any& ) throw (beans::UnknownPropertyException, beans::PropertyVetoException, lang::IllegalArgumentException, lang::WrappedTargetException, uno::RuntimeException) { } uno::Any SAL_CALL DialogModelProvider::getPropertyValue( const OUString& PropertyName ) throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) { - return m_xDialogModelProp->getPropertyValue(PropertyName); + return m_xDialogModel->getPropertyValue(PropertyName); } void SAL_CALL DialogModelProvider::addPropertyChangeListener( const OUString& , const uno::Reference< beans::XPropertyChangeListener >& ) throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) { diff --git a/scripting/source/dlgprov/DialogModelProvider.hxx b/scripting/source/dlgprov/DialogModelProvider.hxx index 4d9256a35f14..b104614948c5 100644 --- a/scripting/source/dlgprov/DialogModelProvider.hxx +++ b/scripting/source/dlgprov/DialogModelProvider.hxx @@ -23,6 +23,8 @@ #include "com/sun/star/container/XNameContainer.hpp" #include "com/sun/star/lang/XServiceInfo.hpp" #include "com/sun/star/beans/XPropertySet.hpp" +#include "com/sun/star/awt/XUnoControlDialogModel.hpp" + /// anonymous implementation namespace namespace dlgprov{ @@ -75,9 +77,8 @@ private: // destructor is private and will be called indirectly by the release call virtual ~DialogModelProvider() {} - css::uno::Reference< css::uno::XComponentContext > m_xContext; - css::uno::Reference< css::container::XNameContainer> m_xDialogModel; - css::uno::Reference< css::beans::XPropertySet> m_xDialogModelProp; + css::uno::Reference< css::uno::XComponentContext > m_xContext; + css::uno::Reference< css::awt::XUnoControlDialogModel> m_xDialogModel; }; } // closing anonymous implementation namespace diff --git a/scripting/source/dlgprov/dlgprov.cxx b/scripting/source/dlgprov/dlgprov.cxx index 2be567db31c8..ea0856e95759 100644 --- a/scripting/source/dlgprov/dlgprov.cxx +++ b/scripting/source/dlgprov/dlgprov.cxx @@ -21,6 +21,7 @@ #include "DialogModelProvider.hxx" #include "dlgprov.hxx" #include "dlgevtatt.hxx" +#include <com/sun/star/awt/UnoControlDialogModel.hpp> #include <com/sun/star/awt/Toolkit.hpp> #include <com/sun/star/awt/XControlContainer.hpp> #include <com/sun/star/awt/XWindowPeer.hpp> @@ -86,8 +87,6 @@ namespace dlgprov { //......................................................................... -static OUString aResourceResolverPropName("ResourceResolver"); - Reference< resource::XStringResourceManager > lcl_getStringResourceManager(const Reference< XComponentContext >& i_xContext,const OUString& i_sURL) { INetURLObject aInetObj( i_sURL ); @@ -120,23 +119,20 @@ static OUString aResourceResolverPropName("ResourceResolver"); } return xStringResourceManager; } - Reference< container::XNameContainer > lcl_createControlModel(const Reference< XComponentContext >& i_xContext) + static Reference< XUnoControlDialogModel > lcl_createControlModel(const Reference< XComponentContext >& i_xContext) { - Reference< XMultiComponentFactory > xSMgr_( i_xContext->getServiceManager(), UNO_QUERY_THROW ); - Reference< container::XNameContainer > xControlModel( xSMgr_->createInstanceWithContext( OUString( "com.sun.star.awt.UnoControlDialogModel" ), i_xContext ), UNO_QUERY_THROW ); + Reference< XUnoControlDialogModel > xControlModel = UnoControlDialogModel::create( i_xContext ); return xControlModel; } - Reference< container::XNameContainer > lcl_createDialogModel( const Reference< XComponentContext >& i_xContext, + Reference< XUnoControlDialogModel > lcl_createDialogModel( const Reference< XComponentContext >& i_xContext, const Reference< io::XInputStream >& xInput, const Reference< frame::XModel >& xModel, const Reference< resource::XStringResourceManager >& xStringResourceManager, - const Any &aDialogSourceURL) throw ( Exception ) + const OUString& aDialogSourceURL) throw ( Exception ) { - Reference< container::XNameContainer > xDialogModel( lcl_createControlModel(i_xContext) ); + Reference< XUnoControlDialogModel > xDialogModel( lcl_createControlModel(i_xContext) ); - OUString aDlgSrcUrlPropName( "DialogSourceURL" ); - Reference< beans::XPropertySet > xDlgPropSet( xDialogModel, UNO_QUERY ); - xDlgPropSet->setPropertyValue( aDlgSrcUrlPropName, aDialogSourceURL ); + xDialogModel->setDialogSourceURL( aDialogSourceURL ); // #TODO we really need to detect the source of the Dialog, is it // the dialog. E.g. if the dialog was created from basic ( then we just @@ -150,10 +146,7 @@ static OUString aResourceResolverPropName("ResourceResolver"); // Set resource property if( xStringResourceManager.is() ) { - Reference< beans::XPropertySet > xDlgPSet( xDialogModel, UNO_QUERY ); - Any aStringResourceManagerAny; - aStringResourceManagerAny <<= xStringResourceManager; - xDlgPSet->setPropertyValue( aResourceResolverPropName, aStringResourceManagerAny ); + xDialogModel->setResourceResolver( xStringResourceManager ); } return xDialogModel; @@ -255,15 +248,15 @@ static OUString aResourceResolverPropName("ResourceResolver"); return xStringResourceManager; } - Reference< container::XNameContainer > DialogProviderImpl::createDialogModel( + Reference< XUnoControlDialogModel > DialogProviderImpl::createDialogModel( const Reference< io::XInputStream >& xInput, const Reference< resource::XStringResourceManager >& xStringResourceManager, - const Any &aDialogSourceURL) throw ( Exception ) + const OUString &aDialogSourceURL) throw ( Exception ) { return lcl_createDialogModel(m_xContext,xInput,m_xModel,xStringResourceManager,aDialogSourceURL); } - Reference< XControlModel > DialogProviderImpl::createDialogModelForBasic() throw ( Exception ) + Reference< XUnoControlDialogModel > DialogProviderImpl::createDialogModelForBasic() throw ( Exception ) { if ( !m_BasicInfo.get() ) // shouln't get here @@ -271,13 +264,10 @@ static OUString aResourceResolverPropName("ResourceResolver"); Reference< resource::XStringResourceManager > xStringResourceManager = getStringResourceFromDialogLibrary( m_BasicInfo->mxDlgLib ); OUString aURL("" ); - Any aDialogSourceURL; - aDialogSourceURL <<= aURL; - Reference< XControlModel > xCtrlModel( createDialogModel( m_BasicInfo->mxInput, xStringResourceManager, aDialogSourceURL ), UNO_QUERY_THROW ); - return xCtrlModel; + return createDialogModel( m_BasicInfo->mxInput, xStringResourceManager, aURL ); } - Reference< XControlModel > DialogProviderImpl::createDialogModel( const OUString& sURL ) + Reference< XUnoControlDialogModel > DialogProviderImpl::createDialogModel( const OUString& sURL ) { OUString aURL( sURL ); @@ -447,7 +437,7 @@ static OUString aResourceResolverPropName("ResourceResolver"); } // import dialog model - Reference< XControlModel > xCtrlModel; + Reference< XUnoControlDialogModel > xCtrlModel; if ( xInput.is() && m_xContext.is() ) { Reference< resource::XStringResourceManager > xStringResourceManager; @@ -460,12 +450,7 @@ static OUString aResourceResolverPropName("ResourceResolver"); xStringResourceManager = getStringResourceFromDialogLibrary( xDialogLib ); } - Any aDialogSourceURLAny; - aDialogSourceURLAny <<= aURL; - - Reference< container::XNameContainer > xDialogModel( createDialogModel( xInput , xStringResourceManager, aDialogSourceURLAny ), UNO_QUERY_THROW); - - xCtrlModel = Reference< XControlModel >( xDialogModel, UNO_QUERY ); + xCtrlModel = createDialogModel( xInput , xStringResourceManager, aURL ); } return xCtrlModel; } diff --git a/scripting/source/dlgprov/dlgprov.hxx b/scripting/source/dlgprov/dlgprov.hxx index 651edfa32cb0..a515b9448e9f 100644 --- a/scripting/source/dlgprov/dlgprov.hxx +++ b/scripting/source/dlgprov/dlgprov.hxx @@ -21,9 +21,10 @@ #define SCRIPTING_DLGPROV_HXX #include <com/sun/star/awt/XControl.hpp> +#include <com/sun/star/awt/XContainerWindowProvider.hpp> #include <com/sun/star/awt/XDialog.hpp> #include <com/sun/star/awt/XDialogProvider2.hpp> -#include <com/sun/star/awt/XContainerWindowProvider.hpp> +#include <com/sun/star/awt/XUnoControlDialogModel.hpp> #include <com/sun/star/frame/XModel.hpp> #include <com/sun/star/lang/XServiceInfo.hpp> #include <com/sun/star/lang/XInitialization.hpp> @@ -53,14 +54,14 @@ namespace dlgprov // ============================================================================= // class DialogProviderImpl // ============================================================================= - ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer > lcl_createControlModel(const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& i_xContext); - ::com::sun::star::uno::Reference< ::com::sun::star::resource::XStringResourceManager > lcl_getStringResourceManager(const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& i_xContext,const OUString& i_sURL); - ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer > lcl_createDialogModel( + ::com::sun::star::uno::Reference< ::com::sun::star::resource::XStringResourceManager > lcl_getStringResourceManager(const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& i_xContext,const OUString& i_sURL);; + + ::com::sun::star::uno::Reference< ::com::sun::star::awt::XUnoControlDialogModel > lcl_createDialogModel( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& i_xContext, const ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream >& xInput, const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel >& xModel, const ::com::sun::star::uno::Reference< ::com::sun::star::resource::XStringResourceManager >& xStringResourceManager, - const ::com::sun::star::uno::Any &aDialogSourceURL) throw ( ::com::sun::star::uno::Exception ); + const OUString& aDialogSourceURL) throw ( ::com::sun::star::uno::Exception ); typedef ::cppu::WeakImplHelper4< ::com::sun::star::lang::XServiceInfo, @@ -80,9 +81,9 @@ namespace dlgprov std::auto_ptr< BasicRTLParams > m_BasicInfo; ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > m_xContext; ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel > m_xModel; + OUString msDialogLibName; - OUString msDialogLibName; - ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlModel > createDialogModel( const OUString& sURL ); + ::com::sun::star::uno::Reference< ::com::sun::star::awt::XUnoControlDialogModel > createDialogModel( const OUString& sURL ); ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControl > createDialogControl( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlModel >& rxDialogModel, @@ -95,11 +96,11 @@ namespace dlgprov ::com::sun::star::uno::Reference< ::com::sun::star::beans::XIntrospectionAccess > inspectHandler( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& rxHandler ); // helper methods - ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer > createDialogModel( + ::com::sun::star::uno::Reference< ::com::sun::star::awt::XUnoControlDialogModel > createDialogModel( const ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream >& xInput, const ::com::sun::star::uno::Reference< ::com::sun::star::resource::XStringResourceManager >& xStringResourceManager, - const ::com::sun::star::uno::Any &aDialogSourceURL) throw ( ::com::sun::star::uno::Exception ); - ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlModel > createDialogModelForBasic() throw ( ::com::sun::star::uno::Exception ); + const OUString &aDialogSourceURL) throw ( ::com::sun::star::uno::Exception ); + ::com::sun::star::uno::Reference< ::com::sun::star::awt::XUnoControlDialogModel > createDialogModelForBasic() throw ( ::com::sun::star::uno::Exception ); // XDialogProvider / XDialogProvider2 impl method virtual ::com::sun::star::uno::Reference < ::com::sun::star::awt::XControl > SAL_CALL createDialogImpl( |