summaryrefslogtreecommitdiff
path: root/basic/source/runtime
diff options
context:
space:
mode:
authorNoel Grandin <noel@peralex.com>2012-11-02 17:46:30 +0200
committerStephan Bergmann <sbergman@redhat.com>2012-11-15 08:28:44 +0100
commit5837402fb1daa437d9a1a37edc9ede57319944f1 (patch)
tree61e39515cd546fe7ad76364ebb444850b93541ce /basic/source/runtime
parent3f15a663b273e4a437fd68335d6eab2b11fc80c9 (diff)
fdo#46808, use service constructor for ucb::SimpleFileAccess
I upgraded the service to return XSimpleFileAccess3, since it already implemented that interface, and it's backwards compatible. Change-Id: I40001a46048bd21a23b6a2f58a95376f06fc634b
Diffstat (limited to 'basic/source/runtime')
-rw-r--r--basic/source/runtime/iosys.cxx65
-rw-r--r--basic/source/runtime/methods.cxx9
2 files changed, 31 insertions, 43 deletions
diff --git a/basic/source/runtime/iosys.cxx b/basic/source/runtime/iosys.cxx
index c6cf5fad1cb5..124608eaafc1 100644
--- a/basic/source/runtime/iosys.cxx
+++ b/basic/source/runtime/iosys.cxx
@@ -47,7 +47,6 @@
#include <com/sun/star/lang/XMultiServiceFactory.hpp>
#include <com/sun/star/ucb/SimpleFileAccess.hpp>
#include <com/sun/star/ucb/UniversalContentBroker.hpp>
-#include <com/sun/star/ucb/XSimpleFileAccess2.hpp>
#include <com/sun/star/ucb/XContentProvider.hpp>
#include <com/sun/star/ucb/XContentProviderManager.hpp>
#include <com/sun/star/io/XInputStream.hpp>
@@ -55,7 +54,6 @@
#include <com/sun/star/io/XStream.hpp>
#include <com/sun/star/io/XSeekable.hpp>
-using namespace comphelper;
using namespace com::sun::star::uno;
using namespace com::sun::star::lang;
using namespace com::sun::star::ucb;
@@ -224,7 +222,7 @@ bool needSecurityRestrictions( void )
return true;
}
- Reference< XComponentContext > xContext = getProcessComponentContext();
+ Reference< XComponentContext > xContext = comphelper::getProcessComponentContext();
Reference< XBridgeFactory2 > xBridgeFac( BridgeFactory::create(xContext) );
Sequence< Reference< XBridge > > aBridgeSeq = xBridgeFac->getExistingBridges();
@@ -279,7 +277,7 @@ bool hasUno( void )
if( bNeedInit )
{
bNeedInit = false;
- Reference< XComponentContext > xContext = getProcessComponentContext();
+ Reference< XComponentContext > xContext = comphelper::getProcessComponentContext();
if( !xContext.is() )
{
// No service manager at all
@@ -571,42 +569,37 @@ SbError SbiStream::Open
if( hasUno() )
{
- Reference< XMultiServiceFactory > xSMgr = getProcessServiceFactory();
- if( xSMgr.is() )
+ Reference< XSimpleFileAccess3 > xSFI( SimpleFileAccess::create( comphelper::getProcessComponentContext() ) );
+ try
{
- Reference< XSimpleFileAccess2 >
- xSFI( SimpleFileAccess::create( comphelper::getComponentContext(xSMgr) ) );
- try
- {
- // #??? For write access delete file if it already exists (not for appending)
- if( (nStrmMode & STREAM_WRITE) != 0 && !IsAppend() && !IsBinary() &&
- xSFI->exists( aNameStr ) && !xSFI->isFolder( aNameStr ) )
- {
- xSFI->kill( aNameStr );
- }
+ // #??? For write access delete file if it already exists (not for appending)
+ if( (nStrmMode & STREAM_WRITE) != 0 && !IsAppend() && !IsBinary() &&
+ xSFI->exists( aNameStr ) && !xSFI->isFolder( aNameStr ) )
+ {
+ xSFI->kill( aNameStr );
+ }
- if( (nStrmMode & (STREAM_READ | STREAM_WRITE)) == (STREAM_READ | STREAM_WRITE) )
- {
- Reference< XStream > xIS = xSFI->openFileReadWrite( aNameStr );
- pStrm = new UCBStream( xIS );
- }
- else if( nStrmMode & STREAM_WRITE )
- {
- Reference< XStream > xIS = xSFI->openFileReadWrite( aNameStr );
- pStrm = new UCBStream( xIS );
- }
- else //if( nStrmMode & STREAM_READ )
- {
- Reference< XInputStream > xIS = xSFI->openFileRead( aNameStr );
- pStrm = new UCBStream( xIS );
- }
+ if( (nStrmMode & (STREAM_READ | STREAM_WRITE)) == (STREAM_READ | STREAM_WRITE) )
+ {
+ Reference< XStream > xIS = xSFI->openFileReadWrite( aNameStr );
+ pStrm = new UCBStream( xIS );
+ }
+ else if( nStrmMode & STREAM_WRITE )
+ {
+ Reference< XStream > xIS = xSFI->openFileReadWrite( aNameStr );
+ pStrm = new UCBStream( xIS );
+ }
+ else //if( nStrmMode & STREAM_READ )
+ {
+ Reference< XInputStream > xIS = xSFI->openFileRead( aNameStr );
+ pStrm = new UCBStream( xIS );
+ }
- }
- catch(const Exception & )
- {
- nError = ERRCODE_IO_GENERAL;
- }
+ }
+ catch(const Exception & )
+ {
+ nError = ERRCODE_IO_GENERAL;
}
}
diff --git a/basic/source/runtime/methods.cxx b/basic/source/runtime/methods.cxx
index 881ee8678c0e..08d6699f9785 100644
--- a/basic/source/runtime/methods.cxx
+++ b/basic/source/runtime/methods.cxx
@@ -52,7 +52,7 @@
#include <com/sun/star/util/DateTime.hpp>
#include <com/sun/star/lang/XMultiServiceFactory.hpp>
#include <com/sun/star/lang/Locale.hpp>
-#include <com/sun/star/ucb/XSimpleFileAccess3.hpp>
+#include <com/sun/star/ucb/SimpleFileAccess.hpp>
#include <com/sun/star/script/XErrorQuery.hpp>
#include <ooo/vba/XHelperInterface.hpp>
#include <com/sun/star/bridge/oleautomation/XAutomationObject.hpp>
@@ -175,12 +175,7 @@ static uno::Reference< ucb::XSimpleFileAccess3 > getFileAccess( void )
static uno::Reference< ucb::XSimpleFileAccess3 > xSFI;
if( !xSFI.is() )
{
- uno::Reference< lang::XMultiServiceFactory > xSMgr = getProcessServiceFactory();
- if( xSMgr.is() )
- {
- xSFI = uno::Reference< ucb::XSimpleFileAccess3 >( xSMgr->createInstance
- ( OUString("com.sun.star.ucb.SimpleFileAccess" ) ), uno::UNO_QUERY );
- }
+ xSFI = ucb::SimpleFileAccess::create( comphelper::getProcessComponentContext() );
}
return xSFI;
}