summaryrefslogtreecommitdiff
path: root/sfx2
diff options
context:
space:
mode:
authorNoel Grandin <noel@peralex.com>2012-05-26 13:53:19 +0200
committerStephan Bergmann <sbergman@redhat.com>2012-06-04 16:57:55 +0200
commitb3c76dee6d44d07eae404b8d7341e6c88e6c4429 (patch)
treec747dd5bddf94c3b4312c7b1861a5087e76e71d6 /sfx2
parenteb68bf18f2d859486c4a737abb2536a6afe45411 (diff)
fdo#46808, Adapt UNO services to new style, Part 7, updating ::create
Update calls to factories to use new ::create methods Change-Id: I01d4417820f52718836c92faf3c2fae0dc96b30d Signed-off-by: Stephan Bergmann <sbergman@redhat.com>, added some tweaks.
Diffstat (limited to 'sfx2')
-rw-r--r--sfx2/source/dialog/taskpane.cxx6
-rw-r--r--sfx2/source/doc/doctempl.cxx20
-rw-r--r--sfx2/source/doc/graphhelp.cxx52
-rw-r--r--sfx2/source/doc/objserv.cxx5
-rw-r--r--sfx2/source/doc/plugin.cxx6
5 files changed, 38 insertions, 51 deletions
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() )
{