use more TempFileFastService in scripting
Change-Id: Ic04abad55e655fa0e0434bd09f797c6f1b2cc245 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/141649 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
This commit is contained in:
committed by
Noel Grandin
parent
0df36d45b6
commit
8cbc179ace
@@ -25,6 +25,7 @@ $(eval $(call gb_Library_use_libraries,stringresource,\
|
|||||||
cppu \
|
cppu \
|
||||||
cppuhelper \
|
cppuhelper \
|
||||||
sal \
|
sal \
|
||||||
|
utl \
|
||||||
tl \
|
tl \
|
||||||
i18nlangtag \
|
i18nlangtag \
|
||||||
))
|
))
|
||||||
|
@@ -34,9 +34,11 @@
|
|||||||
|
|
||||||
#include <osl/diagnose.h>
|
#include <osl/diagnose.h>
|
||||||
#include <o3tl/string_view.hxx>
|
#include <o3tl/string_view.hxx>
|
||||||
|
#include <rtl/ref.hxx>
|
||||||
#include <rtl/tencinfo.h>
|
#include <rtl/tencinfo.h>
|
||||||
#include <rtl/ustrbuf.hxx>
|
#include <rtl/ustrbuf.hxx>
|
||||||
#include <tools/urlobj.hxx>
|
#include <tools/urlobj.hxx>
|
||||||
|
#include <unotools/tempfile.hxx>
|
||||||
#include <i18nlangtag/languagetag.hxx>
|
#include <i18nlangtag/languagetag.hxx>
|
||||||
#include <sal/log.hxx>
|
#include <sal/log.hxx>
|
||||||
|
|
||||||
@@ -1046,12 +1048,11 @@ void StringResourcePersistenceImpl::implStoreAtLocation
|
|||||||
|
|
||||||
class BinaryOutput
|
class BinaryOutput
|
||||||
{
|
{
|
||||||
Reference< XComponentContext > m_xContext;
|
rtl::Reference< utl::TempFileFastService > m_xTempFile;
|
||||||
Reference< XInterface > m_xTempFile;
|
|
||||||
Reference< io::XOutputStream > m_xOutputStream;
|
Reference< io::XOutputStream > m_xOutputStream;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit BinaryOutput( Reference< XComponentContext > const & xContext );
|
explicit BinaryOutput();
|
||||||
|
|
||||||
const Reference< io::XOutputStream >& getOutputStream() const
|
const Reference< io::XOutputStream >& getOutputStream() const
|
||||||
{ return m_xOutputStream; }
|
{ return m_xOutputStream; }
|
||||||
@@ -1069,11 +1070,10 @@ public:
|
|||||||
void writeString( const OUString& aStr );
|
void writeString( const OUString& aStr );
|
||||||
};
|
};
|
||||||
|
|
||||||
BinaryOutput::BinaryOutput( Reference< XComponentContext > const & xContext )
|
BinaryOutput::BinaryOutput()
|
||||||
: m_xContext( xContext )
|
|
||||||
{
|
{
|
||||||
m_xTempFile = io::TempFile::create( m_xContext );
|
m_xTempFile = new utl::TempFileFastService;
|
||||||
m_xOutputStream.set( m_xTempFile, UNO_QUERY_THROW );
|
m_xOutputStream = m_xTempFile;
|
||||||
}
|
}
|
||||||
|
|
||||||
template< class T >
|
template< class T >
|
||||||
@@ -1128,18 +1128,10 @@ Sequence< ::sal_Int8 > BinaryOutput::closeAndGetData()
|
|||||||
|
|
||||||
m_xOutputStream->closeOutput();
|
m_xOutputStream->closeOutput();
|
||||||
|
|
||||||
Reference< io::XSeekable> xSeekable( m_xTempFile, UNO_QUERY );
|
sal_Int32 nSize = static_cast<sal_Int32>(m_xTempFile->getPosition());
|
||||||
if( !xSeekable.is() )
|
|
||||||
return aRetSeq;
|
|
||||||
|
|
||||||
sal_Int32 nSize = static_cast<sal_Int32>(xSeekable->getPosition());
|
m_xTempFile->seek( 0 );
|
||||||
|
sal_Int32 nRead = m_xTempFile->readBytes( aRetSeq, nSize );
|
||||||
Reference< io::XInputStream> xInputStream( m_xTempFile, UNO_QUERY );
|
|
||||||
if( !xInputStream.is() )
|
|
||||||
return aRetSeq;
|
|
||||||
|
|
||||||
xSeekable->seek( 0 );
|
|
||||||
sal_Int32 nRead = xInputStream->readBytes( aRetSeq, nSize );
|
|
||||||
OSL_ENSURE( nRead == nSize, "BinaryOutput::closeAndGetData: nRead != nSize" );
|
OSL_ENSURE( nRead == nSize, "BinaryOutput::closeAndGetData: nRead != nSize" );
|
||||||
|
|
||||||
return aRetSeq;
|
return aRetSeq;
|
||||||
@@ -1175,7 +1167,7 @@ Sequence< ::sal_Int8 > BinaryOutput::closeAndGetData()
|
|||||||
|
|
||||||
Sequence< sal_Int8 > StringResourcePersistenceImpl::exportBinary( )
|
Sequence< sal_Int8 > StringResourcePersistenceImpl::exportBinary( )
|
||||||
{
|
{
|
||||||
BinaryOutput aOut( m_xContext );
|
BinaryOutput aOut;
|
||||||
|
|
||||||
sal_Int32 nLocaleCount = m_aLocaleItemVector.size();
|
sal_Int32 nLocaleCount = m_aLocaleItemVector.size();
|
||||||
std::vector<Sequence< sal_Int8 >> aLocaleDataSeq(nLocaleCount);
|
std::vector<Sequence< sal_Int8 >> aLocaleDataSeq(nLocaleCount);
|
||||||
@@ -1189,7 +1181,7 @@ Sequence< sal_Int8 > StringResourcePersistenceImpl::exportBinary( )
|
|||||||
if( m_pDefaultLocaleItem == pLocaleItem.get() )
|
if( m_pDefaultLocaleItem == pLocaleItem.get() )
|
||||||
iDefault = iLocale;
|
iDefault = iLocale;
|
||||||
|
|
||||||
BinaryOutput aLocaleOut( m_xContext );
|
BinaryOutput aLocaleOut;
|
||||||
implWriteLocaleBinary( pLocaleItem.get(), aLocaleOut );
|
implWriteLocaleBinary( pLocaleItem.get(), aLocaleOut );
|
||||||
|
|
||||||
aLocaleDataSeq[iLocale] = aLocaleOut.closeAndGetData();
|
aLocaleDataSeq[iLocale] = aLocaleOut.closeAndGetData();
|
||||||
@@ -1291,15 +1283,11 @@ Reference< io::XInputStream > BinaryInput::getInputStreamForSection( sal_Int32 n
|
|||||||
Reference< io::XInputStream > xIn;
|
Reference< io::XInputStream > xIn;
|
||||||
if( m_nCurPos + nSize <= m_nSize )
|
if( m_nCurPos + nSize <= m_nSize )
|
||||||
{
|
{
|
||||||
Reference< io::XOutputStream > xTempOut( io::TempFile::create(m_xContext), UNO_QUERY_THROW );
|
rtl::Reference< utl::TempFileFastService > xTempOut = new utl::TempFileFastService;
|
||||||
Sequence< sal_Int8 > aSection( m_pData + m_nCurPos, nSize );
|
Sequence< sal_Int8 > aSection( m_pData + m_nCurPos, nSize );
|
||||||
xTempOut->writeBytes( aSection );
|
xTempOut->writeBytes( aSection );
|
||||||
|
xTempOut->seek( 0 );
|
||||||
Reference< io::XSeekable> xSeekable( xTempOut, UNO_QUERY );
|
xIn = xTempOut;
|
||||||
if( xSeekable.is() )
|
|
||||||
xSeekable->seek( 0 );
|
|
||||||
|
|
||||||
xIn.set( xTempOut, UNO_QUERY );
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
OSL_FAIL( "BinaryInput::getInputStreamForSection(): Read past end" );
|
OSL_FAIL( "BinaryInput::getInputStreamForSection(): Read past end" );
|
||||||
|
Reference in New Issue
Block a user