[Libreoffice-commits] core.git: sw/source

Miklos Vajna vmiklos at collabora.co.uk
Tue Mar 27 16:31:09 UTC 2018


 sw/source/filter/html/wrthtml.cxx |   20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)

New commits:
commit af69f27e812a0e86d256e36154ecef9aaf43a32a
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Tue Mar 27 17:25:47 2018 +0200

    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 at collabora.co.uk>
    Tested-by: Jenkins <ci at libreoffice.org>

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


More information about the Libreoffice-commits mailing list