diff options
22 files changed, 27 insertions, 44 deletions
diff --git a/connectivity/source/drivers/dbase/DTable.cxx b/connectivity/source/drivers/dbase/DTable.cxx index c5da1d6b2477..0f8f72328a0b 100644 --- a/connectivity/source/drivers/dbase/DTable.cxx +++ b/connectivity/source/drivers/dbase/DTable.cxx @@ -1004,9 +1004,6 @@ bool ODbaseTable::fetchRow(OValueRefRow& _rRow, const OSQLColumns & _rCols, bool void ODbaseTable::FileClose() { ::osl::MutexGuard aGuard(m_aMutex); - // if not everything has been written yet - if (m_pMemoStream && m_pMemoStream->IsWritable()) - m_pMemoStream->Flush(); m_pMemoStream.reset(); @@ -1415,7 +1412,6 @@ bool ODbaseTable::CreateMemoFile(const INetURLObject& aFile) m_pMemoStream->Seek(0); (*m_pMemoStream).WriteUInt32( 1 ); // pointer to the first free block - m_pMemoStream->Flush(); m_pMemoStream.reset(); return true; } diff --git a/connectivity/source/drivers/file/FTable.cxx b/connectivity/source/drivers/file/FTable.cxx index 50475449ef73..af2d6de226f8 100644 --- a/connectivity/source/drivers/file/FTable.cxx +++ b/connectivity/source/drivers/file/FTable.cxx @@ -136,9 +136,6 @@ void OFileTable::FileClose() { ::osl::MutexGuard aGuard(m_aMutex); - if (m_pFileStream && m_pFileStream->IsWritable()) - m_pFileStream->Flush(); - m_pFileStream.reset(); m_pBuffer.reset(); } diff --git a/editeng/source/editeng/impedit4.cxx b/editeng/source/editeng/impedit4.cxx index e160f3896f37..8c2d054e72ee 100644 --- a/editeng/source/editeng/impedit4.cxx +++ b/editeng/source/editeng/impedit4.cxx @@ -641,7 +641,6 @@ ErrCode ImpEditEngine::WriteRTF( SvStream& rOutput, EditSelection aSel ) } // RTF-trailer ... rOutput.WriteCharPtr( "}}" ); // 1xparentheses paragraphs, 1xparentheses RTF document - rOutput.Flush(); aFontTable.clear(); diff --git a/forms/source/component/DatabaseForm.cxx b/forms/source/component/DatabaseForm.cxx index 74fbaf77e6be..873781f580ce 100644 --- a/forms/source/component/DatabaseForm.cxx +++ b/forms/source/component/DatabaseForm.cxx @@ -496,7 +496,7 @@ Sequence<sal_Int8> ODatabaseForm::GetDataMultiPartEncoded(const Reference<XContr } pBuf.reset(); - aMemStream.Flush(); + aMemStream.FlushBuffer(); aMemStream.Seek( 0 ); void const * pData = aMemStream.GetData(); sal_Int32 nLen = aMemStream.TellEnd(); @@ -940,7 +940,7 @@ void ODatabaseForm::InsertTextPart( INetMIMEMessage& rParent, std::u16string_vie // Body SvMemoryStream* pStream = new SvMemoryStream; pStream->WriteLine( OUStringToOString(rData, rtl_getTextEncodingFromMimeCharset(pBestMatchingEncoding)) ); - pStream->Flush(); + pStream->FlushBuffer(); pStream->Seek( 0 ); pChild->SetDocumentLB( new SvLockBytes(pStream, true) ); rParent.AttachChild( std::move(pChild) ); diff --git a/include/tools/stream.hxx b/include/tools/stream.hxx index 306a7584a8c3..9c9591a86355 100644 --- a/include/tools/stream.hxx +++ b/include/tools/stream.hxx @@ -186,7 +186,6 @@ protected: virtual void FlushData(); virtual void SetSize(sal_uInt64 nSize); - void FlushBuffer(); SAL_DLLPRIVATE void ClearError(); SAL_DLLPRIVATE void ClearBuffer(); @@ -273,6 +272,9 @@ public: virtual sal_uInt64 TellEnd(); // length between current (Tell()) pos and end of stream sal_uInt64 remainingSize(); + /// If we have data in our internal buffers, write them out + void FlushBuffer(); + /// Call FlushBuffer() and then call flush on the underlying OS stream void Flush(); // next Tell() <= nSize bool SetStreamSize( sal_uInt64 nSize ); @@ -590,7 +592,6 @@ private: sal_uInt16 nLockCounter; #endif bool bIsOpen; - bool mbDontFlushOnClose; ///< used to avoid flushing when closing temporary files SvFileStream (const SvFileStream&) = delete; SvFileStream & operator= (const SvFileStream&) = delete; @@ -617,7 +618,6 @@ public: bool IsOpen() const { return bIsOpen; } const OUString& GetFileName() const { return aFilename; } - void SetDontFlushOnClose(bool b) { mbDontFlushOnClose = b; } }; // MemoryStream @@ -666,7 +666,7 @@ public: sal_uInt64 GetSize() { return TellEnd(); } std::size_t GetEndOfData() const { return nEndOfData; } - const void* GetData() { Flush(); return pBuf; } + const void* GetData() { FlushBuffer(); return pBuf; } // return the buffer currently in use, and allocate a new buffer internally void* SwitchBuffer(); diff --git a/lotuswordpro/source/filter/explode.cxx b/lotuswordpro/source/filter/explode.cxx index 4b4ffa25c6cf..a001254d0be4 100644 --- a/lotuswordpro/source/filter/explode.cxx +++ b/lotuswordpro/source/filter/explode.cxx @@ -307,7 +307,7 @@ sal_Int32 Decompression::explode() if (distance > nOutputPos) return -3; // format error - m_pOutStream->Flush(); + m_pOutStream->FlushBuffer(); // point back to copy position and read bytes m_pOutStream->SeekRel(-static_cast<tools::Long>(distance)); sal_uInt8 sTemp[MAXWIN]; diff --git a/sc/source/core/tool/autoform.cxx b/sc/source/core/tool/autoform.cxx index 07f8b5134569..55676816bc15 100644 --- a/sc/source/core/tool/autoform.cxx +++ b/sc/source/core/tool/autoform.cxx @@ -923,7 +923,7 @@ bool ScAutoFormat::Save() } } - rStream.Flush(); + rStream.FlushBuffer(); aMedium.Commit(); } diff --git a/sc/source/filter/excel/xechart.cxx b/sc/source/filter/excel/xechart.cxx index 089f578b3e10..78fe80cadc6f 100644 --- a/sc/source/filter/excel/xechart.cxx +++ b/sc/source/filter/excel/xechart.cxx @@ -714,7 +714,7 @@ void XclExpChEscherFormat::WriteBody( XclExpStream& rStrm ) // write Escher property container via temporary memory stream SvMemoryStream aMemStrm; maData.mxEscherSet->Commit( aMemStrm ); - aMemStrm.Flush(); + aMemStrm.FlushBuffer(); aMemStrm.Seek( STREAM_SEEK_TO_BEGIN ); rStrm.CopyFromStream( aMemStrm ); } diff --git a/sc/source/filter/excel/xestream.cxx b/sc/source/filter/excel/xestream.cxx index 17395145bbab..f8337b327930 100644 --- a/sc/source/filter/excel/xestream.cxx +++ b/sc/source/filter/excel/xestream.cxx @@ -104,7 +104,7 @@ XclExpStream::XclExpStream( SvStream& rOutStrm, const XclExpRoot& rRoot, sal_uIn XclExpStream::~XclExpStream() { - mrStrm.Flush(); + mrStrm.FlushBuffer(); } void XclExpStream::StartRecord( sal_uInt16 nRecId, std::size_t nRecSize ) diff --git a/sfx2/source/doc/docfile.cxx b/sfx2/source/doc/docfile.cxx index 588e349a2e5b..cfa203a85b44 100644 --- a/sfx2/source/doc/docfile.cxx +++ b/sfx2/source/doc/docfile.cxx @@ -829,9 +829,9 @@ bool SfxMedium::Commit() if( pImpl->xStorage.is() ) StorageCommit_Impl(); else if( pImpl->m_pOutStream ) - pImpl->m_pOutStream->Flush(); + pImpl->m_pOutStream->FlushBuffer(); else if( pImpl->m_pInStream ) - pImpl->m_pInStream->Flush(); + pImpl->m_pInStream->FlushBuffer(); if ( GetError() == ERRCODE_NONE ) { diff --git a/sfx2/source/doc/graphhelp.cxx b/sfx2/source/doc/graphhelp.cxx index 04b55df9c18c..dffb1bce163a 100644 --- a/sfx2/source/doc/graphhelp.cxx +++ b/sfx2/source/doc/graphhelp.cxx @@ -188,7 +188,7 @@ bool GraphicHelper::getThumbnailFormatFromBitmap_Impl(const BitmapEx& rBitmap, c if (rFilter.compressAsPNG(bitmap, *pStream) != ERRCODE_NONE) return false; - pStream->Flush(); + pStream->FlushBuffer(); return !pStream->GetError(); } diff --git a/sot/source/sdstor/storage.cxx b/sot/source/sdstor/storage.cxx index cef5b3d7a02d..0381aa477a9e 100644 --- a/sot/source/sdstor/storage.cxx +++ b/sot/source/sdstor/storage.cxx @@ -69,12 +69,12 @@ SotTempStream::SotTempStream( const OUString & rName, StreamMode nMode ) SotTempStream::~SotTempStream() { - Flush(); + FlushBuffer(); } void SotTempStream::CopyTo( SotTempStream * pDestStm ) { - Flush(); // write all data + FlushBuffer(); // write all data sal_uInt64 nPos = Tell(); // save position Seek( 0 ); diff --git a/svtools/qa/unit/testHtmlWriter.cxx b/svtools/qa/unit/testHtmlWriter.cxx index 7016b77257bb..d4c8e24e4390 100644 --- a/svtools/qa/unit/testHtmlWriter.cxx +++ b/svtools/qa/unit/testHtmlWriter.cxx @@ -20,7 +20,7 @@ namespace OString extractFromStream(SvMemoryStream& rStream) { rStream.WriteChar('\0'); - rStream.Flush(); + rStream.FlushBuffer(); rStream.Seek(STREAM_SEEK_TO_BEGIN); return static_cast<const char*>(rStream.GetData()); } diff --git a/sw/source/core/doc/tblafmt.cxx b/sw/source/core/doc/tblafmt.cxx index 6385794aa620..c92cadd49f50 100644 --- a/sw/source/core/doc/tblafmt.cxx +++ b/sw/source/core/doc/tblafmt.cxx @@ -1150,7 +1150,7 @@ bool SwTableAutoFormatTable::Save( SvStream& rStream ) const bRet = rFormat.Save(rStream, AUTOFORMAT_FILE_VERSION); } } - rStream.Flush(); + rStream.FlushBuffer(); return bRet; } diff --git a/sw/source/uibase/config/uinums.cxx b/sw/source/uibase/config/uinums.cxx index 70d01d01d746..71e68f558e57 100644 --- a/sw/source/uibase/config/uinums.cxx +++ b/sw/source/uibase/config/uinums.cxx @@ -61,7 +61,7 @@ void SwChapterNumRules::Save() { sw::ExportStoredChapterNumberingRules(*this, *pStream,CHAPTER_FILENAME); - pStream->Flush(); + pStream->FlushBuffer(); aMedium.Commit(); } diff --git a/tools/source/stream/stream.cxx b/tools/source/stream/stream.cxx index 016c8b67e891..a40e13d70b82 100644 --- a/tools/source/stream/stream.cxx +++ b/tools/source/stream/stream.cxx @@ -378,7 +378,7 @@ void SvStream::SetBufferSize( sal_uInt16 nBufferSize ) bool bDontSeek = (m_pRWBuf == nullptr); if (m_isDirty && m_isWritable) // due to Windows NT: Access denied - Flush(); + FlushBuffer(); if (m_nBufSize) { @@ -1546,7 +1546,7 @@ SvMemoryStream::~SvMemoryStream() if( bOwnsData ) FreeMemory(); else - Flush(); + FlushBuffer(); } } @@ -1754,7 +1754,7 @@ void SvMemoryStream::FreeMemory() void* SvMemoryStream::SwitchBuffer() { - Flush(); + FlushBuffer(); if( !bOwnsData ) return nullptr; Seek( STREAM_SEEK_TO_BEGIN ); diff --git a/tools/source/stream/strmunx.cxx b/tools/source/stream/strmunx.cxx index 9beade27e92e..d01866476f51 100644 --- a/tools/source/stream/strmunx.cxx +++ b/tools/source/stream/strmunx.cxx @@ -198,7 +198,6 @@ SvFileStream::SvFileStream( const OUString& rFileName, StreamMode nOpenMode ) { bIsOpen = false; m_isWritable = false; - mbDontFlushOnClose = false; pInstanceData.reset(new StreamData); SetBufferSize( 1024 ); @@ -216,7 +215,6 @@ SvFileStream::SvFileStream() { bIsOpen = false; m_isWritable = false; - mbDontFlushOnClose = false; pInstanceData.reset(new StreamData); SetBufferSize( 1024 ); } @@ -460,8 +458,7 @@ void SvFileStream::Close() if ( IsOpen() ) { SAL_INFO("tools", "Closing " << aFilename); - if ( !mbDontFlushOnClose ) - Flush(); + FlushBuffer(); osl_closeFile( pInstanceData->rHandle ); pInstanceData->rHandle = nullptr; } diff --git a/tools/source/stream/strmwnt.cxx b/tools/source/stream/strmwnt.cxx index c91628b55091..4ea9c7eb1d42 100644 --- a/tools/source/stream/strmwnt.cxx +++ b/tools/source/stream/strmwnt.cxx @@ -107,7 +107,6 @@ SvFileStream::SvFileStream( const OUString& rFileName, StreamMode nMode ) bIsOpen = false; nLockCounter = 0; m_isWritable = false; - mbDontFlushOnClose = false; pInstanceData.reset( new StreamData ); SetBufferSize( 8192 ); @@ -124,7 +123,6 @@ SvFileStream::SvFileStream() bIsOpen = false; nLockCounter = 0; m_isWritable = false; - mbDontFlushOnClose = false; pInstanceData.reset( new StreamData ); SetBufferSize( 8192 ); @@ -379,8 +377,7 @@ void SvFileStream::Close() nLockCounter = 1; UnlockFile(); } - if ( !mbDontFlushOnClose ) - Flush(); + FlushBuffer(); CloseHandle( pInstanceData->hFile ); } bIsOpen = false; diff --git a/unotools/source/streaming/streamwrap.cxx b/unotools/source/streaming/streamwrap.cxx index 9a9b53d1f1ec..ccd9b5033d2a 100644 --- a/unotools/source/streaming/streamwrap.cxx +++ b/unotools/source/streaming/streamwrap.cxx @@ -208,7 +208,7 @@ void SAL_CALL OOutputStreamWrapper::writeBytes(const css::uno::Sequence< sal_Int void SAL_CALL OOutputStreamWrapper::flush() { - rStream.Flush(); + rStream.FlushBuffer(); checkError(); } @@ -298,7 +298,7 @@ void SAL_CALL OStreamWrapper::writeBytes(const css::uno::Sequence< sal_Int8 >& a void SAL_CALL OStreamWrapper::flush() { - m_pSvStream->Flush(); + m_pSvStream->FlushBuffer(); if (m_pSvStream->GetError() != ERRCODE_NONE) throw css::io::NotConnectedException(OUString(),static_cast<css::uno::XWeak*>(this)); } diff --git a/unotools/source/ucbhelper/tempfile.cxx b/unotools/source/ucbhelper/tempfile.cxx index 02770fda8744..07889ffdab83 100644 --- a/unotools/source/ucbhelper/tempfile.cxx +++ b/unotools/source/ucbhelper/tempfile.cxx @@ -388,9 +388,6 @@ TempFile::~TempFile() if ( !bKillingFileEnabled ) return; - // if we're going to delete this file, no point in flushing it when closing - if (pStream && !aName.isEmpty()) - static_cast<SvFileStream*>(pStream.get())->SetDontFlushOnClose(true); pStream.reset(); if ( bIsDirectory ) { diff --git a/vcl/source/filter/graphicfilter.cxx b/vcl/source/filter/graphicfilter.cxx index e9fb9d73bafb..ae04ede2dacf 100644 --- a/vcl/source/filter/graphicfilter.cxx +++ b/vcl/source/filter/graphicfilter.cxx @@ -107,7 +107,7 @@ class ImpFilterOutputStream : public ::cppu::WeakImplHelper< css::io::XOutputStr virtual void SAL_CALL writeBytes( const css::uno::Sequence< sal_Int8 >& rData ) override { mrStm.WriteBytes(rData.getConstArray(), rData.getLength()); } virtual void SAL_CALL flush() override - { mrStm.Flush(); } + { mrStm.FlushBuffer(); } virtual void SAL_CALL closeOutput() override {} public: diff --git a/vcl/source/gdi/impgraph.cxx b/vcl/source/gdi/impgraph.cxx index b00eb31599fd..7fd24f419a95 100644 --- a/vcl/source/gdi/impgraph.cxx +++ b/vcl/source/gdi/impgraph.cxx @@ -1347,7 +1347,7 @@ bool ImpGraphic::swapOut() if (!xOutputStream->GetError() && swapOutContent(*xOutputStream)) { - xOutputStream->Flush(); + xOutputStream->FlushBuffer(); bResult = !xOutputStream->GetError(); } } |