diff options
author | Jim Raykowski <raykowj@gmail..com> | 2019-11-18 19:43:29 -0900 |
---|---|---|
committer | Jim Raykowski <raykowj@gmail.com> | 2019-11-20 22:50:33 +0100 |
commit | b8bbe9a3ca4758102ce6aa5d1e0fbb077eedbe64 (patch) | |
tree | 676b66ecc37c7b82a4515c2983d820ce5342f758 /sfx2/source | |
parent | 1906f3f2f7c39ea9a3e04f1081dbfc24a1de3212 (diff) |
tdf#128557 Add tooltips to styles lists
Change-Id: Ia8f00cd882c1c8c239b95de8e917ff317a6485e8
Reviewed-on: https://gerrit.libreoffice.org/83152
Tested-by: Jenkins
Reviewed-by: Jim Raykowski <raykowj@gmail.com>
Diffstat (limited to 'sfx2/source')
-rw-r--r-- | sfx2/source/dialog/templdlg.cxx | 47 | ||||
-rw-r--r-- | sfx2/source/inc/templdgi.hxx | 1 |
2 files changed, 48 insertions, 0 deletions
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. */ diff --git a/sfx2/source/inc/templdgi.hxx b/sfx2/source/inc/templdgi.hxx index 9ab64b0262a7..1981bb25101b 100644 --- a/sfx2/source/inc/templdgi.hxx +++ b/sfx2/source/inc/templdgi.hxx @@ -83,6 +83,7 @@ public: } virtual bool EventNotify( NotifyEvent& rNEvt ) override; + virtual void RequestHelp(const HelpEvent& rHEvt) override; }; |