diff options
author | Palenik Mihály <palenik.mihaly@gmail.com> | 2013-07-11 18:30:38 +0200 |
---|---|---|
committer | Andras Timar <atimar@suse.com> | 2013-07-16 13:31:53 +0000 |
commit | c66e9cd24c28ff00f15770037ae9a8dd852fdada (patch) | |
tree | acb0aa67c05bc46a8093fa9646bf25a19e9cc1ad /tools/source | |
parent | 159e3639077d8e05707133969c4e5cd710c10e2e (diff) |
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/4847
Reviewed-by: Andras Timar <atimar@suse.com>
Tested-by: Andras Timar <atimar@suse.com>
Diffstat (limited to 'tools/source')
-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 |
3 files changed, 17 insertions, 128 deletions
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 ) { |