summaryrefslogtreecommitdiff
path: root/sfx2
diff options
context:
space:
mode:
authorMichael Meeks <michael.meeks@collabora.com>2015-06-29 09:58:32 +0100
committerMichael Meeks <michael.meeks@collabora.com>2015-06-29 16:49:37 +0000
commit7e7525ac82772d61f3c223216a3297dadf5b1bef (patch)
tree3b4a0256f7c292594042f11d49e34f83c4ff96c5 /sfx2
parent98d2d985082114ec259c11788af7b8574f2c9b3d (diff)
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@libreoffice.org> Reviewed-by: Michael Meeks <michael.meeks@collabora.com> Tested-by: Michael Meeks <michael.meeks@collabora.com>
Diffstat (limited to 'sfx2')
-rw-r--r--sfx2/source/dialog/templdlg.cxx29
-rw-r--r--sfx2/source/inc/templdgi.hxx1
2 files changed, 23 insertions, 7 deletions
diff --git a/sfx2/source/dialog/templdlg.cxx b/sfx2/source/dialog/templdlg.cxx
index 9510ed381e8b..7ffcd10a8f5e 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 76e41684954c..5171cacab46e 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;