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

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