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

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