diff options
52 files changed, 416 insertions, 490 deletions
diff --git a/chart2/source/controller/chartapiwrapper/WrappedSymbolProperties.cxx b/chart2/source/controller/chartapiwrapper/WrappedSymbolProperties.cxx index 5d65387bda59..78cc8a206234 100644 --- a/chart2/source/controller/chartapiwrapper/WrappedSymbolProperties.cxx +++ b/chart2/source/controller/chartapiwrapper/WrappedSymbolProperties.cxx @@ -39,6 +39,7 @@ #include <com/sun/star/chart/ChartSymbolType.hpp> #include <com/sun/star/drawing/LineStyle.hpp> +#include <com/sun/star/graphic/GraphicProvider.hpp> #include <com/sun/star/graphic/XGraphicProvider.hpp> // for UNO_NAME_GRAPHOBJ_URLPREFIX @@ -389,9 +390,8 @@ void WrappedSymbolBitmapURLProperty::setValueToSeries( try { // @todo: get factory from some context? - Reference< lang::XMultiServiceFactory > xFact( comphelper::getProcessServiceFactory(), uno::UNO_QUERY_THROW ); - Reference< graphic::XGraphicProvider > xGraphProv( - xFact->createInstance( "com.sun.star.graphic.GraphicProvider"), uno::UNO_QUERY_THROW ); + Reference< uno::XComponentContext > xContext = comphelper::getProcessComponentContext(); + Reference< graphic::XGraphicProvider > xGraphProv( graphic::GraphicProvider::create(xContext) ); Sequence< beans::PropertyValue > aArgs(1); aArgs[0] = beans::PropertyValue( "URL", -1, uno::makeAny( aNewGraphicURL ), beans::PropertyState_DIRECT_VALUE ); diff --git a/connectivity/source/drivers/hsqldb/HConnection.cxx b/connectivity/source/drivers/hsqldb/HConnection.cxx index cb8a7499f7a9..979866a76c00 100644 --- a/connectivity/source/drivers/hsqldb/HConnection.cxx +++ b/connectivity/source/drivers/hsqldb/HConnection.cxx @@ -39,6 +39,7 @@ #include <com/sun/star/sdbcx/XDataDefinitionSupplier.hpp> #include <com/sun/star/lang/ServiceNotRegisteredException.hpp> #include <com/sun/star/sdbc/XRow.hpp> +#include <com/sun/star/graphic/GraphicProvider.hpp> #include <com/sun/star/graphic/XGraphicProvider.hpp> #include <com/sun/star/graphic/GraphicColorMode.hpp> #include <com/sun/star/beans/PropertyValue.hpp> @@ -75,6 +76,7 @@ using ::com::sun::star::lang::ServiceNotRegisteredException; using ::com::sun::star::sdbc::XDriver; using ::com::sun::star::lang::XMultiServiceFactory; using ::com::sun::star::graphic::XGraphic; +using ::com::sun::star::graphic::GraphicProvider; using ::com::sun::star::graphic::XGraphicProvider; using ::com::sun::star::uno::XInterface; using ::com::sun::star::lang::IllegalArgumentException; @@ -353,7 +355,7 @@ namespace connectivity { namespace hsqldb // create a graphic provider Reference< XGraphicProvider > xProvider; if ( m_xORB.is() ) - xProvider.set( m_xORB->createInstance( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.graphic.GraphicProvider" ) ) ), UNO_QUERY_THROW ); + xProvider.set( GraphicProvider::create(::comphelper::ComponentContext(m_xORB).getUNOContext()) ); // assemble the image URL ::rtl::OUStringBuffer aImageURL; diff --git a/cui/source/customize/cfg.cxx b/cui/source/customize/cfg.cxx index f1616367812d..adaeaaa94614 100644 --- a/cui/source/customize/cfg.cxx +++ b/cui/source/customize/cfg.cxx @@ -85,7 +85,9 @@ #include <com/sun/star/frame/XFramesSupplier.hpp> #include <com/sun/star/frame/XFrames.hpp> #include <com/sun/star/frame/FrameSearchFlag.hpp> +#include <com/sun/star/graphic/GraphicProvider.hpp> #include <com/sun/star/embed/ElementModes.hpp> +#include <com/sun/star/embed/FileSystemStorageFactory.hpp> #include "dlgname.hxx" @@ -5052,19 +5054,11 @@ SvxIconSelectorDialog::SvxIconSelectorDialog( Window *pWindow, uno::Reference< lang::XMultiServiceFactory > xServiceManager = ::comphelper::getProcessServiceFactory(); + uno::Reference< uno::XComponentContext > xComponentContext = + ::comphelper::getProcessComponentContext(); - if ( xServiceManager.is() ) - { - m_xGraphProvider = uno::Reference< graphic::XGraphicProvider >( - xServiceManager->createInstance( - ::rtl::OUString("com.sun.star.graphic.GraphicProvider" ) ), - uno::UNO_QUERY ); - } - - if ( !m_xGraphProvider.is() ) - { - aBtnImport.Enable( sal_False ); - } + m_xGraphProvider = uno::Reference< graphic::XGraphicProvider >( + graphic::GraphicProvider::create( xComponentContext ) ); uno::Reference< beans::XPropertySet > xPropSet( xServiceManager->createInstance( ::rtl::OUString("com.sun.star.util.PathSettings" ) ), @@ -5094,9 +5088,7 @@ SvxIconSelectorDialog::SvxIconSelectorDialog( Window *pWindow, aDirectory += ::rtl::OUString( "soffice.cfg/import" ); uno::Reference< lang::XSingleServiceFactory > xStorageFactory( - xServiceManager->createInstance( - ::rtl::OUString("com.sun.star.embed.FileSystemStorageFactory" ) ), - uno::UNO_QUERY ); + ::com::sun::star::embed::FileSystemStorageFactory::create( xComponentContext ) ); uno::Sequence< uno::Any > aArgs( 2 ); aArgs[ 0 ] <<= aDirectory; diff --git a/cui/source/dialogs/plfilter.cxx b/cui/source/dialogs/plfilter.cxx index 678db753ad3b..ff6816026c4e 100644 --- a/cui/source/dialogs/plfilter.cxx +++ b/cui/source/dialogs/plfilter.cxx @@ -35,6 +35,7 @@ #include <com/sun/star/lang/XMultiServiceFactory.hpp> #include <com/sun/star/plugin/PluginDescription.hpp> +#include <com/sun/star/plugin/PluginManager.hpp> #include <com/sun/star/plugin/XPluginManager.hpp> using namespace std; @@ -57,69 +58,62 @@ typedef map< String, StrSet, ltstr > FilterMap; //================================================================================================== void fillNetscapePluginFilters( Sequence< rtl::OUString >& rPluginNames, Sequence< rtl::OUString >& rPluginTypes ) { - Reference< XMultiServiceFactory > xMan( ::comphelper::getProcessServiceFactory() ); - Reference< XPluginManager > xPMgr( xMan->createInstance( - rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.plugin.PluginManager") ) ), UNO_QUERY ); + Reference< XComponentContext > xContext = comphelper::getProcessComponentContext(); + Reference< XPluginManager > xPMgr( PluginManager::create(xContext) ); - if ( xPMgr.is() ) + FilterMap aMap; + + // sum up the mimetypes: one description, multiple extensions + + Sequence<PluginDescription > aDescriptions( xPMgr->getPluginDescriptions() ); + const PluginDescription * pDescriptions = aDescriptions.getConstArray(); + for ( sal_uInt32 nPos = aDescriptions.getLength(); nPos--; ) { - FilterMap aMap; + const PluginDescription & rDescr = pDescriptions[nPos]; - // sum up the mimetypes: one description, multiple extensions + StrSet& rTypes = aMap[ rDescr.Description ]; + String aExtension( rDescr.Extension ); - Sequence<PluginDescription > aDescriptions( xPMgr->getPluginDescriptions() ); - const PluginDescription * pDescriptions = aDescriptions.getConstArray(); - for ( sal_uInt32 nPos = aDescriptions.getLength(); nPos--; ) + for ( sal_uInt16 nCnt = comphelper::string::getTokenCount(aExtension, ';'); nCnt--; ) + { + // no default plugins anymore + String aExt( aExtension.GetToken( nCnt, ';' ) ); + if ( aExt.CompareToAscii( "*.*" ) != COMPARE_EQUAL ) + rTypes.insert( aExt ); + } + } + + rPluginNames = Sequence< rtl::OUString >( aMap.size() ); + rPluginTypes = Sequence< rtl::OUString >( aMap.size() ); + rtl::OUString* pPluginNames = rPluginNames.getArray(); + rtl::OUString* pPluginTypes = rPluginTypes.getArray(); + int nIndex = 0; + for ( FilterMap::iterator iPos = aMap.begin(); iPos != aMap.end(); ++iPos ) + { + String aText( (*iPos).first ); + String aType; + StrSet& rTypes = (*iPos).second; + StrSet::iterator i = rTypes.begin(); + while ( i != rTypes.end() ) { - const PluginDescription & rDescr = pDescriptions[nPos]; - - StrSet& rTypes = aMap[ rDescr.Description ]; - String aExtension( rDescr.Extension ); - - for ( sal_uInt16 nCnt = comphelper::string::getTokenCount(aExtension, ';'); nCnt--; ) - { - // no default plugins anymore - String aExt( aExtension.GetToken( nCnt, ';' ) ); - if ( aExt.CompareToAscii( "*.*" ) != COMPARE_EQUAL ) - rTypes.insert( aExt ); - } + aType += (*i); + ++i; + if ( i != rTypes.end() ) + aType += ';'; } - rPluginNames = Sequence< rtl::OUString >( aMap.size() ); - rPluginTypes = Sequence< rtl::OUString >( aMap.size() ); - rtl::OUString* pPluginNames = rPluginNames.getArray(); - rtl::OUString* pPluginTypes = rPluginTypes.getArray(); - int nIndex = 0; - for ( FilterMap::iterator iPos = aMap.begin(); iPos != aMap.end(); ++iPos ) + if ( aType.Len() ) { - String aText( (*iPos).first ); - String aType; - StrSet& rTypes = (*iPos).second; - StrSet::iterator i = rTypes.begin(); - while ( i != rTypes.end() ) - { - aType += (*i); - ++i; - if ( i != rTypes.end() ) - aType += ';'; - } - - if ( aType.Len() ) - { - aText += String::CreateFromAscii( " (" ); - aText += aType; - aText += ')'; - pPluginNames[nIndex] = aText; - pPluginTypes[nIndex] = aType; - nIndex++; - } + aText += String::CreateFromAscii( " (" ); + aText += aType; + aText += ')'; + pPluginNames[nIndex] = aText; + pPluginTypes[nIndex] = aType; + nIndex++; } - rPluginNames.realloc( nIndex ); - rPluginTypes.realloc( nIndex ); } - else - ShowServiceNotAvailableError( NULL, - String::CreateFromAscii( RTL_CONSTASCII_STRINGPARAM( "com.sun.star.plugin.PluginManager" ) ), sal_True ); + rPluginNames.realloc( nIndex ); + rPluginTypes.realloc( nIndex ); } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/cui/source/tabpages/numpages.cxx b/cui/source/tabpages/numpages.cxx index a4d38370874b..fc05d7293238 100644 --- a/cui/source/tabpages/numpages.cxx +++ b/cui/source/tabpages/numpages.cxx @@ -59,6 +59,7 @@ #include <com/sun/star/style/NumberingType.hpp> #include <com/sun/star/lang/XMultiServiceFactory.hpp> #include <com/sun/star/container/XIndexAccess.hpp> +#include <com/sun/star/text/DefaultNumberingProvider.hpp> #include <com/sun/star/text/XDefaultNumberingProvider.hpp> #include <com/sun/star/text/XNumberingFormatter.hpp> #include <com/sun/star/beans/PropertyValue.hpp> @@ -66,6 +67,7 @@ #include <com/sun/star/text/XNumberingTypeInfo.hpp> #include <svx/dialmgr.hxx> #include <svx/dialogs.hrc> +#include <comphelper/componentcontext.hxx> #include <algorithm> #include <vector> @@ -112,12 +114,8 @@ static const sal_Char cBulletFontName[] = "BulletFontName"; Reference<XDefaultNumberingProvider> lcl_GetNumberingProvider() { - Reference< XMultiServiceFactory > xMSF = ::comphelper::getProcessServiceFactory(); - Reference < XInterface > xI = xMSF->createInstance( - ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.text.DefaultNumberingProvider" )) ); - Reference<XDefaultNumberingProvider> xRet(xI, UNO_QUERY); - DBG_ASSERT(xRet.is(), "service missing: \"com.sun.star.text.DefaultNumberingProvider\""); - + Reference<XComponentContext> xContext( ::comphelper::getProcessComponentContext() ); + Reference<XDefaultNumberingProvider> xRet = text::DefaultNumberingProvider::create(xContext); return xRet; } diff --git a/desktop/source/deployment/registry/package/dp_package.cxx b/desktop/source/deployment/registry/package/dp_package.cxx index 4e7f8e8403a6..3a520ebf738c 100644 --- a/desktop/source/deployment/registry/package/dp_package.cxx +++ b/desktop/source/deployment/registry/package/dp_package.cxx @@ -47,6 +47,7 @@ #include "com/sun/star/lang/XServiceInfo.hpp" #include "com/sun/star/beans/UnknownPropertyException.hpp" #include "com/sun/star/graphic/XGraphic.hpp" +#include "com/sun/star/graphic/GraphicProvider.hpp" #include "com/sun/star/graphic/XGraphicProvider.hpp" #include "com/sun/star/io/XOutputStream.hpp" #include "com/sun/star/io/XInputStream.hpp" @@ -835,18 +836,13 @@ uno::Reference< graphic::XGraphic > BackendImpl::PackageImpl::getIcon( sal_Bool OUString aFullIconURL = m_url_expanded + OUSTR("/") + aIconURL; uno::Reference< XComponentContext > xContext( getMyBackend()->getComponentContext() ); - uno::Reference< graphic::XGraphicProvider > xGraphProvider( - xContext->getServiceManager()->createInstanceWithContext( OUSTR( "com.sun.star.graphic.GraphicProvider" ), xContext ), - uno::UNO_QUERY ); + uno::Reference< graphic::XGraphicProvider > xGraphProvider( graphic::GraphicProvider::create(xContext) ); - if ( xGraphProvider.is() ) - { uno::Sequence< beans::PropertyValue > aMediaProps( 1 ); aMediaProps[0].Name = OUSTR( "URL" ); aMediaProps[0].Value <<= aFullIconURL; - xGraphic = xGraphProvider->queryGraphic( aMediaProps ); - } + xGraphic = xGraphProvider->queryGraphic( aMediaProps ); } return xGraphic; diff --git a/desktop/source/migration/migration.cxx b/desktop/source/migration/migration.cxx index 583edec17049..88bf8c54f393 100644 --- a/desktop/source/migration/migration.cxx +++ b/desktop/source/migration/migration.cxx @@ -35,6 +35,7 @@ #include "migration_impl.hxx" #include <unotools/textsearch.hxx> +#include <comphelper/componentcontext.hxx> #include <comphelper/processfactory.hxx> #include <comphelper/sequence.hxx> #include <unotools/bootstrap.hxx> @@ -57,6 +58,7 @@ #include <com/sun/star/util/XChangesBatch.hpp> #include <com/sun/star/util/XStringSubstitution.hpp> #include <com/sun/star/embed/ElementModes.hpp> +#include <com/sun/star/embed/FileSystemStorageFactory.hpp> #include <com/sun/star/embed/XStorage.hpp> #include <com/sun/star/ui/XUIConfiguration.hpp> #include <com/sun/star/ui/XUIConfigurationStorage.hpp> @@ -272,10 +274,9 @@ sal_Bool MigrationImpl::doMigration() lArgs[0] <<= aOldCfgDataPath + vModulesInfo[i].sModuleShortName; lArgs[1] <<= embed::ElementModes::READ; - uno::Reference< lang::XSingleServiceFactory > xStorageFactory(m_xFactory->createInstance(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.embed.FileSystemStorageFactory"))), uno::UNO_QUERY); - uno::Reference< embed::XStorage > xModules; - - xModules = uno::Reference< embed::XStorage >(xStorageFactory->createInstanceWithArguments(lArgs), uno::UNO_QUERY); + uno::Reference< lang::XSingleServiceFactory > xStorageFactory( + embed::FileSystemStorageFactory::create(comphelper::ComponentContext(m_xFactory).getUNOContext())); + uno::Reference< embed::XStorage > xModules(xStorageFactory->createInstanceWithArguments(lArgs), uno::UNO_QUERY); uno::Reference< ui::XUIConfigurationManager > xOldCfgManager( m_xFactory->createInstance( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.ui.UIConfigurationManager"))), uno::UNO_QUERY ); uno::Reference< ui::XUIConfigurationStorage > xOldCfgStorage( xOldCfgManager, uno::UNO_QUERY ); uno::Reference< ui::XUIConfigurationPersistence > xOldCfgPersistence( xOldCfgManager, uno::UNO_QUERY ); @@ -996,7 +997,8 @@ void MigrationImpl::runServices() lArgs[0] <<= m_aInfo.userdata + ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("/user/config/soffice.cfg/modules")); lArgs[1] <<= embed::ElementModes::READ; - uno::Reference< lang::XSingleServiceFactory > xStorageFactory(m_xFactory->createInstance(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.embed.FileSystemStorageFactory"))), uno::UNO_QUERY); + uno::Reference< lang::XSingleServiceFactory > xStorageFactory( + embed::FileSystemStorageFactory::create(comphelper::ComponentContext(m_xFactory).getUNOContext())); uno::Reference< embed::XStorage > xModules; xModules = uno::Reference< embed::XStorage >(xStorageFactory->createInstanceWithArguments(lArgs), uno::UNO_QUERY); diff --git a/editeng/source/items/numitem.cxx b/editeng/source/items/numitem.cxx index ff1472a19310..039d3e483557 100644 --- a/editeng/source/items/numitem.cxx +++ b/editeng/source/items/numitem.cxx @@ -42,6 +42,7 @@ #include <vcl/svapp.hxx> #include <editeng/unolingu.hxx> #include <com/sun/star/text/XNumberingFormatter.hpp> +#include <com/sun/star/text/DefaultNumberingProvider.hpp> #include <com/sun/star/text/XDefaultNumberingProvider.hpp> #include <com/sun/star/style/NumberingType.hpp> #include <com/sun/star/lang/XMultiServiceFactory.hpp> @@ -75,15 +76,13 @@ void lcl_getFormatter(com::sun::star::uno::Reference<com::sun::star::text::XNumb { try { - Reference< XMultiServiceFactory > xMSF = ::comphelper::getProcessServiceFactory(); - Reference < XInterface > xI = xMSF->createInstance( - ::rtl::OUString( "com.sun.star.text.DefaultNumberingProvider" ) ); - Reference<XDefaultNumberingProvider> xRet(xI, UNO_QUERY); - DBG_ASSERT(xRet.is(), "service missing: \"com.sun.star.text.DefaultNumberingProvider\""); + Reference<XComponentContext> xContext( ::comphelper::getProcessComponentContext() ); + Reference<XDefaultNumberingProvider> xRet = text::DefaultNumberingProvider::create(xContext); _xFormatter = Reference<XNumberingFormatter> (xRet, UNO_QUERY); } catch(const Exception&) { + SAL_WARN("editeng", "service missing: \"com.sun.star.text.DefaultNumberingProvider\""); } } } diff --git a/embeddedobj/source/msole/graphconvert.cxx b/embeddedobj/source/msole/graphconvert.cxx index ca83da870135..77caf58c7910 100644 --- a/embeddedobj/source/msole/graphconvert.cxx +++ b/embeddedobj/source/msole/graphconvert.cxx @@ -32,6 +32,7 @@ #include <com/sun/star/embed/Aspects.hpp> #include <com/sun/star/io/XInputStream.hpp> #include <com/sun/star/io/XOutputStream.hpp> +#include <com/sun/star/graphic/GraphicProvider.hpp> #include <com/sun/star/graphic/XGraphicProvider.hpp> #include <com/sun/star/graphic/XGraphic.hpp> #include <com/sun/star/beans/PropertyValue.hpp> @@ -60,27 +61,24 @@ sal_Bool ConvertBufferToFormat( void* pBuf, uno::Reference < io::XInputStream > xIn = new comphelper::SequenceInputStream( aData ); try { - uno::Reference < graphic::XGraphicProvider > xGraphicProvider( comphelper::getProcessServiceFactory()->createInstance( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.graphic.GraphicProvider")) ), uno::UNO_QUERY ); - if( xGraphicProvider.is() ) + uno::Reference < graphic::XGraphicProvider > xGraphicProvider( graphic::GraphicProvider::create(comphelper::getProcessComponentContext())); + uno::Sequence< beans::PropertyValue > aMediaProperties( 1 ); + aMediaProperties[0].Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "InputStream" )); + aMediaProperties[0].Value <<= xIn; + uno::Reference< graphic::XGraphic > xGraphic( xGraphicProvider->queryGraphic( aMediaProperties ) ); + if( xGraphic.is() ) { - uno::Sequence< beans::PropertyValue > aMediaProperties( 1 ); - aMediaProperties[0].Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "InputStream" )); - aMediaProperties[0].Value <<= xIn; - uno::Reference< graphic::XGraphic > xGraphic( xGraphicProvider->queryGraphic( aMediaProperties ) ); - if( xGraphic.is() ) - { - SvMemoryStream aNewStream( 65535, 65535 ); - uno::Reference < io::XStream > xOut = new utl::OStreamWrapper( aNewStream ); - uno::Sequence< beans::PropertyValue > aOutMediaProperties( 2 ); - aOutMediaProperties[0].Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "OutputStream" )); - aOutMediaProperties[0].Value <<= xOut; - aOutMediaProperties[1].Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "MimeType" )); - aOutMediaProperties[1].Value <<= aMimeType; + SvMemoryStream aNewStream( 65535, 65535 ); + uno::Reference < io::XStream > xOut = new utl::OStreamWrapper( aNewStream ); + uno::Sequence< beans::PropertyValue > aOutMediaProperties( 2 ); + aOutMediaProperties[0].Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "OutputStream" )); + aOutMediaProperties[0].Value <<= xOut; + aOutMediaProperties[1].Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "MimeType" )); + aOutMediaProperties[1].Value <<= aMimeType; - xGraphicProvider->storeGraphic( xGraphic, aOutMediaProperties ); - aResult <<= uno::Sequence< sal_Int8 >( reinterpret_cast< const sal_Int8* >( aNewStream.GetData() ), aNewStream.Seek( STREAM_SEEK_TO_END ) ); - return sal_True; - } + xGraphicProvider->storeGraphic( xGraphic, aOutMediaProperties ); + aResult <<= uno::Sequence< sal_Int8 >( reinterpret_cast< const sal_Int8* >( aNewStream.GetData() ), aNewStream.Seek( STREAM_SEEK_TO_END ) ); + return sal_True; } } catch (const uno::Exception&) diff --git a/extensions/source/plugin/base/xplugin.cxx b/extensions/source/plugin/base/xplugin.cxx index 897be135a541..4d2b0420ea24 100644 --- a/extensions/source/plugin/base/xplugin.cxx +++ b/extensions/source/plugin/base/xplugin.cxx @@ -42,7 +42,9 @@ #include <com/sun/star/lang/XSingleServiceFactory.hpp> #include <com/sun/star/loader/XImplementationLoader.hpp> #include <com/sun/star/loader/CannotActivateFactoryException.hpp> +#include <com/sun/star/plugin/PluginManager.hpp> +#include <comphelper/componentcontext.hxx> #include <plugin/impl.hxx> #include <tools/fsys.hxx> #include <ucbhelper/content.hxx> @@ -137,8 +139,8 @@ XPlugin_Impl::XPlugin_Impl( const uno::Reference< com::sun::star::lang::XMultiSe uno::Reference< com::sun::star::beans::XPropertySet > xPS( m_xModel, UNO_QUERY ); xPS->addPropertyChangeListener( OUString(), this ); - Guard< Mutex > aGuard( PluginManager::get().getPluginMutex() ); - PluginManager::get().getPlugins().push_back( this ); + Guard< Mutex > aGuard( ::PluginManager::get().getPluginMutex() ); + ::PluginManager::get().getPlugins().push_back( this ); } void XPlugin_Impl::destroyInstance() @@ -198,11 +200,11 @@ IMPL_LINK( XPlugin_Impl, secondLevelDispose, XPlugin_Impl*, /*pThis*/ ) // may have become undisposable between PostUserEvent and here // or may have disposed and receive a second UserEvent - std::list<XPlugin_Impl*>& rList = PluginManager::get().getPlugins(); + std::list<XPlugin_Impl*>& rList = ::PluginManager::get().getPlugins(); std::list<XPlugin_Impl*>::iterator iter; { - Guard< Mutex > aPluginGuard( PluginManager::get().getPluginMutex() ); + Guard< Mutex > aPluginGuard( ::PluginManager::get().getPluginMutex() ); for( iter = rList.begin(); iter != rList.end(); ++iter ) { if( *iter == this ) @@ -222,7 +224,7 @@ IMPL_LINK( XPlugin_Impl, secondLevelDispose, XPlugin_Impl*, /*pThis*/ ) uno::Reference< com::sun::star::beans::XPropertySet > xPS( m_xModel, UNO_QUERY ); xPS->removePropertyChangeListener( OUString(), this ); { - Guard< Mutex > aPluginGuard( PluginManager::get().getPluginMutex() ); + Guard< Mutex > aPluginGuard( ::PluginManager::get().getPluginMutex() ); rList.remove( this ); } m_aNPWindow.window = NULL; @@ -512,8 +514,8 @@ void XPlugin_Impl::loadPlugin() Guard< Mutex > aGuard( m_aMutex ); std::list<PluginComm*>::iterator iter; - for( iter = PluginManager::get().getPluginComms().begin(); - iter != PluginManager::get().getPluginComms().end(); ++iter ) + for( iter = ::PluginManager::get().getPluginComms().begin(); + iter != ::PluginManager::get().getPluginComms().end(); ++iter ) { if( OStringToOUString( (*iter)->getLibName(), m_aEncoding ) == m_aDescription.PluginName ) { @@ -893,12 +895,7 @@ void XPlugin_Impl::setPosSize( sal_Int32 nX_, sal_Int32 nY_, sal_Int32 nWidth_, PluginDescription XPlugin_Impl::fitDescription( const OUString& rURL ) { - uno::Reference< XPluginManager > xPMgr( m_xSMgr->createInstance( OUString("com.sun.star.plugin.PluginManager") ), UNO_QUERY ); - if( !xPMgr.is() ) - { - m_nProvidingState = PROVIDING_NONE; - return PluginDescription(); - } + uno::Reference< XPluginManager > xPMgr( plugin::PluginManager::create(comphelper::ComponentContext(m_xSMgr).getUNOContext()) ); Sequence< PluginDescription > aDescrs = xPMgr->getPluginDescriptions(); const PluginDescription* pDescrs = aDescrs.getConstArray(); diff --git a/extensions/source/propctrlr/browserline.cxx b/extensions/source/propctrlr/browserline.cxx index 480ac6badacd..816612344e5e 100644 --- a/extensions/source/propctrlr/browserline.cxx +++ b/extensions/source/propctrlr/browserline.cxx @@ -28,7 +28,9 @@ #include "browserline.hxx" +#include <com/sun/star/uno/XComponentContext.hpp> #include <com/sun/star/inspection/PropertyLineElement.hpp> +#include <com/sun/star/graphic/GraphicProvider.hpp> #include <com/sun/star/graphic/XGraphicProvider.hpp> #include <comphelper/componentcontext.hxx> @@ -46,10 +48,12 @@ namespace pcr /** === begin UNO using === **/ using ::com::sun::star::uno::Reference; + using ::com::sun::star::uno::XComponentContext; using ::com::sun::star::inspection::XPropertyControl; using ::com::sun::star::inspection::XPropertyControlContext; using ::com::sun::star::uno::UNO_QUERY_THROW; using ::com::sun::star::uno::Exception; + using ::com::sun::star::graphic::GraphicProvider; using ::com::sun::star::graphic::XGraphicProvider; using ::com::sun::star::uno::Sequence; using ::com::sun::star::beans::PropertyValue; @@ -412,8 +416,8 @@ namespace pcr { try { - ::comphelper::ComponentContext aContext( ::comphelper::getProcessServiceFactory() ); - Reference< XGraphicProvider > xGraphicProvider( aContext.createComponent( "com.sun.star.graphic.GraphicProvider" ), UNO_QUERY_THROW ); + Reference< XComponentContext > xContext( ::comphelper::getProcessComponentContext() ); + Reference< XGraphicProvider > xGraphicProvider( GraphicProvider::create(xContext) ); Sequence< PropertyValue > aMediaProperties(1); aMediaProperties[0].Name = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "URL" ) ); diff --git a/extensions/source/update/ui/updatecheckui.cxx b/extensions/source/update/ui/updatecheckui.cxx index 2c974dcf508f..53d41c40efd2 100644 --- a/extensions/source/update/ui/updatecheckui.cxx +++ b/extensions/source/update/ui/updatecheckui.cxx @@ -36,6 +36,7 @@ #include <com/sun/star/document/XEventListener.hpp> #include <com/sun/star/document/XEventBroadcaster.hpp> #include <com/sun/star/beans/XPropertySet.hpp> +#include <com/sun/star/graphic/GraphicProvider.hpp> #include <com/sun/star/graphic/XGraphicProvider.hpp> #include <com/sun/star/task/XJob.hpp> @@ -323,30 +324,24 @@ Image UpdateCheckUI::GetBubbleImage( ::rtl::OUString &rURL ) if ( !maBubbleImageURL.isEmpty() ) { - uno::Reference< lang::XMultiServiceFactory > xServiceManager = ::comphelper::getProcessServiceFactory(); + uno::Reference< uno::XComponentContext > xContext = ::comphelper::getProcessComponentContext(); - if( !xServiceManager.is() ) + if( !xContext.is() ) throw uno::RuntimeException( UNISTRING( "UpdateCheckUI: unable to obtain service manager from component context" ), uno::Reference< uno::XInterface >() ); try { - uno::Reference< graphic::XGraphicProvider > xGraphProvider( - xServiceManager->createInstance( - ::rtl::OUString("com.sun.star.graphic.GraphicProvider") ), - uno::UNO_QUERY ); - if ( xGraphProvider.is() ) - { - uno::Sequence< beans::PropertyValue > aMediaProps( 1 ); - aMediaProps[0].Name = ::rtl::OUString("URL"); - aMediaProps[0].Value <<= rURL; + uno::Reference< graphic::XGraphicProvider > xGraphProvider(graphic::GraphicProvider::create(xContext)); + uno::Sequence< beans::PropertyValue > aMediaProps( 1 ); + aMediaProps[0].Name = ::rtl::OUString("URL"); + aMediaProps[0].Value <<= rURL; - uno::Reference< graphic::XGraphic > xGraphic = xGraphProvider->queryGraphic( aMediaProps ); - if ( xGraphic.is() ) - { - aImage = Image( xGraphic ); - } + uno::Reference< graphic::XGraphic > xGraphic = xGraphProvider->queryGraphic( aMediaProps ); + if ( xGraphic.is() ) + { + aImage = Image( xGraphic ); } } catch( const uno::Exception& ) diff --git a/forms/source/component/ImageControl.cxx b/forms/source/component/ImageControl.cxx index 55ab059c33a6..57a871b1d368 100644 --- a/forms/source/component/ImageControl.cxx +++ b/forms/source/component/ImageControl.cxx @@ -37,6 +37,7 @@ #include <svtools/imageresourceaccess.hxx> #include <unotools/ucblockbytes.hxx> #include <sfx2/filedlghelper.hxx> +#include <com/sun/star/awt/PopupMenu.hpp> #include <com/sun/star/awt/XPopupMenu.hpp> #include <com/sun/star/awt/PopupMenuDirection.hpp> #include <com/sun/star/ui/dialogs/TemplateDescription.hpp> @@ -911,7 +912,7 @@ void OImageControlControl::mousePressed(const ::com::sun::star::awt::MouseEvent& // is this a request for a context menu? if ( e.PopupTrigger ) { - Reference< XPopupMenu > xMenu( m_aContext.createComponent( "com.sun.star.awt.PopupMenu" ), UNO_QUERY ); + Reference< XPopupMenu > xMenu( awt::PopupMenu::create( m_aContext.getUNOContext() ) ); DBG_ASSERT( xMenu.is(), "OImageControlControl::mousePressed: could not create a popup menu!" ); Reference< XWindowPeer > xWindowPeer = getPeer(); diff --git a/framework/source/services/frame.cxx b/framework/source/services/frame.cxx index d100e097ffec..6000e55f4a53 100644 --- a/framework/source/services/frame.cxx +++ b/framework/source/services/frame.cxx @@ -49,6 +49,7 @@ #include <com/sun/star/lang/XInitialization.hpp> #include <com/sun/star/lang/DisposedException.hpp> +#include <com/sun/star/task/JobExecutor.hpp> #include <com/sun/star/task/XJobExecutor.hpp> #include <com/sun/star/util/XURLTransformer.hpp> #include <com/sun/star/util/XCloseable.hpp> @@ -72,6 +73,7 @@ #include <com/sun/star/frame/XTitleChangeBroadcaster.hpp> +#include <comphelper/componentcontext.hxx> #include <comphelper/sequenceashashmap.hxx> #include <cppuhelper/queryinterface.hxx> #include <cppuhelper/typeprovider.hxx> @@ -2396,11 +2398,9 @@ void SAL_CALL Frame::windowShown( const css::lang::EventObject& ) throw(css::uno if (bMustBeTriggered) { - css::uno::Reference< css::task::XJobExecutor > xExecutor( xFactory->createInstance( SERVICENAME_JOBEXECUTOR ), css::uno::UNO_QUERY ); - if (xExecutor.is()) - { - xExecutor->trigger( DECLARE_ASCII("onFirstVisibleTask") ); - } + css::uno::Reference< css::task::XJobExecutor > xExecutor + = css::task::JobExecutor::create( comphelper::ComponentContext(xFactory).getUNOContext() ); + xExecutor->trigger( DECLARE_ASCII("onFirstVisibleTask") ); } } } diff --git a/framework/source/uielement/langselectionstatusbarcontroller.cxx b/framework/source/uielement/langselectionstatusbarcontroller.cxx index 5e67bebe19d4..ed39425ea7d0 100644 --- a/framework/source/uielement/langselectionstatusbarcontroller.cxx +++ b/framework/source/uielement/langselectionstatusbarcontroller.cxx @@ -40,6 +40,7 @@ #include <com/sun/star/frame/XPopupMenuController.hpp> #include <toolkit/helper/vclunohelper.hxx> +#include <com/sun/star/awt/PopupMenu.hpp> #include <com/sun/star/awt/PopupMenuDirection.hpp> #include <svtools/langtab.hxx> #include "sal/types.h" @@ -58,6 +59,7 @@ #include <com/sun/star/frame/XDispatchProvider.hpp> #include <com/sun/star/util/XURLTransformer.hpp> #include <comphelper/processfactory.hxx> +#include <comphelper/componentcontext.hxx> #include <toolkit/unohlp.hxx> #include <tools/gen.hxx> @@ -186,10 +188,9 @@ throw (::com::sun::star::uno::RuntimeException) return; //add context menu - const static OUString s_sPopupMenu(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.PopupMenu")); - Reference< awt::XPopupMenu > xPopupMenu( m_xServiceManager->createInstance( s_sPopupMenu ), UNO_QUERY ); + Reference< awt::XPopupMenu > xPopupMenu( awt::PopupMenu::create( comphelper::ComponentContext(m_xServiceManager).getUNOContext() ) ); //sub menu that contains all items except the last two items: Separator + Set Language for Paragraph - Reference< awt::XPopupMenu > subPopupMenu(m_xServiceManager->createInstance( s_sPopupMenu ), UNO_QUERY ); + Reference< awt::XPopupMenu > subPopupMenu( awt::PopupMenu::create( comphelper::ComponentContext(m_xServiceManager).getUNOContext() ) ); SvtLanguageTable aLanguageTable; diff --git a/oox/source/helper/graphichelper.cxx b/oox/source/helper/graphichelper.cxx index 53ddb54e0723..edcb19855f45 100644 --- a/oox/source/helper/graphichelper.cxx +++ b/oox/source/helper/graphichelper.cxx @@ -36,6 +36,7 @@ #include <com/sun/star/beans/XPropertySet.hpp> #include <com/sun/star/frame/XFramesSupplier.hpp> #include <com/sun/star/graphic/GraphicObject.hpp> +#include <com/sun/star/graphic/GraphicProvider.hpp> #include <com/sun/star/graphic/XGraphicProvider.hpp> #include <com/sun/star/util/MeasureUnit.hpp> #include <comphelper/seqstream.hxx> @@ -82,7 +83,7 @@ GraphicHelper::GraphicHelper( const Reference< XComponentContext >& rxContext, c Reference< XMultiServiceFactory > xFactory( mxContext->getServiceManager(), UNO_QUERY ); OSL_ENSURE( xFactory.is(), "GraphicHelper::GraphicHelper - missing service factory" ); if( xFactory.is() ) - mxGraphicProvider.set( xFactory->createInstance( CREATE_OUSTRING( "com.sun.star.graphic.GraphicProvider" ) ), UNO_QUERY ); + mxGraphicProvider.set( graphic::GraphicProvider::create( mxContext ) ); //! TODO: get colors from system maSystemPalette[ XML_3dDkShadow ] = 0x716F64; diff --git a/sc/CppunitTest_sc_filters_test.mk b/sc/CppunitTest_sc_filters_test.mk index df24d1585e69..616a0d77048a 100644 --- a/sc/CppunitTest_sc_filters_test.mk +++ b/sc/CppunitTest_sc_filters_test.mk @@ -109,6 +109,7 @@ $(eval $(call gb_CppunitTest_use_components,sc_filters_test,\ sfx2/util/sfx \ sot/util/sot \ svl/util/svl \ + svtools/util/svt \ toolkit/util/tk \ ucb/source/core/ucb1 \ ucb/source/ucp/file/ucpfile1 \ diff --git a/sc/CppunitTest_sc_macros_test.mk b/sc/CppunitTest_sc_macros_test.mk index c503a0471069..7d1a8fbd241c 100644 --- a/sc/CppunitTest_sc_macros_test.mk +++ b/sc/CppunitTest_sc_macros_test.mk @@ -106,6 +106,7 @@ $(eval $(call gb_CppunitTest_use_components,sc_macros_test,\ sfx2/util/sfx \ sot/util/sot \ svl/source/fsstor/fsstorage \ + svtools/util/svt \ toolkit/util/tk \ ucb/source/core/ucb1 \ ucb/source/ucp/file/ucpfile1 \ diff --git a/sc/CppunitTest_sc_subsequent_filters_test.mk b/sc/CppunitTest_sc_subsequent_filters_test.mk index f52ca4180dfe..b47fe82a97a0 100644 --- a/sc/CppunitTest_sc_subsequent_filters_test.mk +++ b/sc/CppunitTest_sc_subsequent_filters_test.mk @@ -108,6 +108,7 @@ $(eval $(call gb_CppunitTest_use_components,sc_subsequent_filters_test,\ sfx2/util/sfx \ sot/util/sot \ svl/util/svl \ + svtools/util/svt \ toolkit/util/tk \ ucb/source/core/ucb1 \ ucb/source/ucp/file/ucpfile1 \ diff --git a/sd/CppunitTest_sd_filters_test.mk b/sd/CppunitTest_sd_filters_test.mk index 82512dc9f545..6afe52d4d79d 100644 --- a/sd/CppunitTest_sd_filters_test.mk +++ b/sd/CppunitTest_sd_filters_test.mk @@ -99,6 +99,7 @@ $(eval $(call gb_CppunitTest_use_components,sd_filters_test,\ sd/util/sdfilt \ sfx2/util/sfx \ sot/util/sot \ + svtools/util/svt \ toolkit/util/tk \ ucb/source/core/ucb1 \ ucb/source/ucp/file/ucpfile1 \ diff --git a/sd/source/filter/grf/sdgrffilter.cxx b/sd/source/filter/grf/sdgrffilter.cxx index 1db89b3cbaac..2ad8a7abafdb 100644 --- a/sd/source/filter/grf/sdgrffilter.cxx +++ b/sd/source/filter/grf/sdgrffilter.cxx @@ -30,8 +30,10 @@ #ifdef _MSC_VER #pragma warning (disable:4190) #endif +#include <com/sun/star/graphic/GraphicProvider.hpp> #include <com/sun/star/graphic/XGraphicProvider.hpp> #include <com/sun/star/graphic/GraphicType.hpp> +#include <com/sun/star/ucb/SimpleFileAccess.hpp> #include <com/sun/star/ucb/XSimpleFileAccess2.hpp> #include <unotools/localfilehelper.hxx> @@ -381,9 +383,9 @@ void SdGRFFilter::SaveGraphic( const ::com::sun::star::uno::Reference< ::com::su { try { - Reference< XMultiServiceFactory > xSM( ::comphelper::getProcessServiceFactory(), UNO_QUERY_THROW ); + Reference< XComponentContext > xContext = ::comphelper::getProcessComponentContext(); - Reference< XGraphicProvider > xProvider( xSM->createInstance( "com.sun.star.graphic.GraphicProvider" ), UNO_QUERY_THROW ); + Reference< XGraphicProvider > xProvider( GraphicProvider::create(xContext) ); Reference< XPropertySet > xShapeSet( xShape, UNO_QUERY_THROW ); // detect mime type of graphic @@ -523,7 +525,7 @@ void SdGRFFilter::SaveGraphic( const ::com::sun::star::uno::Reference< ::com::su if( xGraphStream.is() ) { - Reference< XSimpleFileAccess2 > xFileAccess( xSM->createInstance("com.sun.star.ucb.SimpleFileAccess" ), UNO_QUERY_THROW ); + Reference< XSimpleFileAccess2 > xFileAccess( SimpleFileAccess::create(xContext) ); xFileAccess->writeFile( sPath, xGraphStream ); } else diff --git a/sd/source/filter/html/buttonset.cxx b/sd/source/filter/html/buttonset.cxx index b819e302d0b2..a22748ca6e01 100644 --- a/sd/source/filter/html/buttonset.cxx +++ b/sd/source/filter/html/buttonset.cxx @@ -28,6 +28,7 @@ #include <com/sun/star/embed/ElementModes.hpp> +#include <com/sun/star/graphic/GraphicProvider.hpp> #include <com/sun/star/graphic/XGraphicProvider.hpp> #include <osl/file.hxx> @@ -261,19 +262,8 @@ Reference< XGraphicProvider > ButtonSetImpl::getGraphicProvider() { if( !mxGraphicProvider.is() ) { - Reference< XMultiServiceFactory > xServiceManager( ::comphelper::getProcessServiceFactory() ); - if( xServiceManager.is() ) try - { - Reference< XGraphicProvider > xGraphProvider( - xServiceManager->createInstance( - ::rtl::OUString( "com.sun.star.graphic.GraphicProvider" ) ), UNO_QUERY_THROW ); - - mxGraphicProvider = xGraphProvider; - } - catch( Exception& ) - { - OSL_FAIL("sd::ButtonSetImpl::getGraphicProvider(), could not get graphic provider!"); - } + Reference< XComponentContext > xComponentContext = ::comphelper::getProcessComponentContext(); + mxGraphicProvider = GraphicProvider::create(xComponentContext); } return mxGraphicProvider; } diff --git a/sd/source/ui/dlg/TemplateScanner.cxx b/sd/source/ui/dlg/TemplateScanner.cxx index a98fa13b3e4d..c9e93c17f995 100644 --- a/sd/source/ui/dlg/TemplateScanner.cxx +++ b/sd/source/ui/dlg/TemplateScanner.cxx @@ -30,6 +30,7 @@ #include "TemplateScanner.hxx" #include <comphelper/processfactory.hxx> +#include <comphelper/componentcontext.hxx> #include <comphelper/documentconstants.hxx> #include <comphelper/string.hxx> @@ -38,6 +39,7 @@ #include <vcl/svapp.hxx> #include <sfx2/doctempl.hxx> #include <sfx2/templatelocnames.hrc> +#include <com/sun/star/frame/DocumentTemplates.hpp> #include <com/sun/star/frame/XDocumentTemplates.hpp> #include <com/sun/star/lang/XMultiServiceFactory.hpp> #include <com/sun/star/ucb/XCommandEnvironment.hpp> @@ -219,22 +221,9 @@ TemplateScanner::State TemplateScanner::GetTemplateRoot (void) { State eNextState (INITIALIZE_FOLDER_SCANNING); - Reference<lang::XMultiServiceFactory> xFactory = ::comphelper::getProcessServiceFactory (); - DBG_ASSERT (xFactory.is(), "TemplateScanner::GetTemplateRoot: xFactory is NULL"); - - if (xFactory.is()) - { - Reference<frame::XDocumentTemplates> xTemplates ( - xFactory->createInstance (rtl::OUString(DOCTEMPLATES)), UNO_QUERY); - DBG_ASSERT (xTemplates.is(), "TemplateScanner::GetTemplateRoot: xTemplates is NULL"); - - if (xTemplates.is()) - mxTemplateRoot = xTemplates->getContent(); - else - eNextState = ERROR; - } - else - eNextState = ERROR; + Reference< XComponentContext > xContext = ::comphelper::getProcessComponentContext(); + Reference<frame::XDocumentTemplates> xTemplates = frame::DocumentTemplates::create(xContext); + mxTemplateRoot = xTemplates->getContent(); return eNextState; } diff --git a/sdext/Library_minimizer.mk b/sdext/Library_minimizer.mk index 5c918c390b51..f19b54168af5 100644 --- a/sdext/Library_minimizer.mk +++ b/sdext/Library_minimizer.mk @@ -35,6 +35,7 @@ $(eval $(call gb_Library_use_api,SunPresentationMinimizer,\ )) $(eval $(call gb_Library_use_libraries,SunPresentationMinimizer,\ + comphelper \ cppu \ cppuhelper \ sal \ diff --git a/sdext/source/minimizer/impoptimizer.cxx b/sdext/source/minimizer/impoptimizer.cxx index befea53dc819..699dc34e09f7 100644 --- a/sdext/source/minimizer/impoptimizer.cxx +++ b/sdext/source/minimizer/impoptimizer.cxx @@ -47,6 +47,7 @@ #include <com/sun/star/frame/XStorable.hpp> #include <com/sun/star/frame/FrameSearchFlag.hpp> #include <com/sun/star/frame/XDispatchProvider.hpp> +#include <com/sun/star/graphic/GraphicProvider.hpp> #include <com/sun/star/graphic/XGraphicProvider.hpp> #include <unotools/configmgr.hxx> #include <com/sun/star/lang/XServiceInfo.hpp> @@ -68,6 +69,7 @@ #include <com/sun/star/io/XSeekable.hpp> #include <com/sun/star/frame/XComponentLoader.hpp> #include <com/sun/star/util/URL.hpp> +#include <comphelper/componentcontext.hxx> using namespace ::std; using namespace ::rtl; @@ -349,7 +351,7 @@ Reference< XGraphic > ImpCompressGraphic( const Reference< XComponentContext >& { Reference< XStream > xTempFile( rxMSF->getServiceManager()->createInstanceWithContext( OUString("com.sun.star.io.TempFile"), rxMSF ), UNO_QUERY_THROW ); Reference< XOutputStream > xOutputStream( xTempFile->getOutputStream() ); - Reference< XGraphicProvider > xGraphicProvider( rxMSF->getServiceManager()->createInstanceWithContext( OUString("com.sun.star.graphic.GraphicProvider"), rxMSF ), UNO_QUERY_THROW ); + Reference< XGraphicProvider > xGraphicProvider( GraphicProvider::create(comphelper::ComponentContext(rxMSF).getUNOContext()) ); ImpCompressGraphic( xGraphicProvider, xGraphic, xOutputStream, aDestMimeType, aLogicalSize, rGraphicSettings.mnJPEGQuality, rGraphicSettings.mnImageResolution, bRemoveCropArea, aGraphicCropLogic ); Reference< XInputStream > xInputStream( xTempFile->getInputStream() ); @@ -369,7 +371,7 @@ Reference< XGraphic > ImpCompressGraphic( const Reference< XComponentContext >& rtl::OUString aDestMimeType( aSourceMimeType ); Reference< XStream > xTempFile( rxMSF->getServiceManager()->createInstanceWithContext( OUString("com.sun.star.io.TempFile"), rxMSF ), UNO_QUERY_THROW ); Reference< XOutputStream > xOutputStream( xTempFile->getOutputStream() ); - Reference< XGraphicProvider > xGraphicProvider( rxMSF->getServiceManager()->createInstanceWithContext( OUString("com.sun.star.graphic.GraphicProvider"), rxMSF ), UNO_QUERY_THROW ); + Reference< XGraphicProvider > xGraphicProvider( GraphicProvider::create( ::comphelper::ComponentContext(rxMSF).getUNOContext() ) ); ImpCompressGraphic( xGraphicProvider, xGraphic, xOutputStream, aDestMimeType, aLogicalSize, rGraphicSettings.mnJPEGQuality, rGraphicSettings.mnImageResolution, sal_False, aGraphicCropLogic ); Reference< XInputStream > xInputStream( xTempFile->getInputStream() ); Reference< XSeekable > xSeekable( xInputStream, UNO_QUERY_THROW ); diff --git a/sdext/source/minimizer/informationdialog.cxx b/sdext/source/minimizer/informationdialog.cxx index 29b6dbeb345e..7f510b657fd9 100644 --- a/sdext/source/minimizer/informationdialog.cxx +++ b/sdext/source/minimizer/informationdialog.cxx @@ -30,12 +30,14 @@ #include "informationdialog.hxx" #include "optimizationstats.hxx" #include <com/sun/star/ui/dialogs/ExecutableDialogResults.hpp> +#include <com/sun/star/graphic/GraphicProvider.hpp> #include <com/sun/star/graphic/XGraphicProvider.hpp> #include <com/sun/star/graphic/XGraphic.hpp> #include <rtl/ustrbuf.hxx> #include <sal/macros.h> #include "com/sun/star/util/URL.hpp" #include "com/sun/star/util/XURLTransformer.hpp" +#include <comphelper/componentcontext.hxx> #define DIALOG_WIDTH 240 #define DIALOG_HEIGHT 80 @@ -218,8 +220,7 @@ OUString InformationDialog::ImpGetStandardImage( const OUString& sPrivateURL ) Reference< XOutputStream > xOutputStream( mxTempFile->getOutputStream() ); if ( xOutputStream.is() && xPropSet.is() ) { - Reference< graphic::XGraphicProvider > xGraphicProvider( mxMSF->getServiceManager()->createInstanceWithContext( - OUString("com.sun.star.graphic.GraphicProvider"), mxMSF ), UNO_QUERY_THROW ); + Reference< graphic::XGraphicProvider > xGraphicProvider( graphic::GraphicProvider::create( ::comphelper::ComponentContext(mxMSF).getUNOContext() ) ); Sequence< PropertyValue > aArgs( 1 ); aArgs[ 0 ].Name = OUString("URL"); aArgs[ 0 ].Value <<= sPrivateURL; diff --git a/sfx2/source/dialog/taskpane.cxx b/sfx2/source/dialog/taskpane.cxx index 6169998dd946..5adaedb0268b 100644 --- a/sfx2/source/dialog/taskpane.cxx +++ b/sfx2/source/dialog/taskpane.cxx @@ -42,6 +42,7 @@ #include <com/sun/star/ui/XUIElementFactory.hpp> #include <com/sun/star/awt/XWindowPeer.hpp> #include <com/sun/star/awt/PosSize.hpp> +#include <com/sun/star/graphic/GraphicProvider.hpp> #include <com/sun/star/graphic/XGraphicProvider.hpp> #include <com/sun/star/accessibility/XAccessible.hpp> #include <com/sun/star/awt/XControl.hpp> @@ -69,6 +70,7 @@ namespace sfx2 /** === begin UNO using === **/ using ::com::sun::star::uno::Reference; + using ::com::sun::star::uno::XComponentContext; using ::com::sun::star::uno::XInterface; using ::com::sun::star::uno::UNO_QUERY; using ::com::sun::star::uno::UNO_QUERY_THROW; @@ -188,8 +190,8 @@ namespace sfx2 } // otherwise, delegate to the GraphicProvider - const ::comphelper::ComponentContext aContext( ::comphelper::getProcessServiceFactory() ); - const Reference< XGraphicProvider > xGraphicProvider( aContext.createComponent( "com.sun.star.graphic.GraphicProvider" ), UNO_QUERY_THROW ); + const Reference< XComponentContext > xContext( ::comphelper::getProcessComponentContext() ); + const Reference< XGraphicProvider > xGraphicProvider( com::sun::star::graphic::GraphicProvider::create(xContext) ); const Reference< XGraphic > xGraphic( xGraphicProvider->queryGraphic( aMediaProperties.getPropertyValues() ), UNO_SET_THROW ); return Image( xGraphic ); diff --git a/sfx2/source/doc/doctempl.cxx b/sfx2/source/doc/doctempl.cxx index 2e256a2d20a1..130a7c656f57 100644 --- a/sfx2/source/doc/doctempl.cxx +++ b/sfx2/source/doc/doctempl.cxx @@ -51,6 +51,7 @@ #include <com/sun/star/document/XTypeDetection.hpp> #include <com/sun/star/document/XDocumentPropertiesSupplier.hpp> #include <com/sun/star/frame/XComponentLoader.hpp> +#include <com/sun/star/frame/DocumentTemplates.hpp> #include <com/sun/star/frame/XDocumentTemplates.hpp> #include <com/sun/star/io/XInputStream.hpp> #include <com/sun/star/io/XPersist.hpp> @@ -113,7 +114,6 @@ using ::std::advance; #define COMMAND_TRANSFER "transfer" #define SERVICENAME_DOCINFO "com.sun.star.document.DocumentProperties" -#define SERVICENAME_DOCTEMPLATES "com.sun.star.frame.DocumentTemplates" #define SERVICENAME_DESKTOP "com.sun.star.frame.Desktop" //======================================================================== @@ -2053,31 +2053,25 @@ sal_Bool SfxDocTemplate_Impl::Construct( ) if ( mbConstructed ) return sal_True; - uno::Reference< XMultiServiceFactory > xFactory; - xFactory = ::comphelper::getProcessServiceFactory(); + uno::Reference< XMultiServiceFactory > xFactory = ::comphelper::getProcessServiceFactory(); + uno::Reference< XComponentContext > xContext = ::comphelper::getProcessComponentContext(); OUString aService( SERVICENAME_DOCINFO ); uno::Reference< XPersist > xInfo( xFactory->createInstance( aService ), UNO_QUERY ); mxInfo = xInfo; - aService = OUString( SERVICENAME_DOCTEMPLATES ); - uno::Reference< XDocumentTemplates > xTemplates( xFactory->createInstance( aService ), UNO_QUERY ); + mxTemplates = frame::DocumentTemplates::create(xContext); - if ( xTemplates.is() ) - mxTemplates = xTemplates; - else - return sal_False; - - uno::Reference< XLocalizable > xLocalizable( xTemplates, UNO_QUERY ); + uno::Reference< XLocalizable > xLocalizable( mxTemplates, UNO_QUERY ); Sequence< Any > aCompareArg(1); - *(aCompareArg.getArray()) <<= xLocalizable->getLocale();; + *(aCompareArg.getArray()) <<= xLocalizable->getLocale(); m_rCompareFactory = uno::Reference< XAnyCompareFactory >( xFactory->createInstanceWithArguments( OUString("com.sun.star.ucb.AnyCompareFactory"), aCompareArg ), UNO_QUERY ); - uno::Reference < XContent > aRootContent = xTemplates->getContent(); + uno::Reference < XContent > aRootContent = mxTemplates->getContent(); uno::Reference < XCommandEnvironment > aCmdEnv; if ( ! aRootContent.is() ) diff --git a/sfx2/source/doc/graphhelp.cxx b/sfx2/source/doc/graphhelp.cxx index 11acd56c6c10..e7ec525d7eaa 100644 --- a/sfx2/source/doc/graphhelp.cxx +++ b/sfx2/source/doc/graphhelp.cxx @@ -56,6 +56,7 @@ #include <com/sun/star/uno/Exception.hpp> #include <com/sun/star/datatransfer/XTransferable.hpp> #include <com/sun/star/lang/XMultiServiceFactory.hpp> +#include <com/sun/star/graphic/GraphicProvider.hpp> #include <com/sun/star/graphic/XGraphicProvider.hpp> #include <com/sun/star/graphic/XGraphic.hpp> #include <com/sun/star/io/XStream.hpp> @@ -455,42 +456,33 @@ sal_Bool GraphicHelper::getThumbnailReplacement_Impl( sal_Int32 nResID, const un sal_Bool bResult = sal_False; if ( nResID && xStream.is() ) { - uno::Reference< lang::XMultiServiceFactory > xServiceManager = ::comphelper::getProcessServiceFactory(); - if ( xServiceManager.is() ) + uno::Reference< uno::XComponentContext > xContext = ::comphelper::getProcessComponentContext(); + try { - try - { - uno::Reference< graphic::XGraphicProvider > xGraphProvider( - xServiceManager->createInstance( - "com.sun.star.graphic.GraphicProvider") , - uno::UNO_QUERY ); - if ( xGraphProvider.is() ) - { - ::rtl::OUString aURL("private:resource/sfx/bitmapex/"); - aURL += ::rtl::OUString::valueOf( nResID ); + uno::Reference< graphic::XGraphicProvider > xGraphProvider(graphic::GraphicProvider::create(xContext)); + ::rtl::OUString aURL("private:resource/sfx/bitmapex/"); + aURL += ::rtl::OUString::valueOf( nResID ); - uno::Sequence< beans::PropertyValue > aMediaProps( 1 ); - aMediaProps[0].Name = "URL"; - aMediaProps[0].Value <<= aURL; + uno::Sequence< beans::PropertyValue > aMediaProps( 1 ); + aMediaProps[0].Name = "URL"; + aMediaProps[0].Value <<= aURL; - uno::Reference< graphic::XGraphic > xGraphic = xGraphProvider->queryGraphic( aMediaProps ); - if ( xGraphic.is() ) - { - uno::Sequence< beans::PropertyValue > aStoreProps( 2 ); - aStoreProps[0].Name = "OutputStream"; - aStoreProps[0].Value <<= xStream; - aStoreProps[1].Name = "MimeType"; - aStoreProps[1].Value <<= ::rtl::OUString("image/png"); - - xGraphProvider->storeGraphic( xGraphic, aStoreProps ); - bResult = sal_True; - } - } - } - catch(const uno::Exception&) + uno::Reference< graphic::XGraphic > xGraphic = xGraphProvider->queryGraphic( aMediaProps ); + if ( xGraphic.is() ) { + uno::Sequence< beans::PropertyValue > aStoreProps( 2 ); + aStoreProps[0].Name = "OutputStream"; + aStoreProps[0].Value <<= xStream; + aStoreProps[1].Name = "MimeType"; + aStoreProps[1].Value <<= ::rtl::OUString("image/png"); + + xGraphProvider->storeGraphic( xGraphic, aStoreProps ); + bResult = sal_True; } } + catch(const uno::Exception&) + { + } } return bResult; diff --git a/sfx2/source/doc/objserv.cxx b/sfx2/source/doc/objserv.cxx index 34565c86b979..7b4475af6753 100644 --- a/sfx2/source/doc/objserv.cxx +++ b/sfx2/source/doc/objserv.cxx @@ -42,6 +42,7 @@ #include <com/sun/star/task/XInteractionHandler.hpp> #include <com/sun/star/task/XStatusIndicator.hpp> #include <com/sun/star/task/XStatusIndicatorFactory.hpp> +#include <com/sun/star/frame/DocumentTemplates.hpp> #include <com/sun/star/frame/XDocumentTemplates.hpp> #include <com/sun/star/frame/XStorable.hpp> #include <comphelper/processfactory.hxx> @@ -859,10 +860,8 @@ void SfxObjectShell::ExecFile_Impl(SfxRequest &rReq) try { uno::Reference< frame::XStorable > xStorable( GetModel(), uno::UNO_QUERY_THROW ); - ::rtl::OUString aService( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.frame.DocumentTemplates" ) ); uno::Reference< frame::XDocumentTemplates > xTemplates( - comphelper::getProcessServiceFactory()->createInstance( aService ), - uno::UNO_QUERY_THROW ); + frame::DocumentTemplates::create(comphelper::getProcessComponentContext()) ); bOk = xTemplates->storeTemplate( aTemplateGroup, aTemplateName, xStorable ); } diff --git a/sfx2/source/doc/plugin.cxx b/sfx2/source/doc/plugin.cxx index 68fb03b71d10..5f86248c285f 100644 --- a/sfx2/source/doc/plugin.cxx +++ b/sfx2/source/doc/plugin.cxx @@ -28,10 +28,12 @@ #include "plugin.hxx" +#include <com/sun/star/plugin/PluginManager.hpp> #include <com/sun/star/plugin/XPluginManager.hpp> #include <com/sun/star/plugin/PluginMode.hpp> #include <com/sun/star/awt/XControl.hpp> +#include <comphelper/componentcontext.hxx> #include <rtl/ustring.hxx> #include <toolkit/helper/vclunohelper.hxx> #include <svtools/miscopt.hxx> @@ -101,9 +103,7 @@ sal_Bool SAL_CALL PluginObject::load( const uno::Reference < frame::XFrame >& xFrame ) throw( uno::RuntimeException ) { - uno::Reference< plugin::XPluginManager > xPMgr( mxFact->createInstance( ::rtl::OUString("com.sun.star.plugin.PluginManager") ), uno::UNO_QUERY ); - if (!xPMgr.is() ) - return sal_False; + uno::Reference< plugin::XPluginManager > xPMgr( plugin::PluginManager::create(comphelper::ComponentContext(mxFact).getUNOContext()) ); if ( SvtMiscOptions().IsPluginsEnabled() ) { diff --git a/svtools/source/contnr/templwin.cxx b/svtools/source/contnr/templwin.cxx index aed37c9a3fea..a0f5a7b39e89 100644 --- a/svtools/source/contnr/templwin.cxx +++ b/svtools/source/contnr/templwin.cxx @@ -54,6 +54,7 @@ #include <com/sun/star/util/XURLTransformer.hpp> #include <com/sun/star/util/XOfficeInstallationDirectories.hpp> #include <com/sun/star/frame/XDispatchProvider.hpp> +#include <com/sun/star/frame/DocumentTemplates.hpp> #include <com/sun/star/frame/XDocumentTemplates.hpp> #include <com/sun/star/frame/XComponentLoader.hpp> #include <com/sun/star/beans/PropertyValue.hpp> @@ -176,17 +177,13 @@ SvtIconWindow_Impl::SvtIconWindow_Impl( Window* pParent ) : aIconCtrl.Show(); // detect the root URL of templates - Reference< XDocumentTemplates > xTemplates( ::comphelper::getProcessServiceFactory()-> - createInstance( ASCII_STR("com.sun.star.frame.DocumentTemplates") ), UNO_QUERY ); + Reference< XDocumentTemplates > xTemplates( frame::DocumentTemplates::create(::comphelper::getProcessComponentContext()) ); - if ( xTemplates.is() ) - { - Reference < XContent > aRootContent = xTemplates->getContent(); - Reference < XCommandEnvironment > aCmdEnv; + Reference < XContent > aRootContent = xTemplates->getContent(); + Reference < XCommandEnvironment > aCmdEnv; - if ( aRootContent.is() ) - aTemplateRootURL = aRootContent->getIdentifier()->getContentIdentifier(); - } + if ( aRootContent.is() ) + aTemplateRootURL = aRootContent->getIdentifier()->getContentIdentifier(); // insert the categories // "New Document" @@ -1644,35 +1641,31 @@ IMPL_LINK_NOARG(SvtDocumentTemplateDialog , OrganizerHdl_Impl) IMPL_LINK ( SvtDocumentTemplateDialog, UpdateHdl_Impl, Timer*, _pEventSource ) { pImpl->pWin->SetFocus( sal_False ); - Reference< XDocumentTemplates > xTemplates( ::comphelper::getProcessServiceFactory()-> - createInstance( ASCII_STR("com.sun.star.frame.DocumentTemplates") ), UNO_QUERY ); - if ( xTemplates.is() ) - { - if ( _pEventSource ) - { // it was no direct call, which means it was triggered by the timer, which means we alread checked the necessity - WaitObject aWaitCursor( this ); - xTemplates->update(); - if ( pImpl->pWin->IsTemplateFolderOpen() ) - { - pImpl->pWin->ClearHistory(); - pImpl->pWin->OpenTemplateRoot(); - } - } - else + Reference< XDocumentTemplates > xTemplates( frame::DocumentTemplates::create(::comphelper::getProcessComponentContext()) ); + if ( _pEventSource ) + { // it was no direct call, which means it was triggered by the timer, which means we alread checked the necessity + WaitObject aWaitCursor( this ); + xTemplates->update(); + if ( pImpl->pWin->IsTemplateFolderOpen() ) { - // check if we really need to do the update - ::svt::TemplateFolderCache aCache; - if ( aCache.needsUpdate() ) - { // yes -> do it asynchronous (it will take a noticeable time) - - // (but first store the current state) - aCache.storeState(); - - // start the timer for the async update - pImpl->aUpdateTimer.SetTimeout( 300 ); - pImpl->aUpdateTimer.SetTimeoutHdl( LINK( this, SvtDocumentTemplateDialog, UpdateHdl_Impl ) ); - pImpl->aUpdateTimer.Start(); - } + pImpl->pWin->ClearHistory(); + pImpl->pWin->OpenTemplateRoot(); + } + } + else + { + // check if we really need to do the update + ::svt::TemplateFolderCache aCache; + if ( aCache.needsUpdate() ) + { // yes -> do it asynchronous (it will take a noticeable time) + + // (but first store the current state) + aCache.storeState(); + + // start the timer for the async update + pImpl->aUpdateTimer.SetTimeout( 300 ); + pImpl->aUpdateTimer.SetTimeoutHdl( LINK( this, SvtDocumentTemplateDialog, UpdateHdl_Impl ) ); + pImpl->aUpdateTimer.Start(); } } return 0; diff --git a/svtools/source/misc/imageresourceaccess.cxx b/svtools/source/misc/imageresourceaccess.cxx index 7ffbec2ba90b..92f08a2c42e8 100644 --- a/svtools/source/misc/imageresourceaccess.cxx +++ b/svtools/source/misc/imageresourceaccess.cxx @@ -32,6 +32,7 @@ /** === begin UNO includes === **/ #include <com/sun/star/io/NotConnectedException.hpp> #include <com/sun/star/io/XSeekable.hpp> +#include <com/sun/star/graphic/GraphicProvider.hpp> #include <com/sun/star/graphic/XGraphicProvider.hpp> #include <com/sun/star/io/XStream.hpp> /** === end UNO includes === **/ @@ -39,6 +40,7 @@ #include <tools/stream.hxx> #include <unotools/streamwrap.hxx> #include <cppuhelper/implbase2.hxx> +#include <comphelper/componentcontext.hxx> //........................................................................ namespace svt @@ -154,13 +156,7 @@ namespace svt try { // get a GraphicProvider - Reference< XGraphicProvider > xProvider; - if ( _rxORB.is() ) - xProvider = xProvider.query( _rxORB->createInstance( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.graphic.GraphicProvider" ) ) ) ); - OSL_ENSURE( xProvider.is(), "GraphicAccess::getImageStream: could not create a graphic provider!" ); - - if ( !xProvider.is() ) - return pReturn; + Reference< XGraphicProvider > xProvider = ::com::sun::star::graphic::GraphicProvider::create(comphelper::ComponentContext(_rxORB).getUNOContext()); // let it create a graphic from the given URL Sequence< PropertyValue > aMediaProperties( 1 ); diff --git a/svtools/source/uno/treecontrolpeer.cxx b/svtools/source/uno/treecontrolpeer.cxx index aea3cd62c563..15bb2da3720c 100644 --- a/svtools/source/uno/treecontrolpeer.cxx +++ b/svtools/source/uno/treecontrolpeer.cxx @@ -28,6 +28,7 @@ #define _SVTREEBX_CXX +#include <com/sun/star/graphic/GraphicProvider.hpp> #include <com/sun/star/lang/XServiceInfo.hpp> #include <com/sun/star/lang/DisposedException.hpp> #include <com/sun/star/view/SelectionType.hpp> @@ -1477,14 +1478,10 @@ bool TreeControlPeer::loadImage( const ::rtl::OUString& rURL, Image& rImage ) { if( !mxGraphicProvider.is() ) { - static const OUString aSN( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.graphic.GraphicProvider" ) ); - Reference< XMultiServiceFactory > xORB( ::comphelper::getProcessServiceFactory() ); - if( xORB.is() ) - { - Reference< XInterface > x( xORB->createInstance( aSN ) ); - mxGraphicProvider.query( x ); - mxGraphicProvider = Reference< XGraphicProvider >( x, UNO_QUERY ); - } + Reference< XComponentContext > xContext( ::comphelper::getProcessComponentContext() ); + Reference< XInterface > x( graphic::GraphicProvider::create(xContext) ); + mxGraphicProvider.query( x ); + mxGraphicProvider = Reference< XGraphicProvider >( x, UNO_QUERY ); } if( mxGraphicProvider.is() ) try diff --git a/svx/source/dialog/pfiledlg.cxx b/svx/source/dialog/pfiledlg.cxx index 340e549b5300..e3e4225e8000 100644 --- a/svx/source/dialog/pfiledlg.cxx +++ b/svx/source/dialog/pfiledlg.cxx @@ -30,6 +30,7 @@ // include --------------------------------------------------------------- #include <sfx2/docfile.hxx> #include <com/sun/star/plugin/PluginDescription.hpp> +#include <com/sun/star/plugin/PluginManager.hpp> #include <com/sun/star/plugin/XPluginManager.hpp> #include <com/sun/star/ui/dialogs/TemplateDescription.hpp> @@ -78,111 +79,104 @@ SvxPluginFileDlg::SvxPluginFileDlg (Window *, sal_uInt16 nKind ) } // fill the filterlist of the filedialog with data of installed plugins - uno::Reference< lang::XMultiServiceFactory > xMgr( ::comphelper::getProcessServiceFactory() ); + uno::Reference< uno::XComponentContext > xContext = comphelper::getProcessComponentContext(); + uno::Reference< plugin::XPluginManager > rPluginManager( plugin::PluginManager::create(xContext) ); - if( xMgr.is() ) + const uno::Sequence<plugin::PluginDescription > aSeq( rPluginManager->getPluginDescriptions() ); + const plugin::PluginDescription* pDescription = aSeq.getConstArray(); + sal_Int32 nAnzahlPlugins = rPluginManager->getPluginDescriptions().getLength(); + + std::list< String > aPlugNames; + std::list< String > aPlugExtensions; + std::list< String >::iterator j; + std::list< String >::iterator k; + std::list< String >::const_iterator end; + + for ( int i = 0; i < nAnzahlPlugins; i++ ) { - uno::Reference< plugin::XPluginManager > rPluginManager( xMgr->createInstance( - OUString("com.sun.star.plugin.PluginManager") ), uno::UNO_QUERY ); - if ( rPluginManager.is() ) - { - const uno::Sequence<plugin::PluginDescription > aSeq( rPluginManager->getPluginDescriptions() ); - const plugin::PluginDescription* pDescription = aSeq.getConstArray(); - sal_Int32 nAnzahlPlugins = rPluginManager->getPluginDescriptions().getLength(); + String aStrPlugMIMEType( pDescription[i].Mimetype ); + String aStrPlugName( pDescription[i].Description ); + String aStrPlugExtension( pDescription[i].Extension ); - std::list< String > aPlugNames; - std::list< String > aPlugExtensions; - std::list< String >::iterator j; - std::list< String >::iterator k; - std::list< String >::const_iterator end; + aStrPlugMIMEType.ToLowerAscii(); + aStrPlugExtension.ToLowerAscii(); - for ( int i = 0; i < nAnzahlPlugins; i++ ) + if ( ( nKind == SID_INSERT_SOUND && aStrPlugMIMEType.SearchAscii ( sAudio ) == 0 ) || + ( nKind == SID_INSERT_VIDEO && aStrPlugMIMEType.SearchAscii ( sVideo ) == 0 ) ) + { + // extension already in the filterlist of the filedlg ? + sal_Bool bAlreadyExist = sal_False; + for ( j = aPlugExtensions.begin(), end = aPlugExtensions.end(); j != end && !bAlreadyExist; ++j ) { - String aStrPlugMIMEType( pDescription[i].Mimetype ); - String aStrPlugName( pDescription[i].Description ); - String aStrPlugExtension( pDescription[i].Extension ); - - aStrPlugMIMEType.ToLowerAscii(); - aStrPlugExtension.ToLowerAscii(); + bAlreadyExist = (j->Search( aStrPlugExtension ) != STRING_NOTFOUND ); + } - if ( ( nKind == SID_INSERT_SOUND && aStrPlugMIMEType.SearchAscii ( sAudio ) == 0 ) || - ( nKind == SID_INSERT_VIDEO && aStrPlugMIMEType.SearchAscii ( sVideo ) == 0 ) ) + if ( !bAlreadyExist ) + { + // filterdescription already there? + // (then append the new extension to the existing filter) + int nfound = -1; + for ( j = aPlugNames.begin(), + k = aPlugExtensions.begin(), + end = aPlugNames.end(); + j != end && nfound != 0; ) { - // extension already in the filterlist of the filedlg ? - sal_Bool bAlreadyExist = sal_False; - for ( j = aPlugExtensions.begin(), end = aPlugExtensions.end(); j != end && !bAlreadyExist; ++j ) + if ( ( nfound = j->Search( aStrPlugName ) ) == 0 ) { - bAlreadyExist = (j->Search( aStrPlugExtension ) != STRING_NOTFOUND ); - } + if ( aStrPlugExtension.Len() > 0 ) + aStrPlugExtension.Insert( sal_Unicode( ';' ) ); + aStrPlugExtension.Insert( *k ); - if ( !bAlreadyExist ) + // remove old entry, increment (iterators are invalid thereafter, thus the postincrement) + aPlugNames.erase(j++); aPlugExtensions.erase(k++); + + // update end iterator (which may be invalid, too!) + end = aPlugNames.end(); + } + else { - // filterdescription already there? - // (then append the new extension to the existing filter) - int nfound = -1; - for ( j = aPlugNames.begin(), - k = aPlugExtensions.begin(), - end = aPlugNames.end(); - j != end && nfound != 0; ) - { - if ( ( nfound = j->Search( aStrPlugName ) ) == 0 ) - { - if ( aStrPlugExtension.Len() > 0 ) - aStrPlugExtension.Insert( sal_Unicode( ';' ) ); - aStrPlugExtension.Insert( *k ); - - // remove old entry, increment (iterators are invalid thereafter, thus the postincrement) - aPlugNames.erase(j++); aPlugExtensions.erase(k++); - - // update end iterator (which may be invalid, too!) - end = aPlugNames.end(); - } - else - { - // next element - ++j; ++k; - } - } - - // build filterdescription - aStrPlugName.AppendAscii( RTL_CONSTASCII_STRINGPARAM( " (" ) ); - aStrPlugName.Append( aStrPlugExtension ); - aStrPlugName.AppendAscii( RTL_CONSTASCII_STRINGPARAM( ")" ) ); - - // use a own description for the video-formate avi, mov and mpeg - // the descriptions of these MIME-types are not very meaningful - const sal_Char sAVI[] = "*.avi"; - const sal_Char sMOV[] = "*.mov"; - const sal_Char sMPG[] = "*.mpg"; - const sal_Char sMPE[] = "*.mpe"; - const sal_Char sMPEG[] = "*.mpeg"; - - if ( aStrPlugExtension.EqualsIgnoreCaseAscii( sAVI ) ) - aStrPlugName = SVX_RESSTR( STR_INSERT_VIDEO_EXTFILTER_AVI ); - else if ( aStrPlugExtension.EqualsIgnoreCaseAscii( sMOV ) ) - aStrPlugName = SVX_RESSTR( STR_INSERT_VIDEO_EXTFILTER_MOV ); - else if ( aStrPlugExtension.SearchAscii( sMPG ) != STRING_NOTFOUND || - aStrPlugExtension.SearchAscii( sMPE ) != STRING_NOTFOUND || - aStrPlugExtension.SearchAscii( sMPEG ) != STRING_NOTFOUND ) - aStrPlugName = SVX_RESSTR(STR_INSERT_VIDEO_EXTFILTER_MPEG); - - aPlugNames.push_back( aStrPlugName ); - aPlugExtensions.push_back( aStrPlugExtension ); + // next element + ++j; ++k; } } - } - // add filter to dialog - for ( j = aPlugNames.begin(), - k = aPlugExtensions.begin(), - end = aPlugNames.end(); - j != end; ++j, ++k ) - { - maFileDlg.AddFilter( *j, *k ); + // build filterdescription + aStrPlugName.AppendAscii( RTL_CONSTASCII_STRINGPARAM( " (" ) ); + aStrPlugName.Append( aStrPlugExtension ); + aStrPlugName.AppendAscii( RTL_CONSTASCII_STRINGPARAM( ")" ) ); + + // use a own description for the video-formate avi, mov and mpeg + // the descriptions of these MIME-types are not very meaningful + const sal_Char sAVI[] = "*.avi"; + const sal_Char sMOV[] = "*.mov"; + const sal_Char sMPG[] = "*.mpg"; + const sal_Char sMPE[] = "*.mpe"; + const sal_Char sMPEG[] = "*.mpeg"; + + if ( aStrPlugExtension.EqualsIgnoreCaseAscii( sAVI ) ) + aStrPlugName = SVX_RESSTR( STR_INSERT_VIDEO_EXTFILTER_AVI ); + else if ( aStrPlugExtension.EqualsIgnoreCaseAscii( sMOV ) ) + aStrPlugName = SVX_RESSTR( STR_INSERT_VIDEO_EXTFILTER_MOV ); + else if ( aStrPlugExtension.SearchAscii( sMPG ) != STRING_NOTFOUND || + aStrPlugExtension.SearchAscii( sMPE ) != STRING_NOTFOUND || + aStrPlugExtension.SearchAscii( sMPEG ) != STRING_NOTFOUND ) + aStrPlugName = SVX_RESSTR(STR_INSERT_VIDEO_EXTFILTER_MPEG); + + aPlugNames.push_back( aStrPlugName ); + aPlugExtensions.push_back( aStrPlugExtension ); } } } + // add filter to dialog + for ( j = aPlugNames.begin(), + k = aPlugExtensions.begin(), + end = aPlugNames.end(); + j != end; ++j, ++k ) + { + maFileDlg.AddFilter( *j, *k ); + } + // add the All-Filter String aAllFilter( ResId( STR_EXTFILTER_ALL, DIALOG_MGR() ) ); maFileDlg.AddFilter( aAllFilter, UniString::CreateFromAscii( RTL_CONSTASCII_STRINGPARAM( "*.*" ) ) ); diff --git a/sw/CppunitTest_sw_filters_test.mk b/sw/CppunitTest_sw_filters_test.mk index 6a91e04c44c2..3b6bcecd926a 100644 --- a/sw/CppunitTest_sw_filters_test.mk +++ b/sw/CppunitTest_sw_filters_test.mk @@ -83,6 +83,7 @@ $(eval $(call gb_CppunitTest_use_components,sw_filters_test,\ i18npool/util/i18npool \ package/util/package2 \ sfx2/util/sfx \ + svtools/util/svt \ sw/util/msword \ sw/util/sw \ toolkit/util/tk \ diff --git a/sw/CppunitTest_sw_subsequent_rtfexport.mk b/sw/CppunitTest_sw_subsequent_rtfexport.mk index f763e5d6bd31..3943f7ebf6c6 100644 --- a/sw/CppunitTest_sw_subsequent_rtfexport.mk +++ b/sw/CppunitTest_sw_subsequent_rtfexport.mk @@ -61,6 +61,7 @@ $(eval $(call gb_CppunitTest_use_components,sw_subsequent_rtfexport,\ package/util/package2 \ sfx2/util/sfx \ svl/source/fsstor/fsstorage \ + svtools/util/svt \ sw/util/msword \ sw/util/sw \ sw/util/swd \ diff --git a/sw/CppunitTest_sw_subsequent_ww8tok.mk b/sw/CppunitTest_sw_subsequent_ww8tok.mk index 069c9179419d..80e00891f266 100644 --- a/sw/CppunitTest_sw_subsequent_ww8tok.mk +++ b/sw/CppunitTest_sw_subsequent_ww8tok.mk @@ -64,6 +64,7 @@ $(eval $(call gb_CppunitTest_use_components,sw_subsequent_ww8tok,\ sw/util/swd \ sfx2/util/sfx \ svl/source/fsstor/fsstorage \ + svtools/util/svt \ toolkit/util/tk \ ucb/source/core/ucb1 \ ucb/source/ucp/file/ucpfile1 \ diff --git a/sw/source/ui/fldui/fldmgr.cxx b/sw/source/ui/fldui/fldmgr.cxx index c809eead276d..3d1bae935b81 100644 --- a/sw/source/ui/fldui/fldmgr.cxx +++ b/sw/source/ui/fldui/fldmgr.cxx @@ -32,6 +32,7 @@ #include <svl/stritem.hxx> #include <com/sun/star/lang/XMultiServiceFactory.hpp> #include <com/sun/star/container/XNameAccess.hpp> +#include <com/sun/star/text/DefaultNumberingProvider.hpp> #include <com/sun/star/text/XDefaultNumberingProvider.hpp> #include <com/sun/star/text/XNumberingTypeInfo.hpp> #include <com/sun/star/style/NumberingType.hpp> @@ -1757,11 +1758,8 @@ Reference<XNumberingTypeInfo> SwFldMgr::GetNumberingInfo() const { if(!xNumberingInfo.is()) { - Reference< XMultiServiceFactory > xMSF = ::comphelper::getProcessServiceFactory(); - Reference < XInterface > xI = xMSF->createInstance( - ::rtl::OUString( "com.sun.star.text.DefaultNumberingProvider" )); - Reference<XDefaultNumberingProvider> xDefNum(xI, UNO_QUERY); - OSL_ENSURE(xDefNum.is(), "service missing: \"com.sun.star.text.DefaultNumberingProvider\""); + Reference<XComponentContext> xContext( ::comphelper::getProcessComponentContext() ); + Reference<XDefaultNumberingProvider> xDefNum = text::DefaultNumberingProvider::create(xContext); ((SwFldMgr*)this)->xNumberingInfo = Reference<XNumberingTypeInfo>(xDefNum, UNO_QUERY); } return xNumberingInfo; diff --git a/sw/source/ui/misc/numberingtypelistbox.cxx b/sw/source/ui/misc/numberingtypelistbox.cxx index 8a091f112fcf..4f25c4bb2642 100644 --- a/sw/source/ui/misc/numberingtypelistbox.cxx +++ b/sw/source/ui/misc/numberingtypelistbox.cxx @@ -30,6 +30,7 @@ #include <misc.hrc> #include <cnttab.hxx> #include <com/sun/star/style/NumberingType.hpp> +#include <com/sun/star/text/DefaultNumberingProvider.hpp> #include <com/sun/star/text/XDefaultNumberingProvider.hpp> #include <comphelper/processfactory.hxx> #include <com/sun/star/text/XNumberingTypeInfo.hpp> @@ -50,11 +51,8 @@ SwNumberingTypeListBox::SwNumberingTypeListBox( Window* pWin, const ResId& rResI ListBox(pWin, rResId), pImpl(new SwNumberingTypeListBox_Impl) { - uno::Reference< lang::XMultiServiceFactory > xMSF = ::comphelper::getProcessServiceFactory(); - uno::Reference < uno::XInterface > xI = xMSF->createInstance( - ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.text.DefaultNumberingProvider")) ); - uno::Reference<text::XDefaultNumberingProvider> xDefNum(xI, uno::UNO_QUERY); - OSL_ENSURE(xDefNum.is(), "service missing: \"com.sun.star.text.DefaultNumberingProvider\""); + uno::Reference<uno::XComponentContext> xContext( ::comphelper::getProcessComponentContext() ); + uno::Reference<text::XDefaultNumberingProvider> xDefNum = text::DefaultNumberingProvider::create(xContext); pImpl->xInfo = uno::Reference<text::XNumberingTypeInfo>(xDefNum, uno::UNO_QUERY); Reload(nTypeFlags); diff --git a/toolkit/source/awt/animatedimagespeer.cxx b/toolkit/source/awt/animatedimagespeer.cxx index f1f5541a96cb..124dcdb88646 100644 --- a/toolkit/source/awt/animatedimagespeer.cxx +++ b/toolkit/source/awt/animatedimagespeer.cxx @@ -32,6 +32,7 @@ /** === begin UNO includes === **/ #include <com/sun/star/awt/XAnimatedImages.hpp> #include <com/sun/star/awt/Size.hpp> +#include <com/sun/star/graphic/GraphicProvider.hpp> #include <com/sun/star/graphic/XGraphicProvider.hpp> #include <com/sun/star/beans/XPropertySet.hpp> #include <com/sun/star/graphic/XGraphic.hpp> @@ -55,6 +56,7 @@ namespace toolkit //...................................................................................................................... /** === begin UNO using === **/ + using ::com::sun::star::uno::XComponentContext; using ::com::sun::star::uno::Reference; using ::com::sun::star::uno::XInterface; using ::com::sun::star::uno::UNO_QUERY; @@ -198,8 +200,8 @@ namespace toolkit try { // collect the image sizes of the different image sets - const ::comphelper::ComponentContext aContext( ::comphelper::getProcessServiceFactory() ); - const Reference< XGraphicProvider > xGraphicProvider( aContext.createComponent( "com.sun.star.graphic.GraphicProvider" ), UNO_QUERY_THROW ); + const Reference< XComponentContext > xContext( ::comphelper::getProcessComponentContext() ); + const Reference< XGraphicProvider > xGraphicProvider( com::sun::star::graphic::GraphicProvider::create(xContext) ); const bool isHighContrast = pThrobber->GetSettings().GetStyleSettings().GetHighContrastMode(); diff --git a/toolkit/source/awt/vclxwindows.cxx b/toolkit/source/awt/vclxwindows.cxx index 4ae8be922f8c..58107894d93b 100644 --- a/toolkit/source/awt/vclxwindows.cxx +++ b/toolkit/source/awt/vclxwindows.cxx @@ -28,6 +28,7 @@ #include <toolkit/awt/vclxwindows.hxx> #include <com/sun/star/awt/ScrollBarOrientation.hpp> +#include <com/sun/star/graphic/GraphicProvider.hpp> #include <com/sun/star/graphic/XGraphicProvider.hpp> #include <toolkit/helper/vclunohelper.hxx> #include <toolkit/helper/macros.hxx> @@ -2065,15 +2066,12 @@ namespace try { - ::comphelper::ComponentContext aContext( ::comphelper::getProcessServiceFactory() ); - Reference< XGraphicProvider > xProvider; - if ( aContext.createComponent( "com.sun.star.graphic.GraphicProvider", xProvider ) ) - { - ::comphelper::NamedValueCollection aMediaProperties; - aMediaProperties.put( "URL", i_rImageURL ); - Reference< XGraphic > xGraphic = xProvider->queryGraphic( aMediaProperties.getPropertyValues() ); - return Image( xGraphic ); - } + Reference< uno::XComponentContext > xContext( ::comphelper::getProcessComponentContext() ); + Reference< XGraphicProvider > xProvider(graphic::GraphicProvider::create(xContext)); + ::comphelper::NamedValueCollection aMediaProperties; + aMediaProperties.put( "URL", i_rImageURL ); + Reference< XGraphic > xGraphic = xProvider->queryGraphic( aMediaProperties.getPropertyValues() ); + return Image( xGraphic ); } catch( const uno::Exception& ) { diff --git a/toolkit/source/controls/unocontrols.cxx b/toolkit/source/controls/unocontrols.cxx index f9925632d9a7..3da984802618 100644 --- a/toolkit/source/controls/unocontrols.cxx +++ b/toolkit/source/controls/unocontrols.cxx @@ -32,6 +32,7 @@ #include <com/sun/star/awt/PosSize.hpp> #include <com/sun/star/awt/VisualEffect.hpp> #include <com/sun/star/awt/LineEndFormat.hpp> +#include <com/sun/star/graphic/GraphicProvider.hpp> #include <com/sun/star/graphic/XGraphicProvider.hpp> #include <com/sun/star/graphic/GraphicObject.hpp> #include <com/sun/star/util/Date.hpp> @@ -112,15 +113,12 @@ ImageHelper::getGraphicFromURL_nothrow( const ::rtl::OUString& _rURL ) try { - uno::Reference< graphic::XGraphicProvider > xProvider; - ::comphelper::ComponentContext aContext( ::comphelper::getProcessServiceFactory() ); - if ( aContext.createComponent( "com.sun.star.graphic.GraphicProvider", xProvider ) ) - { - uno::Sequence< beans::PropertyValue > aMediaProperties(1); - aMediaProperties[0].Name = ::rtl::OUString( "URL" ); - aMediaProperties[0].Value <<= _rURL; - xGraphic = xProvider->queryGraphic( aMediaProperties ); - } + uno::Reference< uno::XComponentContext > xContext( ::comphelper::getProcessComponentContext() ); + uno::Reference< graphic::XGraphicProvider > xProvider( graphic::GraphicProvider::create(xContext) ); + uno::Sequence< beans::PropertyValue > aMediaProperties(1); + aMediaProperties[0].Name = ::rtl::OUString( "URL" ); + aMediaProperties[0].Value <<= _rURL; + xGraphic = xProvider->queryGraphic( aMediaProperties ); } catch (const Exception&) { diff --git a/toolkit/source/helper/tkresmgr.cxx b/toolkit/source/helper/tkresmgr.cxx index fd2f5cb0e356..fa24f4bc8cc8 100644 --- a/toolkit/source/helper/tkresmgr.cxx +++ b/toolkit/source/helper/tkresmgr.cxx @@ -31,6 +31,7 @@ #include <comphelper/processfactory.hxx> #include <comphelper/componentcontext.hxx> #include <comphelper/namedvaluecollection.hxx> +#include <com/sun/star/graphic/GraphicProvider.hpp> #include <com/sun/star/graphic/XGraphicProvider.hpp> #include <tools/resmgr.hxx> #include <tools/diagnose_ex.h> @@ -107,15 +108,12 @@ Image TkResMgr::getImageFromURL( const ::rtl::OUString& i_rImageURL ) try { - ::comphelper::ComponentContext aContext( ::comphelper::getProcessServiceFactory() ); - Reference< XGraphicProvider > xProvider; - if ( aContext.createComponent( "com.sun.star.graphic.GraphicProvider", xProvider ) ) - { - ::comphelper::NamedValueCollection aMediaProperties; - aMediaProperties.put( "URL", i_rImageURL ); - Reference< XGraphic > xGraphic = xProvider->queryGraphic( aMediaProperties.getPropertyValues() ); - return Image( xGraphic ); - } + Reference< uno::XComponentContext > xContext( ::comphelper::getProcessComponentContext() ); + Reference< XGraphicProvider > xProvider( graphic::GraphicProvider::create(xContext) ); + ::comphelper::NamedValueCollection aMediaProperties; + aMediaProperties.put( "URL", i_rImageURL ); + Reference< XGraphic > xGraphic = xProvider->queryGraphic( aMediaProperties.getPropertyValues() ); + return Image( xGraphic ); } catch( const uno::Exception& ) { diff --git a/ucbhelper/source/provider/registerucb.cxx b/ucbhelper/source/provider/registerucb.cxx index 631322f3f98f..b4dfcb6459e3 100644 --- a/ucbhelper/source/provider/registerucb.cxx +++ b/ucbhelper/source/provider/registerucb.cxx @@ -27,10 +27,13 @@ ************************************************************************/ #include <ucbhelper/registerucb.hxx> +#include <com/sun/star/beans/XPropertySet.hpp> #include <com/sun/star/lang/XMultiServiceFactory.hpp> #include <com/sun/star/ucb/XContentProviderManager.hpp> #include <com/sun/star/ucb/XParameterizedContentProvider.hpp> +#include <com/sun/star/ucb/ContentProviderProxyFactory.hpp> #include <com/sun/star/ucb/XContentProviderFactory.hpp> +#include <com/sun/star/uno/XComponentContext.hpp> #include <com/sun/star/uno/RuntimeException.hpp> #include "osl/diagnose.h" @@ -74,14 +77,13 @@ registerAtUcb( uno::Reference< ucb::XContentProviderFactory > xProxyFactory; try { + uno::Reference< beans::XPropertySet > xFactoryProperties( rServiceFactory, uno::UNO_QUERY_THROW ); + uno::Reference< uno::XComponentContext > xContext = uno::Reference< uno::XComponentContext >( + xFactoryProperties->getPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "DefaultContext" ) ) ), + uno::UNO_QUERY ); xProxyFactory = uno::Reference< ucb::XContentProviderFactory >( - rServiceFactory-> - createInstance( - rtl::OUString( - RTL_CONSTASCII_USTRINGPARAM( - "com.sun.star.ucb.ContentProviderProxyFactory"))), - uno::UNO_QUERY); + ucb::ContentProviderProxyFactory::create( xContext ) ); } catch (uno::Exception const &) {} OSL_ENSURE(xProxyFactory.is(), "No ContentProviderProxyFactory"); diff --git a/vcl/source/control/throbber.cxx b/vcl/source/control/throbber.cxx index a6a6d00a0197..c4167b5c88de 100644 --- a/vcl/source/control/throbber.cxx +++ b/vcl/source/control/throbber.cxx @@ -30,6 +30,8 @@ #include "vcl/throbber.hxx" #include "vcl/svapp.hxx" +#include <com/sun/star/uno/XComponentContext.hpp> +#include <com/sun/star/graphic/GraphicProvider.hpp> #include <com/sun/star/graphic/XGraphicProvider.hpp> #include <com/sun/star/awt/ImageScaleMode.hpp> @@ -119,8 +121,8 @@ namespace ::std::vector< Image > aImages; ENSURE_OR_RETURN( i_imageSet != Throbber::IMAGES_NONE, "lcl_loadImageSet: illegal image set", aImages ); - const ::comphelper::ComponentContext aContext( ::comphelper::getProcessServiceFactory() ); - const Reference< XGraphicProvider > xGraphicProvider( aContext.createComponent( "com.sun.star.graphic.GraphicProvider" ), UNO_QUERY_THROW ); + const Reference< com::sun::star::uno::XComponentContext > aContext( ::comphelper::getProcessComponentContext() ); + const Reference< XGraphicProvider > xGraphicProvider( com::sun::star::graphic::GraphicProvider::create(aContext) ); ::std::vector< ::rtl::OUString > aImageURLs( Throbber::getDefaultImageURLs( i_imageSet ) ); aImages.reserve( aImageURLs.size() ); diff --git a/vcl/source/gdi/graph.cxx b/vcl/source/gdi/graph.cxx index 35ac193a1e38..07c9d4f75f86 100644 --- a/vcl/source/gdi/graph.cxx +++ b/vcl/source/gdi/graph.cxx @@ -36,6 +36,7 @@ #include <comphelper/processfactory.hxx> #include <com/sun/star/lang/XMultiServiceFactory.hpp> +#include <com/sun/star/graphic/GraphicProvider.hpp> #include <com/sun/star/graphic/XGraphicProvider.hpp> #include <com/sun/star/lang/XUnoTunnel.hpp> #include <com/sun/star/lang/XTypeProvider.hpp> @@ -492,25 +493,16 @@ uno::Reference< graphic::XGraphic > Graphic::GetXGraphic() const if( GetType() != GRAPHIC_NONE ) { - uno::Reference < lang::XMultiServiceFactory > xMSF( ::comphelper::getProcessServiceFactory() ); + uno::Reference < uno::XComponentContext > xContext( ::comphelper::getProcessComponentContext() ); + uno::Reference< graphic::XGraphicProvider > xProv( graphic::GraphicProvider::create( xContext ) ); - if( xMSF.is() ) - { - uno::Reference< graphic::XGraphicProvider > xProv( xMSF->createInstance( - ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.graphic.GraphicProvider" ) ) ), - uno::UNO_QUERY ); - - if( xProv.is() ) - { - uno::Sequence< beans::PropertyValue > aLoadProps( 1 ); - ::rtl::OUString aURL( RTL_CONSTASCII_USTRINGPARAM( "private:memorygraphic/" ) ); + uno::Sequence< beans::PropertyValue > aLoadProps( 1 ); + ::rtl::OUString aURL( RTL_CONSTASCII_USTRINGPARAM( "private:memorygraphic/" ) ); - aLoadProps[ 0 ].Name = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "URL" ) ); - aLoadProps[ 0 ].Value <<= ( aURL += ::rtl::OUString::valueOf( reinterpret_cast< sal_Int64 >( this ) ) ); + aLoadProps[ 0 ].Name = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "URL" ) ); + aLoadProps[ 0 ].Value <<= ( aURL += ::rtl::OUString::valueOf( reinterpret_cast< sal_Int64 >( this ) ) ); - xRet = xProv->queryGraphic( aLoadProps ); - } - } + xRet = xProv->queryGraphic( aLoadProps ); } return xRet; diff --git a/vcl/source/gdi/pdfwriter_impl2.cxx b/vcl/source/gdi/pdfwriter_impl2.cxx index b86e758667bb..d94281bdc784 100644 --- a/vcl/source/gdi/pdfwriter_impl2.cxx +++ b/vcl/source/gdi/pdfwriter_impl2.cxx @@ -42,9 +42,11 @@ #include "unotools/streamwrap.hxx" #include "comphelper/processfactory.hxx" +#include "comphelper/componentcontext.hxx" #include "com/sun/star/beans/PropertyValue.hpp" #include "com/sun/star/io/XSeekable.hpp" +#include "com/sun/star/graphic/GraphicProvider.hpp" #include "com/sun/star/graphic/XGraphicProvider.hpp" #include "cppuhelper/implbase1.hxx" @@ -194,47 +196,42 @@ void PDFWriterImpl::implWriteBitmapEx( const Point& i_rPoint, const Size& i_rSiz { uno::Reference < io::XStream > xStream = new utl::OStreamWrapper( aStrm ); uno::Reference< io::XSeekable > xSeekable( xStream, UNO_QUERY_THROW ); - uno::Reference< graphic::XGraphicProvider > xGraphicProvider( ImplGetSVData()->maAppData.mxMSF->createInstance( - OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.graphic.GraphicProvider")) ), UNO_QUERY ); - if ( xGraphicProvider.is() ) + uno::Reference< uno::XComponentContext > xContext( comphelper::ComponentContext(ImplGetSVData()->maAppData.mxMSF).getUNOContext() ); + uno::Reference< graphic::XGraphicProvider > xGraphicProvider( graphic::GraphicProvider::create(xContext) ); + uno::Reference< graphic::XGraphic > xGraphic( aGraphic.GetXGraphic() ); + uno::Reference < io::XOutputStream > xOut( xStream->getOutputStream() ); + rtl::OUString aMimeType(RTL_CONSTASCII_USTRINGPARAM("image/jpeg")); + uno::Sequence< beans::PropertyValue > aOutMediaProperties( 3 ); + aOutMediaProperties[0].Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("OutputStream")); + aOutMediaProperties[0].Value <<= xOut; + aOutMediaProperties[1].Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("MimeType")); + aOutMediaProperties[1].Value <<= aMimeType; + aOutMediaProperties[2].Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("FilterData")); + aOutMediaProperties[2].Value <<= aFilterData; + xGraphicProvider->storeGraphic( xGraphic, aOutMediaProperties ); + xOut->flush(); + if ( xSeekable->getLength() > nZippedFileSize ) { - uno::Reference< graphic::XGraphic > xGraphic( aGraphic.GetXGraphic() ); - uno::Reference < io::XOutputStream > xOut( xStream->getOutputStream() ); - rtl::OUString aMimeType(RTL_CONSTASCII_USTRINGPARAM("image/jpeg")); - uno::Sequence< beans::PropertyValue > aOutMediaProperties( 3 ); - aOutMediaProperties[0].Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("OutputStream")); - aOutMediaProperties[0].Value <<= xOut; - aOutMediaProperties[1].Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("MimeType")); - aOutMediaProperties[1].Value <<= aMimeType; - aOutMediaProperties[2].Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("FilterData")); - aOutMediaProperties[2].Value <<= aFilterData; - xGraphicProvider->storeGraphic( xGraphic, aOutMediaProperties ); - xOut->flush(); - if ( xSeekable->getLength() > nZippedFileSize ) - { - bUseJPGCompression = sal_False; - } - else + bUseJPGCompression = sal_False; + } + else + { + aStrm.Seek( STREAM_SEEK_TO_END ); + + xSeekable->seek( 0 ); + Sequence< PropertyValue > aArgs( 1 ); + aArgs[ 0 ].Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("InputStream")); + aArgs[ 0 ].Value <<= xStream; + uno::Reference< XPropertySet > xPropSet( xGraphicProvider->queryGraphicDescriptor( aArgs ) ); + if ( xPropSet.is() ) { - aStrm.Seek( STREAM_SEEK_TO_END ); - - xSeekable->seek( 0 ); - Sequence< PropertyValue > aArgs( 1 ); - aArgs[ 0 ].Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("InputStream")); - aArgs[ 0 ].Value <<= xStream; - uno::Reference< XPropertySet > xPropSet( xGraphicProvider->queryGraphicDescriptor( aArgs ) ); - if ( xPropSet.is() ) + sal_Int16 nBitsPerPixel = 24; + if ( xPropSet->getPropertyValue( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("BitsPerPixel")) ) >>= nBitsPerPixel ) { - sal_Int16 nBitsPerPixel = 24; - if ( xPropSet->getPropertyValue( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("BitsPerPixel")) ) >>= nBitsPerPixel ) - { - bTrueColorJPG = nBitsPerPixel != 8; - } + bTrueColorJPG = nBitsPerPixel != 8; } } } - else - bUseJPGCompression = sal_False; } catch( uno::Exception& ) { diff --git a/writerfilter/CppunitTest_writerfilter_rtftok.mk b/writerfilter/CppunitTest_writerfilter_rtftok.mk index af0aa6a5e208..9b660d30abac 100644 --- a/writerfilter/CppunitTest_writerfilter_rtftok.mk +++ b/writerfilter/CppunitTest_writerfilter_rtftok.mk @@ -56,6 +56,7 @@ $(eval $(call gb_CppunitTest_use_ure,writerfilter_rtftok)) $(eval $(call gb_CppunitTest_use_components,writerfilter_rtftok,\ configmgr/source/configmgr \ + svtools/util/svt \ ucb/source/core/ucb1 \ ucb/source/ucp/file/ucpfile1 \ writerfilter/util/writerfilter \ diff --git a/writerfilter/source/dmapper/GraphicImport.cxx b/writerfilter/source/dmapper/GraphicImport.cxx index afab11eb6e7f..6d16a8dcef73 100644 --- a/writerfilter/source/dmapper/GraphicImport.cxx +++ b/writerfilter/source/dmapper/GraphicImport.cxx @@ -34,6 +34,7 @@ #include <com/sun/star/drawing/PointSequenceSequence.hpp> #include <com/sun/star/drawing/XShape.hpp> #include <com/sun/star/graphic/XGraphic.hpp> +#include <com/sun/star/graphic/GraphicProvider.hpp> #include <com/sun/star/graphic/XGraphicProvider.hpp> #include <com/sun/star/io/XInputStream.hpp> #include <com/sun/star/lang/XMultiServiceFactory.hpp> @@ -1281,12 +1282,7 @@ uno::Reference< text::XTextContent > GraphicImport::createGraphicObject( const b uno::Reference< text::XTextContent > xGraphicObject; try { - uno::Reference< graphic::XGraphicProvider > xGraphicProvider( - m_xComponentContext->getServiceManager()->createInstanceWithContext( - ::rtl::OUString("com.sun.star.graphic.GraphicProvider"), - m_xComponentContext), - uno::UNO_QUERY_THROW ); - + uno::Reference< graphic::XGraphicProvider > xGraphicProvider( graphic::GraphicProvider::create(m_xComponentContext) ); uno::Reference< graphic::XGraphic > xGraphic = xGraphicProvider->queryGraphic( aMediaProperties ); if(xGraphic.is()) diff --git a/xmloff/source/core/xmluconv.cxx b/xmloff/source/core/xmluconv.cxx index b8fc35dea068..197cdf369835 100644 --- a/xmloff/source/core/xmluconv.cxx +++ b/xmloff/source/core/xmluconv.cxx @@ -43,11 +43,14 @@ #include <com/sun/star/util/XNumberFormatsSupplier.hpp> #include <com/sun/star/style/NumberingType.hpp> +#include <com/sun/star/text/DefaultNumberingProvider.hpp> +#include <com/sun/star/text/XDefaultNumberingProvider.hpp> #include <com/sun/star/text/XNumberingTypeInfo.hpp> #include <com/sun/star/lang/XMultiServiceFactory.hpp> #include <com/sun/star/i18n/XCharacterClassification.hpp> #include <com/sun/star/i18n/UnicodeType.hpp> #include <basegfx/vector/b3dvector.hxx> +#include <comphelper/componentcontext.hxx> #include <sax/tools/converter.hxx> @@ -95,10 +98,10 @@ void SvXMLUnitConverter::Impl::createNumTypeInfo() const { if (m_xServiceFactory.is()) { + Reference<XComponentContext> xContext( comphelper::ComponentContext(m_xServiceFactory).getUNOContext() ); + Reference<XDefaultNumberingProvider> xDefNum = DefaultNumberingProvider::create(xContext); const_cast<Impl*>(this)->m_xNumTypeInfo = - Reference < XNumberingTypeInfo > ( - m_xServiceFactory->createInstance( - OUString("com.sun.star.text.DefaultNumberingProvider" ) ), UNO_QUERY ); + Reference<XNumberingTypeInfo>(xDefNum, uno::UNO_QUERY); } } diff --git a/xmloff/source/draw/shapeexport4.cxx b/xmloff/source/draw/shapeexport4.cxx index bd1ae98c4640..aa4701d36993 100644 --- a/xmloff/source/draw/shapeexport4.cxx +++ b/xmloff/source/draw/shapeexport4.cxx @@ -28,6 +28,7 @@ #include <com/sun/star/graphic/XGraphic.hpp> +#include <com/sun/star/graphic/GraphicProvider.hpp> #include <com/sun/star/graphic/XGraphicProvider.hpp> #include <com/sun/star/embed/ElementModes.hpp> #include <com/sun/star/embed/XTransactedObject.hpp> @@ -69,6 +70,7 @@ #include "xmloff/xmlnmspe.hxx" #include "XMLBase64Export.hxx" +#include <comphelper/componentcontext.hxx> using ::rtl::OUString; using ::rtl::OUStringBuffer; @@ -1220,7 +1222,7 @@ void XMLShapeExport::ImpExportTableShape( const uno::Reference< drawing::XShape xPictureStream.set( xPictureStorage->openStreamElement( sPictureName, ::embed::ElementModes::READWRITE ), UNO_QUERY_THROW ); } - Reference< graphic::XGraphicProvider > xProvider( xSM->createInstance( OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.graphic.GraphicProvider" ) ) ), UNO_QUERY_THROW ); + Reference< graphic::XGraphicProvider > xProvider( graphic::GraphicProvider::create(comphelper::ComponentContext(xSM).getUNOContext()) ); Sequence< beans::PropertyValue > aArgs( 2 ); aArgs[ 0 ].Name = OUString( RTL_CONSTASCII_USTRINGPARAM( "MimeType" ) ); aArgs[ 0 ].Value <<= OUString( RTL_CONSTASCII_USTRINGPARAM( "image/x-vclgraphic" ) ); |