summaryrefslogtreecommitdiff
path: root/sfx2
diff options
context:
space:
mode:
authorNoel Grandin <noel@peralex.com>2013-03-05 15:51:52 +0200
committerNoel Grandin <noel@peralex.com>2013-03-07 08:23:42 +0200
commit8c31a6baf06e711d5e45d477abedfa6afb7ffe51 (patch)
tree55a8ae79e0ec700a7e1b64599dd0dacdda8f5a3c /sfx2
parentf084fc5c80ad8b57f7a22a2a5fc506f90e0e24b8 (diff)
fdo#46808 use document::DocumentRevisionListPersistence constructor
Change-Id: I1a591ec4061c73657c26552d41c58b970696038f
Diffstat (limited to 'sfx2')
-rw-r--r--sfx2/source/doc/docfile.cxx54
-rw-r--r--sfx2/source/doc/doctempl.cxx2
-rw-r--r--sfx2/source/doc/doctemplates.cxx38
-rw-r--r--sfx2/source/inc/sfxurlrelocator.hxx5
4 files changed, 42 insertions, 57 deletions
diff --git a/sfx2/source/doc/docfile.cxx b/sfx2/source/doc/docfile.cxx
index 453a87aab30e..9a5967328ca2 100644
--- a/sfx2/source/doc/docfile.cxx
+++ b/sfx2/source/doc/docfile.cxx
@@ -111,6 +111,7 @@ using namespace ::com::sun::star::io;
#include <sot/stg.hxx>
#include <unotools/saveopt.hxx>
#include <svl/documentlockfile.hxx>
+#include <com/sun/star/document/DocumentRevisionListPersistence.hpp>
#include "helper.hxx"
#include <sfx2/request.hxx> // SFX_ITEMSET_SET
@@ -3101,17 +3102,14 @@ const uno::Sequence < util::RevisionTag >& SfxMedium::GetVersionList( bool _bNoR
if ( ( !_bNoReload || !pImp->m_bVersionsAlreadyLoaded ) && !pImp->aVersions.getLength() &&
( !pImp->m_aName.isEmpty() || !pImp->m_aLogicName.isEmpty() ) && GetStorage().is() )
{
- uno::Reference < document::XDocumentRevisionListPersistence > xReader( comphelper::getProcessServiceFactory()->createInstance(
- ::rtl::OUString("com.sun.star.document.DocumentRevisionListPersistence") ), uno::UNO_QUERY );
- if ( xReader.is() )
+ uno::Reference < document::XDocumentRevisionListPersistence > xReader =
+ document::DocumentRevisionListPersistence::create( comphelper::getProcessComponentContext() );
+ try
+ {
+ pImp->aVersions = xReader->load( GetStorage() );
+ }
+ catch ( const uno::Exception& )
{
- try
- {
- pImp->aVersions = xReader->load( GetStorage() );
- }
- catch ( const uno::Exception& )
- {
- }
}
}
@@ -3123,17 +3121,14 @@ const uno::Sequence < util::RevisionTag >& SfxMedium::GetVersionList( bool _bNoR
uno::Sequence < util::RevisionTag > SfxMedium::GetVersionList( const uno::Reference < embed::XStorage >& xStorage )
{
- uno::Reference < document::XDocumentRevisionListPersistence > xReader( comphelper::getProcessServiceFactory()->createInstance(
- ::rtl::OUString("com.sun.star.document.DocumentRevisionListPersistence") ), uno::UNO_QUERY );
- if ( xReader.is() )
+ uno::Reference < document::XDocumentRevisionListPersistence > xReader =
+ document::DocumentRevisionListPersistence::create( comphelper::getProcessComponentContext() );
+ try
+ {
+ return xReader->load( xStorage );
+ }
+ catch ( const uno::Exception& )
{
- try
- {
- return xReader->load( xStorage );
- }
- catch ( const uno::Exception& )
- {
- }
}
return uno::Sequence < util::RevisionTag >();
@@ -3210,18 +3205,15 @@ sal_Bool SfxMedium::SaveVersionList_Impl( sal_Bool /*bUseXML*/ )
if ( !pImp->aVersions.getLength() )
return true;
- uno::Reference < document::XDocumentRevisionListPersistence > xWriter( comphelper::getProcessServiceFactory()->createInstance(
- ::rtl::OUString("com.sun.star.document.DocumentRevisionListPersistence") ), uno::UNO_QUERY );
- if ( xWriter.is() )
+ uno::Reference < document::XDocumentRevisionListPersistence > xWriter =
+ document::DocumentRevisionListPersistence::create( comphelper::getProcessComponentContext() );
+ try
+ {
+ xWriter->store( GetStorage(), pImp->aVersions );
+ return true;
+ }
+ catch ( const uno::Exception& )
{
- try
- {
- xWriter->store( GetStorage(), pImp->aVersions );
- return true;
- }
- catch ( const uno::Exception& )
- {
- }
}
}
diff --git a/sfx2/source/doc/doctempl.cxx b/sfx2/source/doc/doctempl.cxx
index ef0dd02b7bba..b9f04fa1fe44 100644
--- a/sfx2/source/doc/doctempl.cxx
+++ b/sfx2/source/doc/doctempl.cxx
@@ -1846,7 +1846,7 @@ sal_Bool getTextProperty_Impl( Content& rContent,
if ( SfxURLRelocator_Impl::propertyCanContainOfficeDir( rPropName ) )
{
- SfxURLRelocator_Impl aRelocImpl( ::comphelper::getProcessServiceFactory() );
+ SfxURLRelocator_Impl aRelocImpl( ::comphelper::getProcessComponentContext() );
aRelocImpl.makeAbsoluteURL( rPropValue );
}
diff --git a/sfx2/source/doc/doctemplates.cxx b/sfx2/source/doc/doctemplates.cxx
index 9251b5f11512..b067332248da 100644
--- a/sfx2/source/doc/doctemplates.cxx
+++ b/sfx2/source/doc/doctemplates.cxx
@@ -176,7 +176,7 @@ public:
class SfxDocTplService_Impl
{
- uno::Reference< XMultiServiceFactory > mxFactory;
+ uno::Reference< XComponentContext > mxContext;
uno::Reference< XCommandEnvironment > maCmdEnv;
uno::Reference< XDocumentProperties> m_xDocProps;
uno::Reference< XTypeDetection > mxType;
@@ -268,7 +268,7 @@ class SfxDocTplService_Impl
void updateData( DocTemplates_EntryData_Impl *pData );
public:
- SfxDocTplService_Impl( uno::Reference< XMultiServiceFactory > xFactory );
+ SfxDocTplService_Impl( const uno::Reference< XComponentContext > & xContext );
~SfxDocTplService_Impl();
sal_Bool init() { if ( !mbIsInitialized ) init_Impl(); return mbIsInitialized; }
@@ -451,7 +451,7 @@ void SfxDocTplService_Impl::init_Impl()
}
OUString const aService = OUString( SERVICENAME_TYPEDETECTION );
- mxType = uno::Reference< XTypeDetection > ( mxFactory->createInstance( aService ), UNO_QUERY );
+ mxType = uno::Reference< XTypeDetection > ( mxContext->getServiceManager()->createInstanceWithContext(aService, mxContext), UNO_QUERY );
getDirList();
readFolderList();
@@ -580,9 +580,7 @@ void SfxDocTplService_Impl::getDirList()
maTemplateDirs = Sequence< OUString >( nCount );
- uno::Reference< XComponentContext > xCtx(
- comphelper::getComponentContext( mxFactory ) );
- uno::Reference< util::XMacroExpander > xExpander = util::theMacroExpander::get(xCtx);
+ uno::Reference< util::XMacroExpander > xExpander = util::theMacroExpander::get(mxContext);
const rtl::OUString aPrefix(
"vnd.sun.star.expand:" );
@@ -1122,10 +1120,10 @@ bool SfxURLRelocator_Impl::propertyCanContainOfficeDir(
// public SfxDocTplService_Impl
//-----------------------------------------------------------------------------
-SfxDocTplService_Impl::SfxDocTplService_Impl( uno::Reference< XMultiServiceFactory > xFactory )
-: maRelocator( xFactory )
+SfxDocTplService_Impl::SfxDocTplService_Impl( const uno::Reference< XComponentContext > & xContext )
+: maRelocator( xContext )
{
- mxFactory = xFactory;
+ mxContext = xContext;
mpUpdater = NULL;
mbIsInitialized = sal_False;
mbLocaleSet = sal_False;
@@ -1290,7 +1288,7 @@ uno::Sequence< beans::StringPair > SfxDocTplService_Impl::ReadUINamesForTemplate
{
uno::Reference< io::XInputStream > xLocStream = aLocContent.openStream();
if ( xLocStream.is() )
- aUINames = DocTemplLocaleHelper::ReadGroupLocalizationSequence( xLocStream, comphelper::getComponentContext(mxFactory) );
+ aUINames = DocTemplLocaleHelper::ReadGroupLocalizationSequence( xLocStream, mxContext );
}
catch( uno::Exception& )
{}
@@ -1378,7 +1376,7 @@ sal_Bool SfxDocTplService_Impl::WriteUINamesForTemplateDir_Impl( const ::rtl::OU
sal_Bool bResult = sal_False;
try {
uno::Reference< beans::XPropertySet > xTempFile(
- io::TempFile::create(comphelper::getComponentContext(mxFactory)),
+ io::TempFile::create(mxContext),
uno::UNO_QUERY_THROW );
::rtl::OUString aTempURL;
@@ -1390,7 +1388,7 @@ sal_Bool SfxDocTplService_Impl::WriteUINamesForTemplateDir_Impl( const ::rtl::OU
if ( !xOutStream.is() )
throw uno::RuntimeException();
- DocTemplLocaleHelper::WriteGroupLocalizationSequence( xOutStream, aUINames, comphelper::getComponentContext(mxFactory));
+ DocTemplLocaleHelper::WriteGroupLocalizationSequence( xOutStream, aUINames, mxContext);
try {
// the SAX writer might close the stream
xOutStream->closeOutput();
@@ -2212,7 +2210,7 @@ SFX_IMPL_SINGLEFACTORY( SfxDocTplService )
//-----------------------------------------------------------------------------
SfxDocTplService::SfxDocTplService( const uno::Reference< XMultiServiceFactory >& xFactory )
{
- pImp = new SfxDocTplService_Impl( xFactory );
+ pImp = new SfxDocTplService_Impl( comphelper::getComponentContext(xFactory) );
}
//-----------------------------------------------------------------------------
@@ -2806,8 +2804,8 @@ DocTemplates_EntryData_Impl::DocTemplates_EntryData_Impl( const OUString& rTitle
}
// -----------------------------------------------------------------------
-SfxURLRelocator_Impl::SfxURLRelocator_Impl( uno::Reference< XMultiServiceFactory > xFactory )
-: mxFactory( xFactory )
+SfxURLRelocator_Impl::SfxURLRelocator_Impl( const uno::Reference< XComponentContext > & xContext )
+: mxContext( xContext )
{
}
@@ -2824,12 +2822,9 @@ void SfxURLRelocator_Impl::initOfficeInstDirs()
osl::MutexGuard aGuard( maMutex );
if ( !mxOfficeInstDirs.is() )
{
- OSL_ENSURE( mxFactory.is(), "No service manager!" );
+ OSL_ENSURE( mxContext.is(), "No service manager!" );
- uno::Reference< XComponentContext > xCtx(
- comphelper::getComponentContext( mxFactory ) );
-
- mxOfficeInstDirs = theOfficeInstallationDirectories::get(xCtx);
+ mxOfficeInstDirs = theOfficeInstallationDirectories::get(mxContext);
}
}
}
@@ -2846,8 +2841,7 @@ void SfxURLRelocator_Impl::implExpandURL( ::rtl::OUString& io_url )
{
if ( !mxMacroExpander.is() )
{
- ::comphelper::ComponentContext aContext( mxFactory );
- mxMacroExpander.set( theMacroExpander::get(aContext.getUNOContext()), UNO_QUERY_THROW );
+ mxMacroExpander.set( theMacroExpander::get(mxContext), UNO_QUERY_THROW );
}
io_url = mxMacroExpander->expandMacros( io_url );
}
diff --git a/sfx2/source/inc/sfxurlrelocator.hxx b/sfx2/source/inc/sfxurlrelocator.hxx
index 031ca663bb7b..1406d60e9cf8 100644
--- a/sfx2/source/inc/sfxurlrelocator.hxx
+++ b/sfx2/source/inc/sfxurlrelocator.hxx
@@ -20,7 +20,6 @@
#ifndef _SFX_SFXURLRELOCATOR_HXX_
#define _SFX_SFXURLRELOCATOR_HXX_
-#include <com/sun/star/lang/XMultiServiceFactory.hpp>
#include <com/sun/star/util/XOfficeInstallationDirectories.hpp>
#include <com/sun/star/util/XMacroExpander.hpp>
@@ -30,7 +29,7 @@
class SfxURLRelocator_Impl
{
::osl::Mutex maMutex;
- ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > mxFactory;
+ ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > mxContext;
::com::sun::star::uno::Reference< ::com::sun::star::util::XOfficeInstallationDirectories > mxOfficeInstDirs;
::com::sun::star::uno::Reference< ::com::sun::star::util::XMacroExpander > mxMacroExpander;
@@ -40,7 +39,7 @@ public:
void makeRelocatableURL( rtl::OUString & rURL );
void makeAbsoluteURL( rtl::OUString & rURL );
- SfxURLRelocator_Impl( ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > xFactory );
+ SfxURLRelocator_Impl( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > & xContext );
~SfxURLRelocator_Impl();
private: