From d08578912f2c9ef42d4349079422e25b951e544e Mon Sep 17 00:00:00 2001 From: Noel Grandin Date: Tue, 29 May 2012 17:17:28 +0200 Subject: fdo#46808, Adapt UNO services to new style, Part 7, updating ::create Update calls to factories to use new SimpleFileAccess::create method Change-Id: Ie5b0696fe2228a9033b19969245a53c21a61aa14 Signed-off-by: Stephan Bergmann , added some tweaks. --- .../FilterDevelopment/FlatXmlFilterDetection/fdcomp.cxx | 8 ++++---- .../FlatXmlFilterDetection/filterdetect.cxx | 14 +++++++------- .../FlatXmlFilterDetection/filterdetect.hxx | 12 ++++++++---- 3 files changed, 19 insertions(+), 15 deletions(-) (limited to 'odk') diff --git a/odk/examples/DevelopersGuide/OfficeDev/FilterDevelopment/FlatXmlFilterDetection/fdcomp.cxx b/odk/examples/DevelopersGuide/OfficeDev/FilterDevelopment/FlatXmlFilterDetection/fdcomp.cxx index 1bb950952392..e6b78850c65d 100644 --- a/odk/examples/DevelopersGuide/OfficeDev/FilterDevelopment/FlatXmlFilterDetection/fdcomp.cxx +++ b/odk/examples/DevelopersGuide/OfficeDev/FilterDevelopment/FlatXmlFilterDetection/fdcomp.cxx @@ -38,7 +38,7 @@ #include #include #include -#include +#include #include "filterdetect.hxx" @@ -58,10 +58,10 @@ SAL_DLLPUBLIC_EXPORT void * SAL_CALL component_getFactory( OUString implName = OUString::createFromAscii( pImplName ); if ( pServiceManager && implName.equals(FilterDetect_getImplementationName()) ) { - Reference< XSingleServiceFactory > xFactory( createSingleFactory( - reinterpret_cast< XMultiServiceFactory * >( pServiceManager ), + Reference< XSingleComponentFactory > xFactory( createSingleComponentFactory( + FilterDetect_createInstance, OUString::createFromAscii( pImplName ), - FilterDetect_createInstance, FilterDetect_getSupportedServiceNames() ) ); + FilterDetect_getSupportedServiceNames() ) ); if (xFactory.is()) { diff --git a/odk/examples/DevelopersGuide/OfficeDev/FilterDevelopment/FlatXmlFilterDetection/filterdetect.cxx b/odk/examples/DevelopersGuide/OfficeDev/FilterDevelopment/FlatXmlFilterDetection/filterdetect.cxx index e26d7f6f5869..63c32c041aa0 100644 --- a/odk/examples/DevelopersGuide/OfficeDev/FilterDevelopment/FlatXmlFilterDetection/filterdetect.cxx +++ b/odk/examples/DevelopersGuide/OfficeDev/FilterDevelopment/FlatXmlFilterDetection/filterdetect.cxx @@ -35,7 +35,6 @@ #include "filterdetect.hxx" #include -#include #include #include #include @@ -54,7 +53,9 @@ #include #include #include -#include +#include +#include +#include #include @@ -97,9 +98,8 @@ OUString SAL_CALL FilterDetect::detect(Sequence< PropertyValue >& aArguments ) if (!xInStream.is()) { // open the stream if it was not suplied by the framework - Reference< XSimpleFileAccess > xSFI(mxMSF->createInstance( - OUString("com.sun.star.ucb.SimpleFileAccess")), UNO_QUERY); - if (sURL.getLength() > 0 && xSFI.is()) + Reference< XSimpleFileAccess2 > xSFI(SimpleFileAccess::create(mxContext)); + if (sURL.getLength() > 0) { try { @@ -231,10 +231,10 @@ Sequence< OUString > SAL_CALL FilterDetect_getSupportedServiceNames( ) #undef SERVICE_NAME1 #undef SERVICE_NAME2 -Reference< XInterface > SAL_CALL FilterDetect_createInstance( const Reference< XMultiServiceFactory > & rSMgr) +Reference< XInterface > SAL_CALL FilterDetect_createInstance( const Reference< XComponentContext > & rContext) throw( Exception ) { - return (cppu::OWeakObject*) new FilterDetect( rSMgr ); + return (cppu::OWeakObject*) new FilterDetect( rContext ); } // XServiceInfo diff --git a/odk/examples/DevelopersGuide/OfficeDev/FilterDevelopment/FlatXmlFilterDetection/filterdetect.hxx b/odk/examples/DevelopersGuide/OfficeDev/FilterDevelopment/FlatXmlFilterDetection/filterdetect.hxx index 210d59cf56e5..f3b0382c781f 100644 --- a/odk/examples/DevelopersGuide/OfficeDev/FilterDevelopment/FlatXmlFilterDetection/filterdetect.hxx +++ b/odk/examples/DevelopersGuide/OfficeDev/FilterDevelopment/FlatXmlFilterDetection/filterdetect.hxx @@ -47,6 +47,10 @@ #include +namespace com { namespace sun { namespace star { namespace uno { + class XComponentContext; +} } } } + enum FilterType { FILTER_IMPORT, @@ -61,7 +65,7 @@ class FilterDetect : public cppu::WeakImplHelper3 { protected: - ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > mxMSF; + ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > mxContext; ::com::sun::star::uno::Reference< ::com::sun::star::lang::XComponent > mxDoc; ::rtl::OUString msFilterName; ::com::sun::star::uno::Sequence< ::rtl::OUString > msUserData; @@ -74,8 +78,8 @@ protected: throw (::com::sun::star::uno::RuntimeException); public: - FilterDetect( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > &rxMSF) - : mxMSF( rxMSF ) {} + FilterDetect( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > &rxContext) + : mxContext( rxContext ) {} virtual ~FilterDetect() {} @@ -110,7 +114,7 @@ sal_Bool SAL_CALL FilterDetect_supportsService( const ::rtl::OUString& ServiceNa throw ( ::com::sun::star::uno::RuntimeException ); ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > -SAL_CALL FilterDetect_createInstance( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > & rSMgr) +SAL_CALL FilterDetect_createInstance( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > & rContext) throw ( ::com::sun::star::uno::Exception ); #endif -- cgit v1.2.3