sc/source/ui/docshell/impex.cxx |   17 ++++++++++++++++-
 1 file changed, 16 insertions(+), 1 deletion(-)

New commits:
commit 9f6b7af1a6f4f5b18dc9f8c8371ba579105665a3
Author:     Miklos Vajna <vmik...@collabora.com>
AuthorDate: Thu Jan 18 15:36:15 2024 +0100
Commit:     Miklos Vajna <vmik...@collabora.com>
CommitDate: Thu Jan 18 18:52:01 2024 +0100

    sc: add a debug env var to control the source of the HTML import
    
    Similar to the existing SW_DEBUG_RTF_PASTE_FROM environment variable.
    
    Change-Id: I20713d8701b5eb38554e016ae818f49226638ea8
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/162255
    Reviewed-by: Miklos Vajna <vmik...@collabora.com>
    Tested-by: Jenkins

diff --git a/sc/source/ui/docshell/impex.cxx b/sc/source/ui/docshell/impex.cxx
index 32bb5b36b20d..2d3abccefcca 100644
--- a/sc/source/ui/docshell/impex.cxx
+++ b/sc/source/ui/docshell/impex.cxx
@@ -73,6 +73,7 @@
 #include <unicode/uchar.h>
 
 #include <osl/endian.h>
+#include <osl/file.hxx>
 
 // We don't want to end up with 2GB read in one line just because of malformed
 // multiline fields, so chop it _somewhere_, which is twice supported columns
@@ -2569,7 +2570,21 @@ bool ScImportExport::HTML2Doc( SvStream& rStrm, const 
OUString& rBaseURL )
     std::unique_ptr<ScEEAbsImport> pImp = 
ScFormatFilter::Get().CreateHTMLImport( &rDoc, rBaseURL, aRange);
     if (!pImp)
         return false;
-    pImp->Read( rStrm, rBaseURL );
+
+    // If this is set, read from this file, instead of the real clipboard 
during paste.
+    char* pEnv = getenv("SC_DEBUG_HTML_PASTE_FROM");
+    if (pEnv)
+    {
+        OUString aURL;
+        osl::FileBase::getFileURLFromSystemPath(OUString::fromUtf8(pEnv), 
aURL);
+        SvFileStream aStream(aURL, StreamMode::READ);
+        pImp->Read( aStream, rBaseURL );
+    }
+    else
+    {
+        pImp->Read( rStrm, rBaseURL );
+    }
+
     aRange = pImp->GetRange();
 
     bool bOk = StartPaste();

Reply via email to