From b8bbe9a3ca4758102ce6aa5d1e0fbb077eedbe64 Mon Sep 17 00:00:00 2001 From: Jim Raykowski Date: Mon, 18 Nov 2019 19:43:29 -0900 Subject: tdf#128557 Add tooltips to styles lists Change-Id: Ia8f00cd882c1c8c239b95de8e917ff317a6485e8 Reviewed-on: https://gerrit.libreoffice.org/83152 Tested-by: Jenkins Reviewed-by: Jim Raykowski --- sfx2/source/dialog/templdlg.cxx | 47 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) (limited to 'sfx2/source/dialog') diff --git a/sfx2/source/dialog/templdlg.cxx b/sfx2/source/dialog/templdlg.cxx index 937c241008d9..8ebb054a2a8d 100644 --- a/sfx2/source/dialog/templdlg.cxx +++ b/sfx2/source/dialog/templdlg.cxx @@ -314,6 +314,53 @@ bool DropListBox_Impl::EventNotify( NotifyEvent& rNEvt ) return bRet; } +void DropListBox_Impl::RequestHelp(const HelpEvent& rHEvt) +{ + if (rHEvt.GetMode() & HelpEventMode::QUICK) + { + Point aPos(ScreenToOutputPixel(rHEvt.GetMousePosPixel())); + SvTreeListEntry* pEntry = GetEntry(aPos); + if (pEntry) + { + const OUString aTemplName(GetEntryText(pEntry)); + OUString sQuickHelpText(aTemplName); + + const SfxStyleFamilyItem* pItem = pDialog->GetFamilyItem_Impl(); + SfxStyleSheetBase* pStyle = pDialog->pStyleSheetPool->Find(aTemplName, pItem->GetFamily()); + + if (pStyle && pStyle->IsUsed()) // pStyle is in use in the document? + { + OUString sUsedBy; + if (pStyle->GetFamily() == SfxStyleFamily::Pseudo) + { + sUsedBy = pStyle->GetUsedBy(); + } + + if (!sUsedBy.isEmpty()) + { + const sal_Int32 nMaxLen = 80; + if (sUsedBy.getLength() > nMaxLen) + { + sUsedBy = sUsedBy.copy(0, nMaxLen) + "..."; + } + + OUString aMessage = SfxResId(STR_STYLEUSEDBY); + aMessage = aMessage.replaceFirst("%STYLELIST", sUsedBy); + sQuickHelpText = aTemplName + " " + aMessage; + } + } + + Size aSize(GetOutputSizePixel().Width(), GetEntryHeight()); + tools::Rectangle aScreenRect(OutputToScreenPixel(GetEntryPosition(pEntry)), aSize); + + Help::ShowQuickHelp(this, aScreenRect, + sQuickHelpText, QuickHelpFlags::Left | QuickHelpFlags::VCenter); + return; + } + } + SvTreeListBox::RequestHelp(rHEvt); +} + /** ListBox class that starts a PopupMenu (designer specific) in the command handler. */ -- cgit