diff options
author | Stephan Bergmann <sbergman@redhat.com> | 2012-09-29 17:20:22 +0200 |
---|---|---|
committer | Andras Timar <atimar@suse.com> | 2012-10-01 13:55:48 +0200 |
commit | f5f06fb016766cc40817f1fcc3feec0b464845b0 (patch) | |
tree | aefab28b58cbac33a616b4110ee8db43c831891b /oox | |
parent | ee34432562393a4549e9e77f71146e43c5d02233 (diff) |
Use comphelper::getComponentContext
...and some further clean up.
Change-Id: Id294c0f38fe0041646fc86cacbd2e19734c746a9
Diffstat (limited to 'oox')
-rw-r--r-- | oox/source/core/xmlfilterbase.cxx | 26 | ||||
-rw-r--r-- | oox/source/export/chartexport.cxx | 28 |
2 files changed, 8 insertions, 46 deletions
diff --git a/oox/source/core/xmlfilterbase.cxx b/oox/source/core/xmlfilterbase.cxx index 06773dc4be9e..70b39364e099 100644 --- a/oox/source/core/xmlfilterbase.cxx +++ b/oox/source/core/xmlfilterbase.cxx @@ -44,7 +44,6 @@ #include <com/sun/star/document/XOOXMLDocumentPropertiesImporter.hpp> #include <com/sun/star/xml/dom/XDocument.hpp> #include <com/sun/star/xml/dom/DocumentBuilder.hpp> -#include <com/sun/star/beans/XPropertySet.hpp> #include <comphelper/processfactory.hxx> #include <comphelper/mediadescriptor.hxx> #include <oox/core/filterdetect.hxx> @@ -56,7 +55,6 @@ using ::com::sun::star::xml::dom::DocumentBuilder; using ::com::sun::star::xml::dom::XDocument; using ::com::sun::star::xml::dom::XDocumentBuilder; using ::com::sun::star::xml::sax::XFastSAXSerializable; -using ::com::sun::star::beans::XPropertySet; using ::com::sun::star::lang::XComponent; namespace oox { @@ -194,26 +192,6 @@ XmlFilterBaseImpl::XmlFilterBaseImpl( const Reference< XComponentContext >& rxCo maFastParser.registerNamespace( ids[i].Second ); } - -static Reference< XComponentContext > lcl_getComponentContext(Reference< XMultiServiceFactory > aFactory) -{ - Reference< XComponentContext > xContext; - try - { - Reference< XPropertySet > xFactProp( aFactory, UNO_QUERY ); - if( xFactProp.is() ) - xFactProp->getPropertyValue( "DefaultContext") >>= xContext; - } - catch( Exception& ) - {} - - return xContext; -} - -// ============================================================================ - -// ============================================================================ - XmlFilterBase::XmlFilterBase( const Reference< XComponentContext >& rxContext ) throw( RuntimeException ) : FilterBase( rxContext ), mxImpl( new XmlFilterBaseImpl( rxContext ) ), @@ -233,7 +211,7 @@ void XmlFilterBase::importDocumentProperties() throw() Reference< XMultiServiceFactory > xFactory( getServiceFactory(), UNO_QUERY ); MediaDescriptor aMediaDesc( getMediaDescriptor() ); Reference< XInputStream > xInputStream; - Reference< XComponentContext > xContext = lcl_getComponentContext(getServiceFactory()); + Reference< XComponentContext > xContext = comphelper::getComponentContext(getServiceFactory()); ::oox::core::FilterDetect aDetector( xContext ); xInputStream = aDetector.extractUnencryptedPackage( aMediaDesc ); Reference< XComponent > xModel( getModel(), UNO_QUERY ); @@ -357,7 +335,7 @@ Reference<XDocument> XmlFilterBase::importFragment( const ::rtl::OUString& aFrag { // create the dom parser Reference< XComponentContext > xContext = - lcl_getComponentContext(getServiceFactory()); + comphelper::getComponentContext(getServiceFactory()); Reference<XDocumentBuilder> xDomBuilder( DocumentBuilder::create(xContext) ); // create DOM from fragment diff --git a/oox/source/export/chartexport.cxx b/oox/source/export/chartexport.cxx index 65195432d41e..08cc68c29f9e 100644 --- a/oox/source/export/chartexport.cxx +++ b/oox/source/export/chartexport.cxx @@ -121,21 +121,6 @@ namespace oox { namespace drawingml { if ( GETA(propName) ) \ mAny >>= variable; -Reference< uno::XComponentContext > lcl_getComponentContext() -{ - Reference< uno::XComponentContext > xContext; - try - { - Reference< beans::XPropertySet > xFactProp( comphelper::getProcessServiceFactory(), uno::UNO_QUERY ); - if( xFactProp.is()) - xFactProp->getPropertyValue(OUString("DefaultContext")) >>= xContext; - } - catch( uno::Exception& ) - {} - - return xContext; -} - class lcl_MatchesRole : public ::std::unary_function< Reference< chart2::data::XLabeledDataSequence >, bool > { public: @@ -217,13 +202,12 @@ Reference< chart2::data::XLabeledDataSequence > lcl_getCategories( const Referen Reference< chart2::data::XDataSource > lcl_createDataSource( const Sequence< Reference< chart2::data::XLabeledDataSequence > > & aData ) { - Reference< chart2::data::XDataSink > xSink; - Reference< uno::XComponentContext > xContext( lcl_getComponentContext()); - if( xContext.is() ) - xSink.set( - xContext->getServiceManager()->createInstanceWithContext( - OUString("com.sun.star.chart2.data.DataSource"), - xContext ), uno::UNO_QUERY_THROW ); + Reference< uno::XComponentContext > xContext( + comphelper::getProcessComponentContext() ); + Reference< chart2::data::XDataSink > xSink( + xContext->getServiceManager()->createInstanceWithContext( + "com.sun.star.chart2.data.DataSource", xContext ), + uno::UNO_QUERY_THROW ); if( xSink.is()) xSink->setData( aData ); |