summaryrefslogtreecommitdiff
path: root/sw/source/filter/html/wrthtml.cxx
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.co.uk>2018-03-27 17:25:47 +0200
committerMiklos Vajna <vmiklos@collabora.co.uk>2018-03-27 18:30:23 +0200
commitaf69f27e812a0e86d256e36154ecef9aaf43a32a (patch)
tree976fa116cf4e64941ec406f8288490e9ad4dffe8 /sw/source/filter/html/wrthtml.cxx
parentf98040a273b14e8e3f4b7206d4e6c8b93dde262f (diff)
sw HTML paste: add debug env var to capture outgoing content
Similar to existing SW_DEBUG_RTF_PASTE_TO. Change-Id: I5d6fe72929ab6ddd3e6e175ed344781fc4e3cb31 Reviewed-on: https://gerrit.libreoffice.org/51961 Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk> Tested-by: Jenkins <ci@libreoffice.org>
Diffstat (limited to 'sw/source/filter/html/wrthtml.cxx')
-rw-r--r--sw/source/filter/html/wrthtml.cxx20
1 files changed, 20 insertions, 0 deletions
diff --git a/sw/source/filter/html/wrthtml.cxx b/sw/source/filter/html/wrthtml.cxx
index 5a01534ff141..5abdad007fe2 100644
--- a/sw/source/filter/html/wrthtml.cxx
+++ b/sw/source/filter/html/wrthtml.cxx
@@ -78,6 +78,8 @@
#include <IDocumentMarkAccess.hxx>
#include <xmloff/odffields.hxx>
#include <tools/urlobj.hxx>
+#include <osl/file.hxx>
+#include <comphelper/scopeguard.hxx>
#define MAX_INDENT_LEVEL 20
@@ -208,6 +210,24 @@ void SwHTMLWriter::SetupFilterOptions(SfxMedium& rMedium)
ErrCode SwHTMLWriter::WriteStream()
{
+ // Intercept paste output if requested.
+ char* pPasteEnv = getenv("SW_DEBUG_HTML_PASTE_TO");
+ std::unique_ptr<SvStream> pPasteStream;
+ SvStream* pOldPasteStream = nullptr;
+ if (pPasteEnv)
+ {
+ OUString aPasteStr;
+ if (pPasteEnv
+ && osl::FileBase::getFileURLFromSystemPath(OUString::fromUtf8(pPasteEnv), aPasteStr)
+ == osl::FileBase::E_None)
+ {
+ pPasteStream.reset(new SvFileStream(aPasteStr, StreamMode::WRITE));
+ pOldPasteStream = &Strm();
+ SetStream(pPasteStream.get());
+ }
+ }
+ comphelper::ScopeGuard g([this, pOldPasteStream] { this->SetStream(pOldPasteStream); });
+
SvxHtmlOptions& rHtmlOptions = SvxHtmlOptions::Get();
// font heights 1-7