[Libreoffice-commits] .: 2 commits - sw/source

Miklos Vajna vmiklos at kemper.freedesktop.org
Sun Feb 5 05:25:13 PST 2012


 sw/source/filter/ww8/rtfattributeoutput.cxx |   14 +++++-----
 sw/source/filter/ww8/rtfattributeoutput.hxx |    5 +++
 sw/source/filter/ww8/rtfsdrexport.cxx       |   39 ++++++++++++++++++++++++++++
 sw/source/filter/ww8/rtfsdrexport.hxx       |    3 ++
 4 files changed, 54 insertions(+), 7 deletions(-)

New commits:
commit 32fa7e9208b2053d2ff7743b88b0c0edacb8a7e7
Author: Miklos Vajna <vmiklos at frugalware.org>
Date:   Sun Feb 5 00:24:08 2012 +0100

    fdo#42656 fix RTF export of picture frame shape type

diff --git a/sw/source/filter/ww8/rtfattributeoutput.cxx b/sw/source/filter/ww8/rtfattributeoutput.cxx
index 306eaa0..8ae42ed 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 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 7173697..f0c8d68 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 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_
commit 5cab164402f43bde3693a42c77be07069f42e00f
Author: Miklos Vajna <vmiklos at frugalware.org>
Date:   Sat Feb 4 16:33:21 2012 +0100

    Related: fdo#42656 implement RTF export of fillType shape property

diff --git a/sw/source/filter/ww8/rtfsdrexport.cxx b/sw/source/filter/ww8/rtfsdrexport.cxx
index 99f6da1..7173697 100644
--- a/sw/source/filter/ww8/rtfsdrexport.cxx
+++ b/sw/source/filter/ww8/rtfsdrexport.cxx
@@ -362,6 +362,9 @@ void RtfSdrExport::Commit( EscherPropertyContainer& rProps, const Rectangle& rRe
             case ESCHER_Prop_txflTextFlow:
                 m_aShapeProps.insert(std::pair<OString,OString>(OString("txflTextFlow"), OString::valueOf(sal_Int32(it->nPropValue))));
                 break;
+            case ESCHER_Prop_fillType:
+                m_aShapeProps.insert(std::pair<OString,OString>(OString("fillType"), OString::valueOf(sal_Int32(it->nPropValue))));
+                break;
             default:
                 SAL_INFO("sw.rtf", OSL_THIS_FUNC << ": unhandled property: " << nId << " (value: " << it->nPropValue << ")");
                 break;


More information about the Libreoffice-commits mailing list