summaryrefslogtreecommitdiff
path: root/sw/source/core/tox/txmsrt.cxx
diff options
context:
space:
mode:
authorMichael Stahl <michael.stahl@allotropia.de>2021-01-28 19:59:35 +0100
committerMichael Stahl <michael.stahl@allotropia.de>2021-02-02 18:16:43 +0100
commit7685c0746cf0db6f51c6a7a488f4a960f8eab3c9 (patch)
tree9e68984782579ae58f685354b7f816a60f4807e9 /sw/source/core/tox/txmsrt.cxx
parenta2e533767bed88f293d2129aca9dfd9c4c60226b (diff)
tdf#121842 sw: add hyperlinks to toxmarks in ToC/User-Defined Index
The toxmark is identified by the type of index, the name of the index type (only for user-defined; there is only one ToC type), the text (either text:string-value or text content of the toxmark), and a counter to distinguish marks with the same text. Both text and type name can contain arbitrary characters so use U+0019 control character as separator. Links look like: #1%19text%19Utypename|toxmark Change-Id: I5aeec727e2cd3a02d676cf3ea4c302bf7c77d319 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/110091 Tested-by: Jenkins Reviewed-by: Michael Stahl <michael.stahl@allotropia.de>
Diffstat (limited to 'sw/source/core/tox/txmsrt.cxx')
-rw-r--r--sw/source/core/tox/txmsrt.cxx44
1 files changed, 35 insertions, 9 deletions
diff --git a/sw/source/core/tox/txmsrt.cxx b/sw/source/core/tox/txmsrt.cxx
index 7aefd76721a9..f626f09afc40 100644
--- a/sw/source/core/tox/txmsrt.cxx
+++ b/sw/source/core/tox/txmsrt.cxx
@@ -19,6 +19,7 @@
#include <unotools/charclass.hxx>
#include <osl/diagnose.h>
+#include <rtl/uri.hxx>
#include <txtfld.hxx>
#include <doc.hxx>
#include <IDocumentLayoutAccess.hxx>
@@ -179,9 +180,34 @@ SwTOXSortTabBase::SwTOXSortTabBase( TOXSortType nTyp, const SwContentNode* pNd,
}
}
-OUString SwTOXSortTabBase::GetURL() const
+std::pair<OUString, bool> SwTOXSortTabBase::GetURL(SwRootFrame const*const pLayout) const
{
- return OUString();
+ OUString typeName;
+ SwTOXType const& rType(*pTextMark->GetTOXMark().GetTOXType());
+ switch (rType.GetType())
+ {
+ case TOX_INDEX:
+ typeName = "A";
+ break;
+ case TOX_CONTENT:
+ typeName = "C";
+ break;
+ case TOX_USER:
+ typeName = "U" + rType.GetTypeName();
+ break;
+ default:
+ assert(false); // other tox can't have toxmarks as source
+ break;
+ }
+ OUString const decodedUrl( // counter will be added by caller!
+ OUStringChar(toxMarkSeparator) + pTextMark->GetTOXMark().GetText(pLayout)
+ + OUStringChar(toxMarkSeparator) + typeName
+ + OUStringChar(cMarkSeparator) + "toxmark" );
+
+ OUString const uri(rtl::Uri::encode(decodedUrl, rtl_UriCharClassUricNoSlash,
+ rtl_UriEncodeIgnoreEscapes, RTL_TEXTENCODING_UTF8));
+
+ return std::make_pair(uri, true);
}
bool SwTOXSortTabBase::IsFullPara() const
@@ -645,7 +671,7 @@ sal_uInt16 SwTOXPara::GetLevel() const
return nRet;
}
-OUString SwTOXPara::GetURL() const
+std::pair<OUString, bool> SwTOXPara::GetURL(SwRootFrame const*const) const
{
OUString aText;
const SwContentNode* pNd = aTOXSources[0].pNd;
@@ -696,7 +722,7 @@ OUString SwTOXPara::GetURL() const
break;
default: break;
}
- return aText;
+ return std::make_pair(aText, false);
}
bool SwTOXPara::IsFullPara() const
@@ -741,21 +767,21 @@ sal_uInt16 SwTOXTable::GetLevel() const
return nLevel;
}
-OUString SwTOXTable::GetURL() const
+std::pair<OUString, bool> SwTOXTable::GetURL(SwRootFrame const*const) const
{
const SwNode* pNd = aTOXSources[0].pNd;
if (!pNd)
- return OUString();
+ return std::make_pair(OUString(), false);
pNd = pNd->FindTableNode();
if (!pNd)
- return OUString();
+ return std::make_pair(OUString(), false);
const OUString sName = static_cast<const SwTableNode*>(pNd)->GetTable().GetFrameFormat()->GetName();
if ( sName.isEmpty() )
- return OUString();
+ return std::make_pair(OUString(), false);
- return "#" + sName + OUStringChar(cMarkSeparator) + "table";
+ return std::make_pair("#" + sName + OUStringChar(cMarkSeparator) + "table", false);
}
SwTOXAuthority::SwTOXAuthority( const SwContentNode& rNd,