summaryrefslogtreecommitdiff
path: root/sw/source/core/fields/authfld.cxx
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.com>2021-02-11 16:37:00 +0100
committerMiklos Vajna <vmiklos@collabora.com>2021-02-11 18:50:08 +0100
commitb11db88d0174fbad25f7ee04726ae27ceb1488c3 (patch)
tree42166c5bfa038246b796d478c21f83eea4e4cb4f /sw/source/core/fields/authfld.cxx
parent8180bdc75c2bf3c1f813469eabd38db0612f1c91 (diff)
sw tooltip on bibliography fields: add the actual tooltip functionality
- Similar to e.g. SwMacroField::GetMacro(), add a new SwAuthorityField::GetAuthority() that returns a string which is similar to the one-liner text node in the bibliography table for a given bibliography reference. - Base this on the recently added SwAuthorityFieldType::CreateTOXInternational() and SwTOXAuthority::GetText() to share code with sw::ToxTextGenerator::GenerateText() and SwTOXBaseSection::Update(). - Finally extend SwEditWin::RequestHelp() to actually provide the tooltip on mouse hover. Change-Id: I33a58076c6d141566298259e7e4681541fac1055 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/110765 Reviewed-by: Miklos Vajna <vmiklos@collabora.com> Tested-by: Jenkins
Diffstat (limited to 'sw/source/core/fields/authfld.cxx')
-rw-r--r--sw/source/core/fields/authfld.cxx48
1 files changed, 48 insertions, 0 deletions
diff --git a/sw/source/core/fields/authfld.cxx b/sw/source/core/fields/authfld.cxx
index 53867c809673..4728e48fd60b 100644
--- a/sw/source/core/fields/authfld.cxx
+++ b/sw/source/core/fields/authfld.cxx
@@ -554,6 +554,54 @@ OUString SwAuthorityField::GetDescription() const
return SwResId(STR_AUTHORITY_ENTRY);
}
+OUString SwAuthorityField::GetAuthority(const SwTextAttr* pTextAttr,
+ const SwRootFrame* pLayout) const
+{
+ OUString aText;
+
+ SwForm aForm(TOX_AUTHORITIES);
+ if (!pTextAttr)
+ {
+ return aText;
+ }
+
+ auto& rFormatField = const_cast<SwFormatField&>(pTextAttr->GetFormatField());
+ SwTextField* pTextField = rFormatField.GetTextField();
+ if (!pTextField)
+ {
+ return aText;
+ }
+
+ const SwTextNode& rNode = pTextField->GetTextNode();
+ const auto pFieldType = static_cast<const SwAuthorityFieldType*>(GetTyp());
+ std::unique_ptr<SwTOXInternational> pIntl(pFieldType->CreateTOXInternational());
+ SwTOXAuthority aAuthority(rNode, rFormatField, *pIntl);
+ sal_uInt16 nLevel = aAuthority.GetLevel();
+ SwFormTokens aPattern = aForm.GetPattern(nLevel);
+ aAuthority.InitText(pLayout);
+ for (const auto& rToken : aPattern)
+ {
+ switch (rToken.eTokenType)
+ {
+ case TOKEN_TEXT:
+ {
+ aText += rToken.sText;
+ break;
+ }
+ case TOKEN_AUTHORITY:
+ {
+ sal_uInt16 eField = rToken.nAuthorityField;
+ aText += aAuthority.GetText(eField, pLayout);
+ break;
+ }
+ default:
+ break;
+ }
+ }
+
+ return aText;
+}
+
const char* const aFieldNames[] =
{
"Identifier",