[Libreoffice-commits] .: writerfilter/source

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Fri Dec 28 06:54:40 PST 2012


 writerfilter/source/filter/RtfFilter.cxx |   21 ++++++++++++++++-----
 1 file changed, 16 insertions(+), 5 deletions(-)

New commits:
commit 53d335910f8843b3e9484fe481aa667ffe7b4485
Author: Miklos Vajna <vmiklos at suse.cz>
Date:   Fri Dec 28 15:49:25 2012 +0100

    fdo#45533 make it easier to debug RTF copy&paste
    
    Previously there was only a compile-time switch to dump contents of RTF
    paste. Remove this, and add two environment variables instead:
    
    - SW_DEBUG_RTF_PASTE_TO: to dump what would be pasted
    - SW_DEBUG_RTF_PASTE_FROM: to paste contents of a file, instead of the
      real clipboard
    
    Change-Id: I65f89417ec1cf781ace41df7916791f2199fe104

diff --git a/writerfilter/source/filter/RtfFilter.cxx b/writerfilter/source/filter/RtfFilter.cxx
index 7a0cea1..466afd6 100644
--- a/writerfilter/source/filter/RtfFilter.cxx
+++ b/writerfilter/source/filter/RtfFilter.cxx
@@ -30,11 +30,10 @@
 #include <com/sun/star/io/WrongFormatException.hpp>
 #include <com/sun/star/lang/WrappedTargetRuntimeException.hpp>
 #include <com/sun/star/text/XTextRange.hpp>
-#ifdef DBG_COPYPASTE
 #include <unotools/localfilehelper.hxx>
 #include <tools/stream.hxx>
 #include <unotools/ucbstreamhelper.hxx>
-#endif
+#include <unotools/streamwrap.hxx>
 
 using namespace ::rtl;
 using namespace ::cppu;
@@ -91,16 +90,28 @@ sal_Bool RtfFilter::filter( const uno::Sequence< beans::PropertyValue >& aDescri
         aMediaDesc.addInputStream();
         aMediaDesc[ MediaDescriptor::PROP_INPUTSTREAM() ] >>= xInputStream;
 
-#ifdef DBG_COPYPASTE
+        // If this is set, write to this file, instead of the real document during paste.
+        char* pEnv = getenv("SW_DEBUG_RTF_PASTE_TO");
         OUString aOutStr;
-        if (utl::LocalFileHelper::ConvertPhysicalNameToURL("/tmp/stream.rtf", aOutStr))
+        if (!bIsNewDoc && pEnv && utl::LocalFileHelper::ConvertPhysicalNameToURL(OStringToOUString(pEnv, RTL_TEXTENCODING_UTF8), aOutStr))
         {
             SvStream* pOut = utl::UcbStreamHelper::CreateStream(aOutStr, STREAM_WRITE);
             SvStream* pIn = utl::UcbStreamHelper::CreateStream(xInputStream);
             *pOut << *pIn;
             delete pOut;
+            return true;
+        }
+
+        // If this is set, read from this file, instead of the real clipboard during paste.
+        pEnv = getenv("SW_DEBUG_RTF_PASTE_FROM");
+        if (!bIsNewDoc && pEnv)
+        {
+            OUString aInStr;
+            utl::LocalFileHelper::ConvertPhysicalNameToURL(OStringToOUString(pEnv, RTL_TEXTENCODING_UTF8), aInStr);
+            SvStream* pStream = utl::UcbStreamHelper::CreateStream(aInStr, STREAM_READ);
+            uno::Reference<io::XStream> xStream(new utl::OStreamWrapper(*pStream));
+            xInputStream.set(xStream, uno::UNO_QUERY);
         }
-#endif
 
         uno::Reference<frame::XFrame> xFrame = aMediaDesc.getUnpackedValueOrDefault(MediaDescriptor::PROP_FRAME(),
                 uno::Reference<frame::XFrame>());


More information about the Libreoffice-commits mailing list