libreoffice/SOURCES/0001-export-HYPERLINK-target-in-html-clipboard-export.patch
2021-10-08 12:59:29 +00:00

65 lines
2.2 KiB
Diff

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