summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@suse.cz>2012-12-28 15:49:25 +0100
committerMiklos Vajna <vmiklos@suse.cz>2012-12-28 15:54:24 +0100
commit53d335910f8843b3e9484fe481aa667ffe7b4485 (patch)
treeb02b1c28abd245fccc8753ebb5546bd98642c136
parentc1be14de66aebfa1ce18ff3872876042c9ad7b1e (diff)
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
-rw-r--r--writerfilter/source/filter/RtfFilter.cxx21
1 files 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 <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>());