From 32fa7e9208b2053d2ff7743b88b0c0edacb8a7e7 Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Sun, 5 Feb 2012 00:24:08 +0100 Subject: fdo#42656 fix RTF export of picture frame shape type --- sw/source/filter/ww8/rtfattributeoutput.cxx | 14 +++++------ sw/source/filter/ww8/rtfattributeoutput.hxx | 5 ++++ sw/source/filter/ww8/rtfsdrexport.cxx | 36 +++++++++++++++++++++++++++++ sw/source/filter/ww8/rtfsdrexport.hxx | 3 +++ 4 files changed, 51 insertions(+), 7 deletions(-) (limited to 'sw/source/filter/ww8') diff --git a/sw/source/filter/ww8/rtfattributeoutput.cxx b/sw/source/filter/ww8/rtfattributeoutput.cxx index 306eaa0ab2ef..8ae42ed12982 100644 --- a/sw/source/filter/ww8/rtfattributeoutput.cxx +++ b/sw/source/filter/ww8/rtfattributeoutput.cxx @@ -3138,7 +3138,7 @@ static bool StripMetafileHeader(const sal_uInt8 *&rpGraphicAry, unsigned long &r return false; } -static OString WriteHex(const sal_uInt8* pData, sal_uInt32 nSize, sal_uInt32 nLimit = 64) +OString RtfAttributeOutput::WriteHex(const sal_uInt8* pData, sal_uInt32 nSize, sal_uInt32 nLimit) { OStringBuffer aRet; @@ -3159,17 +3159,17 @@ static OString WriteHex(const sal_uInt8* pData, sal_uInt32 nSize, sal_uInt32 nLi return aRet.makeStringAndClear(); } -static OString WriteHex(sal_Int32 nNum) +OString RtfAttributeOutput::WriteHex(sal_Int32 nNum) { - return WriteHex((sal_uInt8*)&nNum, sizeof(sal_Int32)); + return RtfAttributeOutput::WriteHex((sal_uInt8*)&nNum, sizeof(sal_Int32)); } -static OString WriteHex(OString sString) +OString RtfAttributeOutput::WriteHex(OString sString) { OStringBuffer aRet; aRet.append(WriteHex(sString.getLength()+1)); - aRet.append(WriteHex((sal_uInt8*)sString.getStr(), sString.getLength()+1)); + aRet.append(RtfAttributeOutput::WriteHex((sal_uInt8*)sString.getStr(), sString.getLength()+1)); return aRet.makeStringAndClear(); } @@ -3252,7 +3252,7 @@ static OString ExportPICT( const SwFlyFrmFmt* pFlyFrmFmt, const Size &rOrig, con StripMetafileHeader(pGraphicAry, nSize); } aRet.append(RtfExport::sNewLine); - aRet.append(WriteHex(pGraphicAry, nSize)); + aRet.append(RtfAttributeOutput::WriteHex(pGraphicAry, nSize)); aRet.append('}'); } return aRet.makeStringAndClear(); @@ -3285,7 +3285,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(WriteHex(pNativeData, nNativeDataSize, 126)); + m_aRunText.append(RtfAttributeOutput::WriteHex(pNativeData, nNativeDataSize, 126)); m_aRunText.append(RtfExport::sNewLine); delete pStream; diff --git a/sw/source/filter/ww8/rtfattributeoutput.hxx b/sw/source/filter/ww8/rtfattributeoutput.hxx index c96de2c4c81d..8766c5a9e697 100644 --- a/sw/source/filter/ww8/rtfattributeoutput.hxx +++ b/sw/source/filter/ww8/rtfattributeoutput.hxx @@ -561,6 +561,11 @@ public: /// Font pitch. 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(sal_Int32 nNum); + static rtl::OString WriteHex(rtl::OString sString); }; #endif // _RTFATTRIBUTEOUTPUT_HXX_ diff --git a/sw/source/filter/ww8/rtfsdrexport.cxx b/sw/source/filter/ww8/rtfsdrexport.cxx index 71736977cf97..f0c8d6894f22 100644 --- a/sw/source/filter/ww8/rtfsdrexport.cxx +++ b/sw/source/filter/ww8/rtfsdrexport.cxx @@ -29,10 +29,13 @@ #include "rtfsdrexport.hxx" #include "rtfattributeoutput.hxx" +#include "rtfexportfilter.hxx" #include #include #include +#include +#include using rtl::OString; using rtl::OStringBuffer; @@ -422,6 +425,37 @@ void lcl_AppendSP( ::rtl::OStringBuffer& rRunText, const char cName[], const ::r .append('{').append(OOO_STRING_SVTOOLS_RTF_SV " ").append(rValue).append('}') .append('}'); } + +void RtfSdrExport::impl_writeGraphic() +{ + // Get the Graphic object from the Sdr one. + uno::Reference xShape = GetXShapeForSdrObject(const_cast(m_pSdrObject)); + uno::Reference xPropertySet(xShape, uno::UNO_QUERY); + OUString sGraphicURL; + xPropertySet->getPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("GraphicURL"))) >>= sGraphicURL; + OString aURLBS(OUStringToOString(sGraphicURL, RTL_TEXTENCODING_UTF8)); + const char aURLBegin[] = "vnd.sun.star.GraphicObject:"; + Graphic aGraphic = GraphicObject(aURLBS.copy(RTL_CONSTASCII_LENGTH(aURLBegin))).GetTransformedGraphic(); + + // Export it to a stream. + SvMemoryStream aStream; + GraphicConverter::Export(aStream, aGraphic, CVT_PNG); + aStream.Seek(STREAM_SEEK_TO_END); + sal_uInt32 nSize = aStream.Tell(); + const sal_uInt8* pGraphicAry = (sal_uInt8*)aStream.GetData(); + + Size aMapped(aGraphic.GetPrefSize()); + + // Add it to the properties. + OStringBuffer aBuf; + aBuf.append('{').append(OOO_STRING_SVTOOLS_RTF_PICT).append(OOO_STRING_SVTOOLS_RTF_PNGBLIP); + aBuf.append(OOO_STRING_SVTOOLS_RTF_PICW).append(sal_Int32(aMapped.Width())); + aBuf.append(OOO_STRING_SVTOOLS_RTF_PICH).append(sal_Int32(aMapped.Height())).append(RtfExport::sNewLine); + aBuf.append(RtfAttributeOutput::WriteHex(pGraphicAry, nSize)); + aBuf.append('}'); + m_aShapeProps.insert(std::pair(OString("pib"), aBuf.makeStringAndClear())); +} + sal_Int32 RtfSdrExport::StartShape() { SAL_INFO("sw.rtf", OSL_THIS_FUNC); @@ -430,6 +464,8 @@ sal_Int32 RtfSdrExport::StartShape() return -1; m_aShapeProps.insert(std::pair(OString("shapeType"), OString::valueOf(sal_Int32(m_nShapeType)))); + if (m_nShapeType == 75) + impl_writeGraphic(); m_rAttrOutput.RunText().append('{').append(OOO_STRING_SVTOOLS_RTF_SHP); m_rAttrOutput.RunText().append('{').append(OOO_STRING_SVTOOLS_RTF_IGNORE).append(OOO_STRING_SVTOOLS_RTF_SHPINST); diff --git a/sw/source/filter/ww8/rtfsdrexport.hxx b/sw/source/filter/ww8/rtfsdrexport.hxx index 5834a238561c..eb69aa15b0c6 100644 --- a/sw/source/filter/ww8/rtfsdrexport.hxx +++ b/sw/source/filter/ww8/rtfsdrexport.hxx @@ -105,6 +105,9 @@ private: void AddRectangleDimensions( rtl::OStringBuffer& rBuffer, const Rectangle& rRectangle ); void WriteOutliner(const OutlinerParaObject& rParaObj); + + /// Exports the pib property of the shape + void impl_writeGraphic(); }; #endif // _RTFSdrEXPORT_HXX_ -- cgit > LibreOffice 核心代码仓库文档基金会
summaryrefslogtreecommitdiff
AgeCommit message (Expand)Author