summaryrefslogtreecommitdiff
path: root/sw/source/filter/ww8
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@frugalware.org>2012-02-05 00:24:08 +0100
committerMiklos Vajna <vmiklos@frugalware.org>2012-02-05 14:24:35 +0100
commit32fa7e9208b2053d2ff7743b88b0c0edacb8a7e7 (patch)
tree37dc022d1dab4dddc43f852807b6619e73a45d67 /sw/source/filter/ww8
parent5cab164402f43bde3693a42c77be07069f42e00f (diff)
fdo#42656 fix RTF export of picture frame shape type
Diffstat (limited to 'sw/source/filter/ww8')
-rw-r--r--sw/source/filter/ww8/rtfattributeoutput.cxx14
-rw-r--r--sw/source/filter/ww8/rtfattributeoutput.hxx5
-rw-r--r--sw/source/filter/ww8/rtfsdrexport.cxx36
-rw-r--r--sw/source/filter/ww8/rtfsdrexport.hxx3
4 files changed, 51 insertions, 7 deletions
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 <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);
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_