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(-)
New commits: commit d2e2e3817376787f1804ee808bd37cc99815799a Author: Michael Stahl <mst...@redhat.com> Date: Mon Feb 6 16:09:49 2012 +0100 RtfSdrExport::StartShape: replace "75" (cherry picked from commit 8411534883e960a8404d24937f813eb20accecdd) Signed-off-by: Michael Stahl <mst...@redhat.com> diff --git a/sw/source/filter/ww8/rtfsdrexport.cxx b/sw/source/filter/ww8/rtfsdrexport.cxx index 9ba99a4..e78d73c 100644 --- a/sw/source/filter/ww8/rtfsdrexport.cxx +++ b/sw/source/filter/ww8/rtfsdrexport.cxx @@ -480,7 +480,7 @@ sal_Int32 RtfSdrExport::StartShape() return -1; m_aShapeProps.insert(std::pair<OString,OString>(OString("shapeType"), OString::valueOf(sal_Int32(m_nShapeType)))); - if (m_nShapeType == 75) + if (ESCHER_ShpInst_PictureFrame == m_nShapeType) impl_writeGraphic(); m_rAttrOutput.RunText().append('{').append(OOO_STRING_SVTOOLS_RTF_SHP); commit ec0f75dffbdea7b508f1476fde90d1aeab6afde5 Author: Miklos Vajna <vmik...@frugalware.org> Date: Sun Feb 5 00:24:08 2012 +0100 fdo#42656 fix RTF export of picture frame shape type (cherry picked from commit 32fa7e9208b2053d2ff7743b88b0c0edacb8a7e7) Signed-off-by: Michael Stahl <mst...@redhat.com> diff --git a/sw/source/filter/ww8/rtfattributeoutput.cxx b/sw/source/filter/ww8/rtfattributeoutput.cxx index 9ade064..b66f84f 100644 --- a/sw/source/filter/ww8/rtfattributeoutput.cxx +++ b/sw/source/filter/ww8/rtfattributeoutput.cxx @@ -3139,7 +3139,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; @@ -3160,17 +3160,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(); } @@ -3253,7 +3253,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(); @@ -3286,7 +3286,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 c96de2c..8766c5a 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 badda4e..9ba99a4 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 <svtools/rtfkeywd.hxx> #include <editeng/editobj.hxx> #include <svx/svdotext.hxx> +#include <svx/unoapi.hxx> +#include <vcl/cvtgrf.hxx> using rtl::OString; using rtl::OStringBuffer; @@ -438,6 +441,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<drawing::XShape> xShape = GetXShapeForSdrObject(const_cast<SdrObject*>(m_pSdrObject)); + uno::Reference<beans::XPropertySet> 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,OString>(OString("pib"), aBuf.makeStringAndClear())); +} + sal_Int32 RtfSdrExport::StartShape() { OSL_TRACE("%s", OSL_THIS_FUNC); @@ -446,6 +480,8 @@ sal_Int32 RtfSdrExport::StartShape() return -1; m_aShapeProps.insert(std::pair<OString,OString>(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 5834a23..eb69aa1 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_ _______________________________________________ Libreoffice-commits mailing list Libreoffice-commits@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits