Kaydet (Commit) c66e9cd2 authored tarafından Palenik Mihály's avatar Palenik Mihály Kaydeden (comit) Andras Timar

Delete SvCacheStream class

I changed SvCacheStream class to SvMemoryStream class in
the following:  MSE40HTMLClipFormatObj, SfxLockBytesItem,
SwEditShell, INetMIMEMessageStream classes,
MakeLockBytes_Impl function and SwUnoCursorHelper namespace.
I modified header the precompiled_sw.hxx, wrtsh1.cxx, unoobj2.cxx.
I added two functions in SvMemoryStream class: GetBuffer and
GetSize, and I renamed the old GetSize function to GetBufSize.
I deleted SvCacheStream class.

Change-Id: I929236538dfbe23cccfd1eb85f10c1d5411baa8d
Reviewed-on: https://gerrit.libreoffice.org/4847Reviewed-by: 's avatarAndras Timar <atimar@suse.com>
Tested-by: 's avatarAndras Timar <atimar@suse.com>
üst 159e3639
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* This file incorporates work covered by the following license notice:
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
#ifndef _CACHESTR_HXX
#define _CACHESTR_HXX
#include <tools/stream.hxx>
#include "tools/toolsdllapi.h"
class TempFile;
class TOOLS_DLLPUBLIC SvCacheStream : public SvStream
{
private:
OUString aFileName;
sal_uIntPtr nMaxSize;
bool bPersistent;
SvStream* pSwapStream;
SvStream* pCurrentStream;
TempFile* pTempFile;
TOOLS_DLLPRIVATE virtual sal_uIntPtr GetData( void* pData,
sal_uIntPtr nSize );
TOOLS_DLLPRIVATE virtual sal_uIntPtr PutData( const void* pData,
sal_uIntPtr nSize );
TOOLS_DLLPRIVATE virtual sal_uIntPtr SeekPos( sal_uIntPtr nPos );
TOOLS_DLLPRIVATE virtual void FlushData();
TOOLS_DLLPRIVATE virtual void SetSize( sal_uIntPtr nSize );
public:
SvCacheStream( sal_uIntPtr nMaxMemSize = 0 );
~SvCacheStream();
void SetFilename( const OUString& rFN ) { aFileName = rFN; } // call only from FilenameHdl
const OUString& GetFilename() const { return aFileName; }
void SwapOut();
const void* GetBuffer();
sal_uIntPtr GetSize();
bool IsPersistent() { return bPersistent; }
void SetPersistence( bool b = true ) { bPersistent = b; }
void SetSwapStream( SvStream *p ) { pSwapStream = p; } // call only from FilenameHdl
};
#endif
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
......@@ -702,8 +702,7 @@ class TOOLS_DLLPUBLIC SvMemoryStream : public SvStream
SvMemoryStream (const SvMemoryStream&);
SvMemoryStream & operator= (const SvMemoryStream&);
friend class SvCacheStream;
sal_Size GetSize() const { return nSize; }
sal_Size GetBufSize() const { return nSize; }
protected:
sal_Size nSize;
......@@ -744,6 +743,8 @@ public:
virtual void ResetError();
const void* GetBuffer();
sal_uIntPtr GetSize();
sal_Size GetEndOfData() const { return nEndOfData; }
const void* GetData() { Flush(); return pBuf; }
operator const void*() { Flush(); return pBuf; }
......@@ -757,7 +758,7 @@ public:
bool IsObjectMemoryOwner() { return bOwnsData; }
void SetResizeOffset( sal_Size nNewResize ) { nResize = nNewResize; }
sal_Size GetResizeOffset() const { return nResize; }
virtual sal_Size remainingSize() { return GetSize() - Tell(); }
virtual sal_Size remainingSize() { return GetBufSize() - Tell(); }
};
/** Data Copy Stream
......
......@@ -18,7 +18,6 @@
*/
#include <tools/stream.hxx>
#include <tools/cachestr.hxx>
#include <sot/storage.hxx>
#include <sot/formats.hxx>
......@@ -76,7 +75,7 @@ SvStream* MSE40HTMLClipFormatObj::IsValid( SvStream& rStream )
{
rStream.Seek( nStt );
pStrm = new SvCacheStream( ( nEnd - nStt < 0x10000l
pStrm = new SvMemoryStream( ( nEnd - nStt < 0x10000l
? nEnd - nStt + 32
: 0 ));
*pStrm << rStream;
......@@ -91,7 +90,7 @@ SvStream* MSE40HTMLClipFormatObj::IsValid( SvStream& rStream )
if (nSize < 0x10000L)
{
rStream.Seek(nFragStart);
pStrm = new SvCacheStream(nSize);
pStrm = new SvMemoryStream(nSize);
*pStrm << rStream;
pStrm->SetStreamSize(nSize);
pStrm->Seek(STREAM_SEEK_TO_BEGIN);
......
......@@ -31,7 +31,6 @@
#include <sot/formats.hxx>
#include <sot/exchange.hxx>
#include <unotools/ucbstreamhelper.hxx>
#include <tools/cachestr.hxx>
#include <tools/debug.hxx>
#include <tools/urlobj.hxx>
#include <unotools/localfilehelper.hxx>
......@@ -68,7 +67,7 @@ SvLockBytesRef MakeLockBytes_Impl( const OUString & rName, StreamMode nMode )
}
else
{
SvStream * pCacheStm = new SvCacheStream();
SvStream * pCacheStm = new SvMemoryStream();
xLB = new SvLockBytes( pCacheStm, true );
}
return xLB;
......
......@@ -21,7 +21,6 @@
#include <svl/poolitem.hxx>
#include <com/sun/star/uno/Any.hxx>
#include <com/sun/star/uno/Sequence.hxx>
#include <tools/cachestr.hxx>
// -----------------------------------------------------------------------
......@@ -39,7 +38,7 @@ SfxLockBytesItem::SfxLockBytesItem( sal_uInt16 nW, SvStream &rStream )
: SfxPoolItem( nW )
{
rStream.Seek( 0L );
_xVal = new SvLockBytes( new SvCacheStream(), sal_True );
_xVal = new SvLockBytes( new SvMemoryStream(), sal_True );
SvStream aLockBytesStream( _xVal );
rStream >> aLockBytesStream;
......@@ -121,7 +120,7 @@ bool SfxLockBytesItem::PutValue( const com::sun::star::uno::Any& rVal, sal_uInt8
{
if ( aSeq.getLength() )
{
SvCacheStream* pStream = new SvCacheStream;
SvMemoryStream* pStream = new SvMemoryStream();
pStream->Write( (void*)aSeq.getConstArray(), aSeq.getLength() );
pStream->Seek(0);
......
......@@ -955,7 +955,6 @@
#include <toolkit/awt/vclxdevice.hxx>
#include <toolkit/helper/vclunohelper.hxx>
#include <tools/bigint.hxx>
#include <tools/cachestr.hxx>
#include <tools/color.hxx>
#include <tools/date.hxx>
#include <tools/datetime.hxx>
......
......@@ -21,7 +21,6 @@
#include <osl/endian.h>
#include <hintids.hxx>
#include <svl/urihelper.hxx>
#include <tools/cachestr.hxx>
#include <doc.hxx>
#include <pam.hxx>
#include <docary.hxx>
......@@ -276,7 +275,7 @@ sal_Bool SwEditShell::GetSelectedText( String &rBuf, int nHndlParaBrk )
}
else if( IsSelection() )
{
SvCacheStream aStream(20480);
SvMemoryStream aStream;
#ifdef OSL_BIGENDIAN
aStream.SetNumberFormatInt( NUMBERFORMAT_INT_BIGENDIAN );
#else
......
......@@ -43,7 +43,6 @@
#include <docary.hxx>
#include <paratr.hxx>
#include <pam.hxx>
#include <tools/cachestr.hxx>
#include <shellio.hxx>
#include <swerror.h>
#include <swtblfmt.hxx>
......@@ -169,7 +168,7 @@ void SwUnoCursorHelper::GetTextFromPam(SwPaM & rPam, OUString & rBuffer)
{
return;
}
SvCacheStream aStream( 20480 );
SvMemoryStream aStream;
#ifdef OSL_BIGENDIAN
aStream.SetNumberFormatInt( NUMBERFORMAT_INT_BIGENDIAN );
#else
......
......@@ -38,7 +38,6 @@
#include <docary.hxx>
#include <paratr.hxx>
#include <pam.hxx>
#include <tools/cachestr.hxx>
#include <shellio.hxx>
#include <swerror.h>
#include <swtblfmt.hxx>
......
......@@ -42,7 +42,6 @@
#include <sfx2/ipclient.hxx>
#include <svtools/ehdl.hxx>
#include <svtools/soerr.hxx>
#include <tools/cachestr.hxx>
#include <unotools/moduleoptions.hxx>
#include <editeng/sizeitem.hxx>
#include <editeng/formatbreakitem.hxx>
......
......@@ -80,7 +80,6 @@ $(eval $(call gb_Library_add_exception_objects,tl,\
tools/source/ref/globname \
tools/source/ref/pstm \
tools/source/ref/ref \
tools/source/stream/cachestr \
tools/source/stream/stream \
tools/source/stream/strmsys \
tools/source/stream/vcompat \
......
......@@ -20,7 +20,6 @@
#include <comphelper/string.hxx>
#include <sal/types.h>
#include <rtl/strbuf.hxx>
#include <tools/cachestr.hxx>
#include <tools/inetmsg.hxx>
#include <tools/inetstrm.hxx>
......@@ -1396,7 +1395,7 @@ int INetMIMEMessageStream::PutMsgLine(const sal_Char* pData, sal_uIntPtr nSize)
{
// Encapsulated message.
INetMIMEMessage* pNewMessage = new INetMIMEMessage;
pNewMessage->SetDocumentLB( new SvAsyncLockBytes(new SvCacheStream, false));
pNewMessage->SetDocumentLB( new SvAsyncLockBytes(new SvMemoryStream(), false));
pMsg->AttachChild( *pNewMessage, true );
// Encapsulated message body. Create message parser stream.
......@@ -1509,7 +1508,7 @@ int INetMIMEMessageStream::PutMsgLine(const sal_Char* pData, sal_uIntPtr nSize)
new INetMIMEMessage;
pNewMessage->SetDocumentLB(
new SvAsyncLockBytes(
new SvCacheStream, false));
new SvMemoryStream(), false));
pMsg->AttachChild( *pNewMessage, true );
......
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* This file incorporates work covered by the following license notice:
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
#include <rtl/ustring.hxx>
#include <tools/stream.hxx>
#include <tools/cachestr.hxx>
#include <tools/tempfile.hxx>
SvCacheStream::SvCacheStream( sal_uIntPtr nMaxMemSize )
{
if( !nMaxMemSize )
nMaxMemSize = 20480;
SvStream::bIsWritable = true;
nMaxSize = nMaxMemSize;
bPersistent = false;
pSwapStream = 0;
pCurrentStream = new SvMemoryStream( nMaxMemSize );
pTempFile = 0;
}
SvCacheStream::~SvCacheStream()
{
if( pCurrentStream != pSwapStream )
delete pSwapStream;
delete pCurrentStream;
if( pSwapStream && !bPersistent && pTempFile )
{
// temporaeres File loeschen
pTempFile->EnableKillingFile( true );
}
delete pTempFile;
}
void SvCacheStream::SwapOut()
{
if( pCurrentStream != pSwapStream )
{
if( !pSwapStream && aFileName.isEmpty() )
{
pTempFile = new TempFile;
aFileName = pTempFile->GetName();
}
sal_uIntPtr nPos = pCurrentStream->Tell();
pCurrentStream->Seek( 0 );
if( !pSwapStream )
pSwapStream = new SvFileStream( aFileName, STREAM_READWRITE | STREAM_TRUNC );
*pSwapStream << *pCurrentStream;
pSwapStream->Flush();
delete pCurrentStream;
pCurrentStream = pSwapStream;
pCurrentStream->Seek( nPos );
}
}
sal_uIntPtr SvCacheStream::GetData( void* pData, sal_uIntPtr nSize )
{
return pCurrentStream->Read( pData, nSize );
}
sal_uIntPtr SvCacheStream::PutData( const void* pData, sal_uIntPtr nSize )
{
// prefer swapping data instead copying it again
if( pCurrentStream != pSwapStream
&& pCurrentStream->Tell() + nSize > nMaxSize )
SwapOut();
return pCurrentStream->Write( pData, nSize );
}
sal_uIntPtr SvCacheStream::SeekPos( sal_uIntPtr nPos )
{
return pCurrentStream->Seek( nPos );
}
void SvCacheStream::FlushData()
{
pCurrentStream->Flush();
if( pCurrentStream != pSwapStream
&& ((SvMemoryStream*)pCurrentStream)->GetSize() > nMaxSize )
SwapOut();
}
const void* SvCacheStream::GetBuffer()
{
Flush();
if( pCurrentStream != pSwapStream )
return ((SvMemoryStream*)pCurrentStream)->GetData();
else
return 0;
}
void SvCacheStream::SetSize( sal_uIntPtr nSize )
{
pCurrentStream->SetStreamSize( nSize );
}
sal_uIntPtr SvCacheStream::GetSize()
{
// CAUTION: SvMemoryStream::GetSize() returns size of the allocated buffer
Flush();
sal_uIntPtr nTemp = Tell();
sal_uIntPtr nLength = Seek( STREAM_SEEK_TO_END );
Seek( nTemp );
return nLength;
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
......@@ -1715,6 +1715,21 @@ sal_uInt16 SvMemoryStream::IsA() const
return (sal_uInt16)ID_MEMORYSTREAM;
}
const void* SvMemoryStream::GetBuffer()
{
Flush();
return (const void*)GetData();
}
sal_uIntPtr SvMemoryStream::GetSize()
{
Flush();
sal_uIntPtr nTemp = Tell();
sal_uIntPtr nLength = Seek( STREAM_SEEK_TO_END );
Seek( nTemp );
return nLength;
}
void* SvMemoryStream::SetBuffer( void* pNewBuf, sal_Size nCount,
bool bOwnsDat, sal_Size nEOF )
{
......
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