[Libreoffice-commits] core.git: Branch 'libreoffice-6-4' - 2 commits - include/sfx2 include/svl sfx2/source sw/inc sw/source

Jim Raykowski (via logerrit) logerrit at kemper.freedesktop.org
Tue Nov 26 13:09:26 UTC 2019


 include/sfx2/strings.hrc          |    2 +
 include/svl/style.hxx             |    2 +
 sfx2/source/dialog/templdlg.cxx   |   63 ++++++++++++++++++++++++++++++--------
 sfx2/source/inc/templdgi.hxx      |    1 
 sw/inc/docstyle.hxx               |    2 +
 sw/inc/numrule.hxx                |    1 
 sw/source/core/doc/number.cxx     |   12 +++++++
 sw/source/uibase/app/docstyle.cxx |    5 +++
 8 files changed, 76 insertions(+), 12 deletions(-)

New commits:
commit 4613b32fc121f5f4e0e440837f94903ad361e89a
Author:     Jim Raykowski <raykowj at gmail..com>
AuthorDate: Mon Nov 18 19:43:29 2019 -0900
Commit:     Xisco Faulí <xiscofauli at libreoffice.org>
CommitDate: Tue Nov 26 14:08:40 2019 +0100

    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 at gmail.com>
    (cherry picked from commit b8bbe9a3ca4758102ce6aa5d1e0fbb077eedbe64)
    Reviewed-on: https://gerrit.libreoffice.org/83364
    Reviewed-by: Xisco Faulí <xiscofauli at libreoffice.org>

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 4710cd2c2aec..4347d9894298 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;
commit 9cbc55167301cefe9889ad8e604439e0118b627f
Author:     Jim Raykowski <raykowj at gmail..com>
AuthorDate: Sat Nov 16 23:41:26 2019 -0900
Commit:     Xisco Faulí <xiscofauli at libreoffice.org>
CommitDate: Tue Nov 26 14:08:30 2019 +0100

    tdf#128557 Only show delete menu item when custom style is not in use
    
    or it has a parent style so when a custom paragraph style is in use it
    can be deleted and the style will revert to the parent
    
    Change-Id: I0e4ff953835c105241d3bb027d24841afdccc7ba
    Reviewed-on: https://gerrit.libreoffice.org/83008
    Tested-by: Jenkins
    Reviewed-by: Jim Raykowski <raykowj at gmail.com>
    (cherry picked from commit 30c9bc76d0718f0c01d34f81845d88413645b42c)
    Reviewed-on: https://gerrit.libreoffice.org/83367
    Reviewed-by: Xisco Faulí <xiscofauli at libreoffice.org>

diff --git a/sfx2/source/dialog/templdlg.cxx b/sfx2/source/dialog/templdlg.cxx
index b4c8f4393e8d..4710cd2c2aec 100644
--- a/sfx2/source/dialog/templdlg.cxx
+++ b/sfx2/source/dialog/templdlg.cxx
@@ -1948,6 +1948,7 @@ void SfxCommonTemplateDialog_Impl::ShowHdl()
 
 void SfxCommonTemplateDialog_Impl::EnableDelete()
 {
+    bool bEnableDelete(false);
     if(IsInitialized() && HasSelectedStyle())
     {
         OSL_ENSURE(pStyleSheetPool, "No StyleSheetPool");
@@ -1963,19 +1964,10 @@ void SfxCommonTemplateDialog_Impl::EnableDelete()
             pStyleSheetPool->Find(aTemplName,eFam, pTreeBox->IsVisible()? SfxStyleSearchBits::All : nFilter);
 
         OSL_ENSURE(pStyle, "Style not found");
-        if(pStyle && pStyle->IsUserDefined())
-        {
-            EnableDel(true);
-        }
-        else
-        {
-            EnableDel(false);
-        }
-    }
-    else
-    {
-        EnableDel(false);
+        if (pStyle && pStyle->IsUserDefined() && (pStyle->HasParentSupport() || !pStyle->IsUsed()))
+            bEnableDelete = true;
     }
+    EnableDel(bEnableDelete);
 }
 
 IMPL_LINK_NOARG( SfxCommonTemplateDialog_Impl, TreeListApplyHdl, SvTreeListBox *, bool )


More information about the Libreoffice-commits mailing list