summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJim Raykowski <raykowj@gmail..com>2019-11-18 19:43:29 -0900
committerJim Raykowski <raykowj@gmail.com>2019-11-20 22:50:33 +0100
commitb8bbe9a3ca4758102ce6aa5d1e0fbb077eedbe64 (patch)
tree676b66ecc37c7b82a4515c2983d820ce5342f758
parent1906f3f2f7c39ea9a3e04f1081dbfc24a1de3212 (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>
-rw-r--r--include/sfx2/strings.hrc2
-rw-r--r--include/svl/style.hxx2
-rw-r--r--sfx2/source/dialog/templdlg.cxx47
-rw-r--r--sfx2/source/inc/templdgi.hxx1
-rw-r--r--sw/inc/docstyle.hxx2
-rw-r--r--sw/inc/numrule.hxx1
-rw-r--r--sw/source/core/doc/number.cxx12
-rw-r--r--sw/source/uibase/app/docstyle.cxx5
8 files changed, 72 insertions, 0 deletions
diff --git a/include/sfx2/strings.hrc b/include/sfx2/strings.hrc
index d1196842d36c..52d24f048671 100644
--- a/include/sfx2/strings.hrc
+++ b/include/sfx2/strings.hrc
@@ -350,6 +350,8 @@
#define STR_CTRLCLICKHYPERLINK NC_("STR_CTRLCLICKHYPERLINK", "%{key}-click to open hyperlink: %{link}")
#define STR_CLICKHYPERLINK NC_("STR_CLICKHYPERLINK", "Click to open hyperlink: %{link}")
+
+#define STR_STYLEUSEDBY NC_("STR_STYLEUSEDBY", "(used by: %STYLELIST)")
#endif
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/svl/style.hxx b/include/svl/style.hxx
index 9ac7151f48d8..24656eb2318a 100644
--- a/include/svl/style.hxx
+++ b/include/svl/style.hxx
@@ -157,6 +157,8 @@ public:
virtual bool IsUsed() const; // Default true
virtual OUString GetDescription( MapUnit eMetric );
+ virtual OUString GetUsedBy() { return OUString(); }
+
SfxStyleSheetBasePool* GetPool() { return m_pPool; }
SfxStyleFamily GetFamily() const { return nFamily; }
SfxStyleSearchBits GetMask() const { return nMask; }
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;
};
diff --git a/sw/inc/docstyle.hxx b/sw/inc/docstyle.hxx
index 609cee5c9426..d3160b6e54a7 100644
--- a/sw/inc/docstyle.hxx
+++ b/sw/inc/docstyle.hxx
@@ -127,6 +127,8 @@ public:
virtual bool HasClearParentSupport() const override;
virtual OUString GetDescription(MapUnit eUnit) override;
+ virtual OUString GetUsedBy() override;
+
SwCharFormat* GetCharFormat();
SwTextFormatColl* GetCollection();
SwFrameFormat* GetFrameFormat();
diff --git a/sw/inc/numrule.hxx b/sw/inc/numrule.hxx
index 3702ce2b71bd..6152e6bee99f 100644
--- a/sw/inc/numrule.hxx
+++ b/sw/inc/numrule.hxx
@@ -172,6 +172,7 @@ public:
OUString MakeRefNumString( const SwNodeNum& rNodeNum,
const bool bInclSuperiorNumLabels,
const int nRestrictInclToThisLevel ) const;
+ OUString MakeParagraphStyleListString() const;
/** @return list of associated text nodes */
void GetTextNodeList( SwNumRule::tTextNodeList& rTextNodeList ) const;
diff --git a/sw/source/core/doc/number.cxx b/sw/source/core/doc/number.cxx
index e1a5af928d68..f57933440278 100644
--- a/sw/source/core/doc/number.cxx
+++ b/sw/source/core/doc/number.cxx
@@ -795,6 +795,18 @@ OUString SwNumRule::MakeRefNumString( const SwNodeNum& rNodeNum,
return aRefNumStr;
}
+OUString SwNumRule::MakeParagraphStyleListString() const
+{
+ OUString aParagraphStyleListString;
+ for (const auto& rParagraphStyle : maParagraphStyleList)
+ {
+ if (!aParagraphStyleListString.isEmpty())
+ aParagraphStyleListString += ", ";
+ aParagraphStyleListString += rParagraphStyle->GetName();
+ }
+ return aParagraphStyleListString;
+}
+
/** Copy method of SwNumRule
A kind of copy constructor, so that the num formats are attached to the
diff --git a/sw/source/uibase/app/docstyle.cxx b/sw/source/uibase/app/docstyle.cxx
index fae87682edf0..4326445cd8ec 100644
--- a/sw/source/uibase/app/docstyle.cxx
+++ b/sw/source/uibase/app/docstyle.cxx
@@ -2259,6 +2259,11 @@ bool SwDocStyleSheet::IsUsed() const
return rDoc.IsUsed( *pMod );
}
+OUString SwDocStyleSheet::GetUsedBy()
+{
+ return pNumRule ? pNumRule->MakeParagraphStyleListString() : OUString();
+}
+
sal_uLong SwDocStyleSheet::GetHelpId( OUString& rFile )
{
sal_uInt16 nId = 0;