From 53d335910f8843b3e9484fe481aa667ffe7b4485 Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Fri, 28 Dec 2012 15:49:25 +0100 Subject: 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 --- writerfilter/source/filter/RtfFilter.cxx | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/writerfilter/source/filter/RtfFilter.cxx b/writerfilter/source/filter/RtfFilter.cxx index 7a0cea1ba8d6..466afd672a62 100644 --- a/writerfilter/source/filter/RtfFilter.cxx +++ b/writerfilter/source/filter/RtfFilter.cxx @@ -30,11 +30,10 @@ #include #include #include -#ifdef DBG_COPYPASTE #include #include #include -#endif +#include 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 xStream(new utl::OStreamWrapper(*pStream)); + xInputStream.set(xStream, uno::UNO_QUERY); } -#endif uno::Reference xFrame = aMediaDesc.getUnpackedValueOrDefault(MediaDescriptor::PROP_FRAME(), uno::Reference()); -- cgit v1.2.3