Kaydet (Commit) 3e7990fa authored tarafından Noel Grandin's avatar Noel Grandin Kaydeden (comit) Stephan Bergmann

fdo#46808, Shiny UNO, Use factory to create XSimpleFileAccess instances

Change-Id: I86e2a8873e5646abd340015f500bf9e872e8e6c5
Signed-off-by: 's avatarStephan Bergmann <sbergman@redhat.com>
üst 8b34ad62
......@@ -21,6 +21,7 @@
#include <com/sun/star/embed/XEncryptionProtectedSource2.hpp>
#include <com/sun/star/embed/XTransactedObject.hpp>
#include <com/sun/star/ucb/XSimpleFileAccess.hpp>
#include <com/sun/star/ucb/SimpleFileAccess.hpp>
#include <com/sun/star/beans/XPropertySet.hpp>
#include <com/sun/star/beans/PropertyValue.hpp>
#include <com/sun/star/beans/NamedValue.hpp>
......@@ -34,6 +35,7 @@
#include <ucbhelper/content.hxx>
#include <comphelper/componentcontext.hxx>
#include <comphelper/fileformat.h>
#include <comphelper/processfactory.hxx>
#include <comphelper/documentconstants.hxx>
......@@ -229,9 +231,8 @@ uno::Reference< io::XInputStream > OStorageHelper::GetInputStreamFromURL(
if ( !xFactory.is() )
throw uno::RuntimeException();
uno::Reference < ::com::sun::star::ucb::XSimpleFileAccess > xTempAccess(
xFactory->createInstance ( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.ucb.SimpleFileAccess" )) ),
uno::UNO_QUERY );
uno::Reference < ucb::XSimpleFileAccess2 > xTempAccess(
ucb::SimpleFileAccess::create(comphelper::ComponentContext(xFactory).getUNOContext()) );
if ( !xTempAccess.is() )
throw uno::RuntimeException();
......
......@@ -34,7 +34,7 @@
#include <com/sun/star/awt/XVclWindowPeer.hpp>
#include <com/sun/star/util/XCloseable.hpp>
#include <com/sun/star/lang/DisposedException.hpp>
#include <com/sun/star/ucb/XSimpleFileAccess.hpp>
#include <com/sun/star/ucb/SimpleFileAccess.hpp>
#include <com/sun/star/presentation/XPresentation.hpp>
#include <com/sun/star/presentation/XPresentationSupplier.hpp>
#include <vcl/window.hxx>
......@@ -238,9 +238,9 @@ sal_Bool SoPluginInstance::LoadDocument(NSP_HWND hParent)
}
//create stream for the document
Reference< ::com::sun::star::ucb::XSimpleFileAccess > xSimpleFileAccess(
mxRemoteMSF->createInstance( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.ucb.SimpleFileAccess")) ),
uno::UNO_QUERY );
Reference< beans::XPropertySet > xFactoryProperties( mxRemoteMSF, uno::UNO_QUERY );
Reference< uno::XComponentContext > xContext( xFactoryProperties->getPropertyValue( "DefaultContext" ), UNO_QUERY );
Reference< ucb::XSimpleFileAccess2 > xSimpleFileAccess( ucb::SimpleFileAccess::create(xContext) );
if(!xSimpleFileAccess.is())
{
debug_fprintf(NSP_LOG_APPEND, "can not create SimpleFileAccess to load URL\n");
......
......@@ -34,8 +34,8 @@
#if 0
// for debugging purposes here
#include <com/sun/star/ucb/XSimpleFileAccess.hpp>
#include <comphelper/processfactory.hxx>
#include <com/sun/star/ucb/SimpleFileAccess.hpp>
#include <comphelper/componentcontext.hxx>
using namespace ::com::sun::star;
#endif
......@@ -305,8 +305,8 @@ sal_Int32 SAL_CALL XUnbufferedStream::readBytes( Sequence< sal_Int8 >& aData, sa
{
if ( 0 )
{
uno::Reference< lang::XMultiServiceFactory > xFactory = comphelper::getProcessServiceFactory();
uno::Reference< ucb::XSimpleFileAccess > xAccess( xFactory->createInstance(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.ucb.SimpleFileAccess") ) ), uno::UNO_QUERY );
uno::Reference< uno::XComponentContext > xContext = comphelper::getProcessComponentContext();
uno::Reference< ucb::XSimpleFileAccess2 > xAccess( SimpleFileAccess::create(xContext) );
uno::Reference< io::XOutputStream > xOut = xAccess->openFileWrite(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "file:///d:/777/Encrypted/picture") ) );
xOut->writeBytes( aData );
xOut->closeOutput();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment