diff options
Diffstat (limited to 'sw/source/filter/ww8/rtfsdrexport.cxx')
-rw-r--r-- | sw/source/filter/ww8/rtfsdrexport.cxx | 36 |
1 files changed, 36 insertions, 0 deletions
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 <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; @@ -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<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() { SAL_INFO("sw.rtf", OSL_THIS_FUNC); @@ -430,6 +464,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); |