summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVladimir Glazunov <vg@openoffice.org>2009-12-11 17:56:47 +0100
committerVladimir Glazunov <vg@openoffice.org>2009-12-11 17:56:47 +0100
commitf11aa3132d85bfafc8e9829814b655f86175d349 (patch)
treec09be61c62c6b18eae00bb69e806b03cb5adf7c6
parent2ee1464936d571b6796dcd3336135a8283d56269 (diff)
parent609f0d0f0f49b8b145e018408ad038ab4dc235d9 (diff)
CWS-TOOLING: integrate CWS fwk129_DEV300
-rw-r--r--extensions/source/plugin/base/nfuncs.cxx5
-rw-r--r--package/source/xstor/makefile.mk1
-rw-r--r--package/source/xstor/owriteablestream.cxx22
-rw-r--r--package/source/xstor/selfterminatefilestream.cxx156
-rw-r--r--package/source/xstor/selfterminatefilestream.hxx79
-rw-r--r--package/source/zippackage/ZipPackage.cxx23
6 files changed, 252 insertions, 34 deletions
diff --git a/extensions/source/plugin/base/nfuncs.cxx b/extensions/source/plugin/base/nfuncs.cxx
index e965a5696f94..c3ba2a4fd605 100644
--- a/extensions/source/plugin/base/nfuncs.cxx
+++ b/extensions/source/plugin/base/nfuncs.cxx
@@ -102,8 +102,13 @@ NPNetscapeFuncs aNPNFuncs =
NPN_MemFree,
NPN_MemFlush,
NPN_ReloadPlugins,
+#ifdef OJI
NPN_GetJavaEnv,
NPN_GetJavaPeer,
+#else
+ 0,
+ 0,
+#endif
NPN_GetURLNotify,
NPN_PostURLNotify,
NPN_GetValue,
diff --git a/package/source/xstor/makefile.mk b/package/source/xstor/makefile.mk
index a0e49f2096e0..703873f9ca71 100644
--- a/package/source/xstor/makefile.mk
+++ b/package/source/xstor/makefile.mk
@@ -52,6 +52,7 @@ SLOFILES = \
$(SLO)$/xstorage.obj\
$(SLO)$/xfactory.obj\
$(SLO)$/disposelistener.obj\
+ $(SLO)$/selfterminatefilestream.obj\
$(SLO)$/switchpersistencestream.obj\
$(SLO)$/register.obj
diff --git a/package/source/xstor/owriteablestream.cxx b/package/source/xstor/owriteablestream.cxx
index 8d540a663098..4f3a912b8c0b 100644
--- a/package/source/xstor/owriteablestream.cxx
+++ b/package/source/xstor/owriteablestream.cxx
@@ -48,6 +48,7 @@
#include <comphelper/storagehelper.hxx>
#include <comphelper/ofopxmlhelper.hxx>
+#include "selfterminatefilestream.hxx"
#include "owriteablestream.hxx"
#include "oseekinstream.hxx"
#include "mutexholder.hxx"
@@ -850,6 +851,9 @@ void OWriteStream_Impl::Commit()
if ( m_xCacheStream.is() )
{
+ if ( m_pAntiImpl )
+ m_pAntiImpl->DeInit();
+
uno::Reference< io::XInputStream > xInStream( m_xCacheStream->getInputStream(), uno::UNO_SET_THROW );
xNewPackageStream = uno::Reference< packages::XDataSinkEncrSupport >(
@@ -861,23 +865,16 @@ void OWriteStream_Impl::Commit()
m_xCacheStream = uno::Reference< io::XStream >();
m_xCacheSeek = uno::Reference< io::XSeekable >();
- if ( m_pAntiImpl )
- m_pAntiImpl->DeInit();
}
else if ( m_aTempURL.getLength() )
{
- uno::Reference < ucb::XSimpleFileAccess > xTempAccess(
- GetServiceFactory()->createInstance (
- ::rtl::OUString::createFromAscii( "com.sun.star.ucb.SimpleFileAccess" ) ),
- uno::UNO_QUERY );
-
- if ( !xTempAccess.is() )
- throw uno::RuntimeException(); // TODO:
+ if ( m_pAntiImpl )
+ m_pAntiImpl->DeInit();
uno::Reference< io::XInputStream > xInStream;
try
{
- xInStream = xTempAccess->openFileRead( m_aTempURL );
+ xInStream.set( static_cast< io::XInputStream* >( new OSelfTerminateFileStream( GetServiceFactory(), m_aTempURL ) ), uno::UNO_QUERY );
}
catch( uno::Exception& )
{
@@ -893,9 +890,6 @@ void OWriteStream_Impl::Commit()
// TODO/NEW: Let the temporary file be removed after commit
xNewPackageStream->setDataStream( xInStream );
m_aTempURL = ::rtl::OUString();
-
- if ( m_pAntiImpl )
- m_pAntiImpl->DeInit();
}
else // if ( m_bHasInsertedStreamOptimization )
{
@@ -2627,6 +2621,8 @@ void SAL_CALL OWriteStream::dispose()
m_xInStream = uno::Reference< io::XInputStream >();
}
+ m_xSeekable = uno::Reference< io::XSeekable >();
+
m_pImpl->m_pAntiImpl = NULL;
if ( !m_bInitOnDemand )
diff --git a/package/source/xstor/selfterminatefilestream.cxx b/package/source/xstor/selfterminatefilestream.cxx
new file mode 100644
index 000000000000..ebb707e59de6
--- /dev/null
+++ b/package/source/xstor/selfterminatefilestream.cxx
@@ -0,0 +1,156 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: ocompinstream.cxx,v $
+ * $Revision: 1.12 $
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_package.hxx"
+
+#include <com/sun/star/ucb/XSimpleFileAccess.hpp>
+
+#include "selfterminatefilestream.hxx"
+#include <comphelper/processfactory.hxx>
+
+using namespace ::com::sun::star;
+
+//-----------------------------------------------
+OSelfTerminateFileStream::OSelfTerminateFileStream( const uno::Reference< lang::XMultiServiceFactory > xFactory, const ::rtl::OUString& aURL )
+: m_aURL( aURL )
+{
+ uno::Reference< lang::XMultiServiceFactory > xOwnFactory = xFactory;
+ if ( !xOwnFactory.is() )
+ xOwnFactory.set( ::comphelper::getProcessServiceFactory(), uno::UNO_SET_THROW );
+
+ // IMPORTANT: The implementation is based on idea that m_xFileAccess, m_xInputStream and m_xSeekable are always set
+ // otherwise an exception is thrown in constructor
+
+ m_xFileAccess.set( xOwnFactory->createInstance (
+ ::rtl::OUString::createFromAscii( "com.sun.star.ucb.SimpleFileAccess" ) ),
+ uno::UNO_QUERY_THROW );
+
+ m_xInputStream.set( m_xFileAccess->openFileRead( aURL ), uno::UNO_SET_THROW );
+ m_xSeekable.set( m_xInputStream, uno::UNO_QUERY_THROW );
+}
+
+//-----------------------------------------------
+OSelfTerminateFileStream::~OSelfTerminateFileStream()
+{
+ CloseStreamDeleteFile();
+}
+
+//-----------------------------------------------
+void OSelfTerminateFileStream::CloseStreamDeleteFile()
+{
+ try
+ {
+ m_xInputStream->closeInput();
+ }
+ catch( uno::Exception& )
+ {}
+
+ try
+ {
+ m_xFileAccess->kill( m_aURL );
+ }
+ catch( uno::Exception& )
+ {}
+}
+
+//-----------------------------------------------
+sal_Int32 SAL_CALL OSelfTerminateFileStream::readBytes( uno::Sequence< sal_Int8 >& aData, sal_Int32 nBytesToRead )
+ throw ( io::NotConnectedException,
+ io::BufferSizeExceededException,
+ io::IOException,
+ uno::RuntimeException )
+{
+ return m_xInputStream->readBytes( aData, nBytesToRead );
+}
+
+//-----------------------------------------------
+sal_Int32 SAL_CALL OSelfTerminateFileStream::readSomeBytes( uno::Sequence< sal_Int8 >& aData, sal_Int32 nMaxBytesToRead )
+ throw ( io::NotConnectedException,
+ io::BufferSizeExceededException,
+ io::IOException,
+ uno::RuntimeException )
+{
+ return m_xInputStream->readSomeBytes( aData, nMaxBytesToRead );
+}
+
+//-----------------------------------------------
+void SAL_CALL OSelfTerminateFileStream::skipBytes( sal_Int32 nBytesToSkip )
+ throw ( io::NotConnectedException,
+ io::BufferSizeExceededException,
+ io::IOException,
+ uno::RuntimeException )
+{
+ return m_xInputStream->skipBytes( nBytesToSkip );
+}
+
+//-----------------------------------------------
+sal_Int32 SAL_CALL OSelfTerminateFileStream::available( )
+ throw ( io::NotConnectedException,
+ io::IOException,
+ uno::RuntimeException )
+{
+ return m_xInputStream->available();
+}
+
+//-----------------------------------------------
+void SAL_CALL OSelfTerminateFileStream::closeInput( )
+ throw ( io::NotConnectedException,
+ io::IOException,
+ uno::RuntimeException )
+{
+ CloseStreamDeleteFile();
+}
+
+//-----------------------------------------------
+void SAL_CALL OSelfTerminateFileStream::seek( sal_Int64 location )
+ throw ( lang::IllegalArgumentException,
+ io::IOException,
+ uno::RuntimeException )
+{
+ m_xSeekable->seek( location );
+}
+
+//-----------------------------------------------
+sal_Int64 SAL_CALL OSelfTerminateFileStream::getPosition()
+ throw ( io::IOException,
+ uno::RuntimeException)
+{
+ return m_xSeekable->getPosition();
+}
+
+//-----------------------------------------------
+sal_Int64 SAL_CALL OSelfTerminateFileStream::getLength()
+ throw ( io::IOException,
+ uno::RuntimeException )
+{
+ return m_xSeekable->getLength();
+}
+
diff --git a/package/source/xstor/selfterminatefilestream.hxx b/package/source/xstor/selfterminatefilestream.hxx
new file mode 100644
index 000000000000..6f95ba17ec42
--- /dev/null
+++ b/package/source/xstor/selfterminatefilestream.hxx
@@ -0,0 +1,79 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: ocompinstream.hxx,v $
+ * $Revision: 1.7 $
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef _SELFTERMINATEFILESTREAM_HXX_
+#define _SELFTERMINATEFILESTREAM_HXX_
+
+#include <com/sun/star/io/XInputStream.hpp>
+#include <com/sun/star/io/XSeekable.hpp>
+#include <com/sun/star/ucb/XSimpleFileAccess.hpp>
+#include <cppuhelper/implbase2.hxx>
+
+struct OWriteStream_Impl;
+
+class OSelfTerminateFileStream : public cppu::WeakImplHelper2< ::com::sun::star::io::XInputStream,
+ ::com::sun::star::io::XSeekable >
+{
+protected:
+ ::com::sun::star::uno::Reference< ::com::sun::star::ucb::XSimpleFileAccess > m_xFileAccess;
+
+ ::rtl::OUString m_aURL;
+
+ ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream > m_xInputStream;
+ ::com::sun::star::uno::Reference< ::com::sun::star::io::XSeekable > m_xSeekable;
+
+public:
+ OSelfTerminateFileStream( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > xFactory, const ::rtl::OUString& aURL );
+
+ virtual ~OSelfTerminateFileStream();
+
+ void CloseStreamDeleteFile();
+
+ // XInputStream
+ virtual sal_Int32 SAL_CALL readBytes( ::com::sun::star::uno::Sequence< sal_Int8 >& aData, sal_Int32 nBytesToRead )
+ throw(::com::sun::star::io::NotConnectedException, ::com::sun::star::io::BufferSizeExceededException, ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Int32 SAL_CALL readSomeBytes( ::com::sun::star::uno::Sequence< sal_Int8 >& aData, sal_Int32 nMaxBytesToRead )
+ throw(::com::sun::star::io::NotConnectedException, ::com::sun::star::io::BufferSizeExceededException, ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL skipBytes( sal_Int32 nBytesToSkip )
+ throw(::com::sun::star::io::NotConnectedException, ::com::sun::star::io::BufferSizeExceededException, ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Int32 SAL_CALL available()
+ throw(::com::sun::star::io::NotConnectedException, ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL closeInput()
+ throw(::com::sun::star::io::NotConnectedException, ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException);
+
+ //XSeekable
+ virtual void SAL_CALL seek( sal_Int64 location ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Int64 SAL_CALL getPosition() throw (::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Int64 SAL_CALL getLength() throw (::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException);
+
+};
+
+#endif
+
diff --git a/package/source/zippackage/ZipPackage.cxx b/package/source/zippackage/ZipPackage.cxx
index 759f7d4d7d03..a692586681b5 100644
--- a/package/source/zippackage/ZipPackage.cxx
+++ b/package/source/zippackage/ZipPackage.cxx
@@ -135,25 +135,6 @@ sal_Bool isLocalFile_Impl( ::rtl::OUString aURL )
return ( aSystemPath.getLength() != 0 );
}
-class PostinitializationGuard
-{
- uno::Reference< io::XInputStream > m_xTempStream;
-
- ZipPackage& m_rZipPackage;
-
-public:
- PostinitializationGuard( const uno::Reference< io::XInputStream >& xTempStream,
- ZipPackage& rZipPackage )
- : m_xTempStream( xTempStream )
- , m_rZipPackage( rZipPackage )
- {}
-
- virtual ~PostinitializationGuard()
- {
- m_rZipPackage.ConnectTo( m_xTempStream );
- }
-};
-
}
//===========================================================================
@@ -1380,8 +1361,8 @@ void SAL_CALL ZipPackage::commitChanges()
static_cast < OWeakObject * > ( this ), makeAny ( r ) );
}
- // switch to the new temporary stream only after the transfer
- PostinitializationGuard aPostInitGuard( xTempInStream, *this );
+ // connect to the temporary stream
+ ConnectTo( xTempInStream );
if ( m_eMode == e_IMode_XStream )
{