Blame SOURCES/0001-export-HYPERLINK-target-in-html-clipboard-export.patch

2654e0
From 13aba101eadfe4f67a930ac7231d26ece658bbec Mon Sep 17 00:00:00 2001
2654e0
From: =?UTF-8?q?Caol=C3=A1n=20McNamara?= <caolanm@redhat.com>
2654e0
Date: Mon, 28 Sep 2020 14:55:47 +0100
2654e0
Subject: [PATCH] export HYPERLINK target in html clipboard export
2654e0
2654e0
Change-Id: Ia77e4bd8a5b54636d0e9e561360128202a81420b
2654e0
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/103557
2654e0
Tested-by: Jenkins
2654e0
Reviewed-by: Eike Rathke <erack@redhat.com>
2654e0
---
2654e0
 sc/source/filter/html/htmlexp.cxx | 23 +++++++++++++++++++++++
2654e0
 1 file changed, 23 insertions(+)
2654e0
2654e0
diff --git a/sc/source/filter/html/htmlexp.cxx b/sc/source/filter/html/htmlexp.cxx
2654e0
index 6122c9b6c45c..13792201c8b0 100644
2654e0
--- a/sc/source/filter/html/htmlexp.cxx
2654e0
+++ b/sc/source/filter/html/htmlexp.cxx
2654e0
@@ -37,6 +37,7 @@
2654e0
 #include <sfx2/docfile.hxx>
2654e0
 #include <sfx2/frmhtmlw.hxx>
2654e0
 #include <sfx2/objsh.hxx>
2654e0
+#include <svl/stritem.hxx>
2654e0
 #include <svl/urihelper.hxx>
2654e0
 #include <svtools/htmlkywd.hxx>
2654e0
 #include <svtools/htmlout.hxx>
2654e0
@@ -1127,6 +1128,26 @@ void ScHTMLExport::WriteCell( sc::ColumnBlockPosition& rBlockPos, SCCOL nCol, SC
2654e0
         TAG_ON(aStr.makeStringAndClear().getStr());
2654e0
     }
2654e0
 
2654e0
+    OUString aURL;
2654e0
+    bool bWriteHyperLink(false);
2654e0
+    if (aCell.meType == CELLTYPE_FORMULA)
2654e0
+    {
2654e0
+        ScFormulaCell* pFCell = aCell.mpFormula;
2654e0
+        if (pFCell->IsHyperLinkCell())
2654e0
+        {
2654e0
+            OUString aCellText;
2654e0
+            pFCell->GetURLResult(aURL, aCellText);
2654e0
+            bWriteHyperLink = true;
2654e0
+        }
2654e0
+    }
2654e0
+
2654e0
+    if (bWriteHyperLink)
2654e0
+    {
2654e0
+        OString aURLStr = HTMLOutFuncs::ConvertStringToHTML(aURL, eDestEnc, &aNonConvertibleChars);
2654e0
+        OString aStr = OOO_STRING_SVTOOLS_HTML_anchor " " OOO_STRING_SVTOOLS_HTML_O_href "=\"" + aURLStr + "\"";
2654e0
+        TAG_ON(aStr.getStr());
2654e0
+    }
2654e0
+
2654e0
     OUString aStrOut;
2654e0
     bool bFieldText = false;
2654e0
 
2654e0
@@ -1174,6 +1195,8 @@ void ScHTMLExport::WriteCell( sc::ColumnBlockPosition& rBlockPos, SCCOL nCol, SC
2654e0
     if ( pGraphEntry )
2654e0
         WriteGraphEntry( pGraphEntry );
2654e0
 
2654e0
+    if (bWriteHyperLink) { TAG_OFF(OOO_STRING_SVTOOLS_HTML_anchor); }
2654e0
+
2654e0
     if ( bSetFont )     TAG_OFF( OOO_STRING_SVTOOLS_HTML_font );
2654e0
     if ( bCrossedOut )  TAG_OFF( OOO_STRING_SVTOOLS_HTML_strikethrough );
2654e0
     if ( bUnderline )   TAG_OFF( OOO_STRING_SVTOOLS_HTML_underline );
2654e0
-- 
2654e0
2.26.2
2654e0