summaryrefslogtreecommitdiff
path: root/package
diff options
context:
space:
mode:
authorStephan Bergmann <sbergman@redhat.com>2012-09-14 18:08:57 +0200
committerStephan Bergmann <sbergman@redhat.com>2012-09-14 18:24:49 +0200
commit9ac86f484b0c278aafbce685ed19d3ea005ee8f8 (patch)
treecf2fe16d76992bcbd1bd89a8693c5f4996cd55f2 /package
parent2e284203da7f9882842111265f5f68ea0a145065 (diff)
Improvement on previous commit, UCB clean up
* As UCB is only ever initialized with "Local"/"Office", remove this configuration vector completely. The "create" ctor creates an instance internally initialized with those "Local"/"Office" keys. Special (test) code can still instantiate an uninitialized one via plain createInstance. And for backwards compatilibity process startup still ensures to create an initialized instance early, in case there is still code out there (in extensions) that later calls plain createInstance and expects to get the already-initialized (single) instance. * XInitialization is an "implementation detail" of the UniversalContentBroker service, do not expose in XUniversalContentBroker. * ucbhelper/configurationkeys.hxx is no longer needed and is removed. * ucbhelper/contentbroker.hxx is an empty wrapper and is removed; however, that requires ucbhelper::Content constructors to take explicit XComponentContext arguments now. * The only remaining code in ucbhelper/source/client/contentbroker.cxx is Android-only InitUCBHelper. Is that relevant still? Change-Id: I3f7bddd0456bffbcd13590c66d9011915c760f28
Diffstat (limited to 'package')
-rw-r--r--package/inc/ZipPackage.hxx2
-rw-r--r--package/source/zippackage/ZipPackage.cxx67
-rw-r--r--package/source/zippackage/zipfileaccess.cxx7
3 files changed, 36 insertions, 40 deletions
diff --git a/package/inc/ZipPackage.hxx b/package/inc/ZipPackage.hxx
index b39ff2998403..c22976ec3e19 100644
--- a/package/inc/ZipPackage.hxx
+++ b/package/inc/ZipPackage.hxx
@@ -106,6 +106,8 @@ protected:
ZipPackageFolder *m_pRootFolder;
ZipFile *m_pZipFile;
+ sal_Bool isLocalFile() const;
+
void parseManifest();
void parseContentType();
void getZipFileContents();
diff --git a/package/source/zippackage/ZipPackage.cxx b/package/source/zippackage/ZipPackage.cxx
index bc941a61b7f3..a9c4ba0db6fd 100644
--- a/package/source/zippackage/ZipPackage.cxx
+++ b/package/source/zippackage/ZipPackage.cxx
@@ -49,6 +49,7 @@
#include <com/sun/star/ucb/OpenMode.hpp>
#include <com/sun/star/ucb/XProgressHandler.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/io/XActiveDataStreamer.hpp>
#include <com/sun/star/embed/XTransactedObject.hpp>
@@ -65,13 +66,12 @@
#include <rtl/logfile.hxx>
#include <rtl/instance.hxx>
#include <osl/time.h>
-#include <osl/file.hxx>
#include "com/sun/star/io/XAsyncOutputMonitor.hpp"
+#include <cstring>
#include <memory>
#include <vector>
-#include <ucbhelper/contentbroker.hxx>
#include <ucbhelper/fileidentifierconverter.hxx>
#include <comphelper/componentcontext.hxx>
#include <comphelper/seekableinput.hxx>
@@ -100,37 +100,6 @@ using namespace com::sun::star::packages::zip::ZipConstants;
#define LOGFILE_AUTHOR "mg115289"
-
-namespace {
-
-sal_Bool isLocalFile_Impl( OUString aURL )
-{
- OUString aSystemPath;
- ContentBroker* pBroker = ContentBroker::get();
- if ( !pBroker )
- {
- OUString aRet;
- if ( FileBase::getSystemPathFromFileURL( aURL, aRet ) == FileBase::E_None )
- aSystemPath = aRet;
- }
- else
- {
- uno::Reference< XContentProviderManager > xManager =
- pBroker->getContentProviderManagerInterface();
- try
- {
- aSystemPath = getSystemPathFromFileURL( xManager, aURL );
- }
- catch ( Exception& )
- {
- }
- }
-
- return ( !aSystemPath.isEmpty() );
-}
-
-}
-
//===========================================================================
class ActiveDataStreamer : public ::cppu::WeakImplHelper1< XActiveDataStreamer >
@@ -203,6 +172,22 @@ ZipPackage::~ZipPackage( void )
// during m_pRootFolder dieing by refcount.
}
+sal_Bool ZipPackage::isLocalFile() const
+{
+ OUString aSystemPath;
+ uno::Reference< XUniversalContentBroker > xUcb(
+ UniversalContentBroker::create(
+ comphelper::ComponentContext( m_xFactory ).getUNOContext() ) );
+ try
+ {
+ aSystemPath = getSystemPathFromFileURL( xUcb, m_aURL );
+ }
+ catch ( Exception& )
+ {
+ }
+ return !aSystemPath.isEmpty();
+}
+
//--------------------------------------------------------
void ZipPackage::parseManifest()
{
@@ -646,7 +631,9 @@ void SAL_CALL ZipPackage::initialize( const uno::Sequence< Any >& aArguments )
else
m_aURL = aParamUrl;
- Content aContent ( m_aURL, uno::Reference < XCommandEnvironment >() );
+ Content aContent(
+ m_aURL, uno::Reference< XCommandEnvironment >(),
+ comphelper::ComponentContext( m_xFactory ).getUNOContext() );
Any aAny = aContent.getPropertyValue("Size");
sal_uInt64 aSize = 0;
// kind of optimisation: treat empty files as nonexistent files
@@ -1153,7 +1140,7 @@ uno::Reference< io::XInputStream > ZipPackage::writeTempFile()
uno::Reference < io::XOutputStream > xTempOut;
uno::Reference< io::XActiveDataStreamer > xSink;
- if ( m_eMode == e_IMode_URL && !m_pZipFile && isLocalFile_Impl( m_aURL ) )
+ if ( m_eMode == e_IMode_URL && !m_pZipFile && isLocalFile() )
{
xSink = openOriginalForOutput();
if( xSink.is() )
@@ -1331,7 +1318,9 @@ uno::Reference< io::XInputStream > ZipPackage::writeTempFile()
uno::Reference< XActiveDataStreamer > ZipPackage::openOriginalForOutput()
{
// open and truncate the original file
- Content aOriginalContent ( m_aURL, uno::Reference < XCommandEnvironment >() );
+ Content aOriginalContent(
+ m_aURL, uno::Reference< XCommandEnvironment >(),
+ comphelper::ComponentContext( m_xFactory ).getUNOContext() );
uno::Reference< XActiveDataStreamer > xSink = new ActiveDataStreamer;
if ( m_eMode == e_IMode_URL )
@@ -1462,7 +1451,7 @@ void SAL_CALL ZipPackage::commitChanges()
uno::Reference< XOutputStream > aOrigFileStream;
sal_Bool bCanBeCorrupted = sal_False;
- if( isLocalFile_Impl( m_aURL ) )
+ if( isLocalFile() )
{
// write directly in case of local file
uno::Reference< ::com::sun::star::ucb::XSimpleFileAccess2 > xSimpleAccess(
@@ -1512,7 +1501,9 @@ void SAL_CALL ZipPackage::commitChanges()
throw uno::RuntimeException(OSL_LOG_PREFIX, uno::Reference< uno::XInterface >() );
OUString sTargetFolder = m_aURL.copy ( 0, m_aURL.lastIndexOf ( static_cast < sal_Unicode > ( '/' ) ) );
- Content aContent ( sTargetFolder, uno::Reference < XCommandEnvironment > () );
+ Content aContent(
+ sTargetFolder, uno::Reference< XCommandEnvironment >(),
+ comphelper::ComponentContext( m_xFactory ).getUNOContext() );
OUString sTempURL;
Any aAny = xPropSet->getPropertyValue ("Uri");
diff --git a/package/source/zippackage/zipfileaccess.cxx b/package/source/zippackage/zipfileaccess.cxx
index 5339b84ccd2b..64f244c9d69c 100644
--- a/package/source/zippackage/zipfileaccess.cxx
+++ b/package/source/zippackage/zipfileaccess.cxx
@@ -23,7 +23,7 @@
#include <com/sun/star/io/XActiveDataSink.hpp>
#include <com/sun/star/io/XStream.hpp>
#include <com/sun/star/io/XSeekable.hpp>
-
+#include <comphelper/componentcontext.hxx>
#include <zipfileaccess.hxx>
#include <ZipEnumeration.hxx>
#include <ZipPackageSink.hxx>
@@ -185,7 +185,10 @@ void SAL_CALL OZipFileAccess::initialize( const uno::Sequence< uno::Any >& aArgu
if ( ( aArguments[0] >>= aParamURL ) )
{
- ::ucbhelper::Content aContent ( aParamURL, uno::Reference< ::com::sun::star::ucb::XCommandEnvironment >() );
+ ::ucbhelper::Content aContent(
+ aParamURL,
+ uno::Reference< ::com::sun::star::ucb::XCommandEnvironment >(),
+ comphelper::ComponentContext( m_xFactory ).getUNOContext() );
uno::Reference < io::XActiveDataSink > xSink = new ZipPackageSink;
if ( aContent.openStream ( xSink ) )
{