From 9b6e7eb1bad4344be0e766f4c05f0a3f28cb737d Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Mon, 5 Mar 2012 09:44:18 +0100 Subject: make ExportPICT() and WriteHex() be able to write to a stream --- sw/source/filter/ww8/rtfattributeoutput.cxx | 34 ++++++++++++++++++++++------- sw/source/filter/ww8/rtfattributeoutput.hxx | 2 +- 2 files changed, 27 insertions(+), 9 deletions(-) diff --git a/sw/source/filter/ww8/rtfattributeoutput.cxx b/sw/source/filter/ww8/rtfattributeoutput.cxx index ce72a1a027c3..eaf9ee313717 100644 --- a/sw/source/filter/ww8/rtfattributeoutput.cxx +++ b/sw/source/filter/ww8/rtfattributeoutput.cxx @@ -3160,7 +3160,7 @@ static bool StripMetafileHeader(const sal_uInt8 *&rpGraphicAry, unsigned long &r return false; } -OString RtfAttributeOutput::WriteHex(const sal_uInt8* pData, sal_uInt32 nSize, sal_uInt32 nLimit) +OString RtfAttributeOutput::WriteHex(const sal_uInt8* pData, sal_uInt32 nSize, SvStream* pStream, sal_uInt32 nLimit) { OStringBuffer aRet; @@ -3169,11 +3169,22 @@ OString RtfAttributeOutput::WriteHex(const sal_uInt8* pData, sal_uInt32 nSize, s { OString sNo = OString::valueOf(sal_Int32(pData[i]), 16); if (sNo.getLength() < 2) - aRet.append('0'); - aRet.append(sNo); + { + if (pStream) + (*pStream) << '0'; + else + aRet.append('0'); + } + if (pStream) + (*pStream) << sNo.getStr(); + else + aRet.append(sNo); if (++nBreak == nLimit) { - aRet.append(RtfExport::sNewLine); + if (pStream) + (*pStream) << RtfExport::sNewLine; + else + aRet.append(RtfExport::sNewLine); nBreak = 0; } } @@ -3212,7 +3223,7 @@ void lcl_AppendSP( OStringBuffer& rBuffer, static OString ExportPICT( const SwFlyFrmFmt* pFlyFrmFmt, const Size &rOrig, const Size &rRendered, const Size &rMapped, const SwCropGrf &rCr, const char *pBLIPType, const sal_uInt8 *pGraphicAry, - unsigned long nSize, const RtfExport& rExport ) + unsigned long nSize, const RtfExport& rExport, SvStream *pStream = 0 ) { OStringBuffer aRet; bool bIsWMF = std::strcmp(pBLIPType, OOO_STRING_SVTOOLS_RTF_WMETAFILE) == 0; @@ -3274,8 +3285,15 @@ static OString ExportPICT( const SwFlyFrmFmt* pFlyFrmFmt, const Size &rOrig, con StripMetafileHeader(pGraphicAry, nSize); } aRet.append(RtfExport::sNewLine); - aRet.append(RtfAttributeOutput::WriteHex(pGraphicAry, nSize)); + if (pStream) + (*pStream) << aRet.makeStringAndClear().getStr(); + if (pStream) + RtfAttributeOutput::WriteHex(pGraphicAry, nSize, pStream); + else + aRet.append(RtfAttributeOutput::WriteHex(pGraphicAry, nSize)); aRet.append('}'); + if (pStream) + (*pStream) << aRet.makeStringAndClear().getStr(); } return aRet.makeStringAndClear(); } @@ -3307,7 +3325,7 @@ void RtfAttributeOutput::FlyFrameOLEData( SwOLENode& rOLENode ) const sal_uInt8* pNativeData = (sal_uInt8*)pStream->GetData(); m_aRunText->append(WriteHex(nNativeDataSize)); m_aRunText->append(RtfExport::sNewLine); - m_aRunText->append(RtfAttributeOutput::WriteHex(pNativeData, nNativeDataSize, 126)); + m_aRunText->append(RtfAttributeOutput::WriteHex(pNativeData, nNativeDataSize, 0, 126)); m_aRunText->append(RtfExport::sNewLine); delete pStream; @@ -3319,7 +3337,7 @@ void RtfAttributeOutput::FlyFrameOLEData( SwOLENode& rOLENode ) pStream->Seek(STREAM_SEEK_TO_END); sal_uInt32 nPresentationDataSize = pStream->Tell(); const sal_uInt8* pPresentationData = (sal_uInt8*)pStream->GetData(); - m_aRunText->append(WriteHex(pPresentationData, nPresentationDataSize, 126)); + m_aRunText->append(WriteHex(pPresentationData, nPresentationDataSize, 0, 126)); } } diff --git a/sw/source/filter/ww8/rtfattributeoutput.hxx b/sw/source/filter/ww8/rtfattributeoutput.hxx index c9303572781c..4be68dbdc8b2 100644 --- a/sw/source/filter/ww8/rtfattributeoutput.hxx +++ b/sw/source/filter/ww8/rtfattributeoutput.hxx @@ -571,7 +571,7 @@ public: void FontPitchType( FontPitch ePitch ) const; /// Writes binary data as a hex dump. - static rtl::OString WriteHex(const sal_uInt8* pData, sal_uInt32 nSize, sal_uInt32 nLimit = 64); + static rtl::OString WriteHex(const sal_uInt8* pData, sal_uInt32 nSize, SvStream* pStream = 0, sal_uInt32 nLimit = 64); static rtl::OString WriteHex(sal_Int32 nNum); static rtl::OString WriteHex(rtl::OString sString); }; -- cgit v1.2.3