diff options
-rw-r--r-- | include/tools/cachestr.hxx | 64 | ||||
-rw-r--r-- | include/tools/stream.hxx | 7 | ||||
-rw-r--r-- | sfx2/source/bastyp/mieclip.cxx | 5 | ||||
-rw-r--r-- | sot/source/sdstor/storage.cxx | 3 | ||||
-rw-r--r-- | svl/source/items/lckbitem.cxx | 5 | ||||
-rw-r--r-- | sw/inc/pch/precompiled_sw.hxx | 1 | ||||
-rw-r--r-- | sw/source/core/edit/edglss.cxx | 3 | ||||
-rw-r--r-- | sw/source/core/unocore/unoobj.cxx | 3 | ||||
-rw-r--r-- | sw/source/core/unocore/unoobj2.cxx | 1 | ||||
-rw-r--r-- | sw/source/ui/wrtsh/wrtsh1.cxx | 1 | ||||
-rw-r--r-- | tools/Library_tl.mk | 1 | ||||
-rw-r--r-- | tools/source/inet/inetstrm.cxx | 5 | ||||
-rw-r--r-- | tools/source/stream/cachestr.cxx | 125 | ||||
-rw-r--r-- | tools/source/stream/stream.cxx | 15 |
14 files changed, 28 insertions, 211 deletions
diff --git a/include/tools/cachestr.hxx b/include/tools/cachestr.hxx deleted file mode 100644 index 6d980566a96a..000000000000 --- a/include/tools/cachestr.hxx +++ /dev/null @@ -1,64 +0,0 @@ -/* -*- 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: */ diff --git a/include/tools/stream.hxx b/include/tools/stream.hxx index 8aed53c1fd15..d71f1587d18c 100644 --- a/include/tools/stream.hxx +++ b/include/tools/stream.hxx @@ -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 diff --git a/sfx2/source/bastyp/mieclip.cxx b/sfx2/source/bastyp/mieclip.cxx index d9e50ea7c2fd..71776fdaa738 100644 --- a/sfx2/source/bastyp/mieclip.cxx +++ b/sfx2/source/bastyp/mieclip.cxx @@ -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); diff --git a/sot/source/sdstor/storage.cxx b/sot/source/sdstor/storage.cxx index 68da44187e44..3ae023668533 100644 --- a/sot/source/sdstor/storage.cxx +++ b/sot/source/sdstor/storage.cxx @@ -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; diff --git a/svl/source/items/lckbitem.cxx b/svl/source/items/lckbitem.cxx index e3c58862eaa9..05d7ae3b5453 100644 --- a/svl/source/items/lckbitem.cxx +++ b/svl/source/items/lckbitem.cxx @@ -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); diff --git a/sw/inc/pch/precompiled_sw.hxx b/sw/inc/pch/precompiled_sw.hxx index 1a5339e85a82..e829e8649170 100644 --- a/sw/inc/pch/precompiled_sw.hxx +++ b/sw/inc/pch/precompiled_sw.hxx @@ -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> diff --git a/sw/source/core/edit/edglss.cxx b/sw/source/core/edit/edglss.cxx index af1f793017db..fbec264b5d33 100644 --- a/sw/source/core/edit/edglss.cxx +++ b/sw/source/core/edit/edglss.cxx @@ -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 diff --git a/sw/source/core/unocore/unoobj.cxx b/sw/source/core/unocore/unoobj.cxx index f4ac2b6dbad8..65c7cb1b9460 100644 --- a/sw/source/core/unocore/unoobj.cxx +++ b/sw/source/core/unocore/unoobj.cxx @@ -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 diff --git a/sw/source/core/unocore/unoobj2.cxx b/sw/source/core/unocore/unoobj2.cxx index 973cbe7dc51e..1d0c0666ef90 100644 --- a/sw/source/core/unocore/unoobj2.cxx +++ b/sw/source/core/unocore/unoobj2.cxx @@ -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> diff --git a/sw/source/ui/wrtsh/wrtsh1.cxx b/sw/source/ui/wrtsh/wrtsh1.cxx index 7ad48a33a788..df5cd69a5efd 100644 --- a/sw/source/ui/wrtsh/wrtsh1.cxx +++ b/sw/source/ui/wrtsh/wrtsh1.cxx @@ -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> diff --git a/tools/Library_tl.mk b/tools/Library_tl.mk index e0d19b84e358..56c48dba5a9a 100644 --- a/tools/Library_tl.mk +++ b/tools/Library_tl.mk @@ -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 \ diff --git a/tools/source/inet/inetstrm.cxx b/tools/source/inet/inetstrm.cxx index 3e619d841c7b..8204eeccee0c 100644 --- a/tools/source/inet/inetstrm.cxx +++ b/tools/source/inet/inetstrm.cxx @@ -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 ); diff --git a/tools/source/stream/cachestr.cxx b/tools/source/stream/cachestr.cxx deleted file mode 100644 index 8b988b136ff7..000000000000 --- a/tools/source/stream/cachestr.cxx +++ /dev/null @@ -1,125 +0,0 @@ -/* -*- 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: */ diff --git a/tools/source/stream/stream.cxx b/tools/source/stream/stream.cxx index a3053a9fc907..05f7ac3fbc7e 100644 --- a/tools/source/stream/stream.cxx +++ b/tools/source/stream/stream.cxx @@ -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 ) { |