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