[Libreoffice-commits] core.git: sfx2/source

Michael Meeks michael.meeks at collabora.com
Mon Jun 29 09:50:03 PDT 2015


 sfx2/source/dialog/templdlg.cxx |   29 ++++++++++++++++++++++-------
 sfx2/source/inc/templdgi.hxx    |    1 +
 2 files changed, 23 insertions(+), 7 deletions(-)

New commits:
commit 7e7525ac82772d61f3c223216a3297dadf5b1bef
Author: Michael Meeks <michael.meeks at collabora.com>
Date:   Mon Jun 29 09:58:32 2015 +0100

    tdf#92047 - cleanup logic.
    
    There are still a truck-load of problems with watercan usability.
    
    Change-Id: Ic8a9cda070747b1887a292df89b0398bdad8ef8a
    Reviewed-on: https://gerrit.libreoffice.org/16565
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Michael Meeks <michael.meeks at collabora.com>
    Tested-by: Michael Meeks <michael.meeks at collabora.com>

diff --git a/sfx2/source/dialog/templdlg.cxx b/sfx2/source/dialog/templdlg.cxx
index 9510ed3..7ffcd10 100644
--- a/sfx2/source/dialog/templdlg.cxx
+++ b/sfx2/source/dialog/templdlg.cxx
@@ -933,6 +933,20 @@ SfxStyleSheetBase *SfxCommonTemplateDialog_Impl::GetSelectedStyle() const
     return pStyleSheetPool->Find( aTemplName, pItem->GetFamily(), SFXSTYLEBIT_ALL );
 }
 
+/**
+ * Is it safe to show the water-can / fill icon. If we've a
+ * hierarchical widget - we have only single select, otherwise
+ * we need to check if we have a multi-selection. We either have
+ * a pTreeBox showing or an aFmtLb (which we hide when not shown)
+ */
+bool SfxCommonTemplateDialog_Impl::IsSafeForWaterCan() const
+{
+    if ( pTreeBox.get() != NULL )
+        return pTreeBox->FirstSelected() != 0;
+    else
+        return aFmtLb->GetSelectionCount() == 1;
+}
+
 void SfxCommonTemplateDialog_Impl::SelectStyle(const OUString &rStr)
 {
     const SfxStyleFamilyItem* pItem = GetFamilyItem_Impl();
@@ -990,7 +1004,7 @@ void SfxCommonTemplateDialog_Impl::SelectStyle(const OUString &rStr)
                     aFmtLb->MakeVisible( pEntry );
                     aFmtLb->SelectAll(false);
                     aFmtLb->Select( pEntry );
-                    bWaterDisabled = !(pTreeBox || aFmtLb->GetSelectionCount() <= 1);
+                    bWaterDisabled = !IsSafeForWaterCan();
                     FmtSelectHdl( NULL );
                 }
             }
@@ -1257,11 +1271,11 @@ void SfxCommonTemplateDialog_Impl::UpdateStyles_Impl(sal_uInt16 nFlags)
 // Updated display: Watering the house
 void SfxCommonTemplateDialog_Impl::SetWaterCanState(const SfxBoolItem *pItem)
 {
-    bWaterDisabled =  pItem == 0;
+    bWaterDisabled = (pItem == 0);
 
     if(!bWaterDisabled)
         //make sure the watercan is only activated when there is (only) one selection
-        bWaterDisabled = !(pTreeBox || aFmtLb->GetSelectionCount() <= 1);
+        bWaterDisabled = !IsSafeForWaterCan();
 
     if(pItem && !bWaterDisabled)
     {
@@ -1269,10 +1283,12 @@ void SfxCommonTemplateDialog_Impl::SetWaterCanState(const SfxBoolItem *pItem)
         EnableItem( SID_STYLE_WATERCAN, true );
     }
     else
+    {
         if(!bWaterDisabled)
             EnableItem(SID_STYLE_WATERCAN, true);
         else
             EnableItem(SID_STYLE_WATERCAN, false);
+    }
 
 // Ignore while in watercan mode statusupdates
 
@@ -2150,12 +2166,11 @@ SfxStyleFamily SfxCommonTemplateDialog_Impl::GetActualFamily() const
 
 void SfxCommonTemplateDialog_Impl::EnableExample_Impl(sal_uInt16 nId, bool bEnable)
 {
+    bool bDisable = !bEnable || !IsSafeForWaterCan();
     if( nId == SID_STYLE_NEW_BY_EXAMPLE )
-    {
-        bNewByExampleDisabled = !(pTreeBox || aFmtLb->GetSelectionCount() <= 1) || !bEnable;
-    }
+        bNewByExampleDisabled = bDisable;
     else if( nId == SID_STYLE_UPDATE_BY_EXAMPLE )
-        bUpdateByExampleDisabled = !(pTreeBox || aFmtLb->GetSelectionCount() <= 1) || !bEnable;
+        bUpdateByExampleDisabled = bDisable;
 
     EnableItem(nId, bEnable);
 }
diff --git a/sfx2/source/inc/templdgi.hxx b/sfx2/source/inc/templdgi.hxx
index 76e4168..5171cac 100644
--- a/sfx2/source/inc/templdgi.hxx
+++ b/sfx2/source/inc/templdgi.hxx
@@ -266,6 +266,7 @@ protected:
     void FilterSelect( sal_uInt16 nFilterIdx, bool bForce = false );
     void SetFamilyState( sal_uInt16 nSlotId, const SfxTemplateItem* );
     void SetWaterCanState( const SfxBoolItem* pItem );
+    bool IsSafeForWaterCan() const;
 
     void SelectStyle( const OUString& rStyle );
     bool HasSelectedStyle() const;


More information about the Libreoffice-commits mailing list