summaryrefslogtreecommitdiff
path: root/sfx2
diff options
context:
space:
mode:
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;