diff options
author | Noel Grandin <noel@peralex.com> | 2014-04-14 11:50:33 +0200 |
---|---|---|
committer | Noel Grandin <noel@peralex.com> | 2014-04-15 09:02:32 +0200 |
commit | 8fbbd1bd988f0e886095e012c48d93b999773273 (patch) | |
tree | 5eec05a5492bd3e688dfb14065fdff4eb1f36633 | |
parent | 3edb4611b2314fa5c03e1b4f70c425d92c95ed16 (diff) |
fix hacked bool in SfxDispatcher::SetSlotFilter
The bEnable flag was being passed an extra value.
Make this explicit now using an enum.
Change-Id: I292aca44e8592c9f3c1497c24c41140c8c3b5452
-rw-r--r-- | include/sfx2/dispatch.hxx | 14 | ||||
-rw-r--r-- | sd/source/ui/docshell/docshell.cxx | 2 | ||||
-rw-r--r-- | sd/source/ui/slideshow/slideshowimpl.cxx | 2 | ||||
-rw-r--r-- | sfx2/source/control/dispatch.cxx | 33 | ||||
-rw-r--r-- | sw/source/core/uibase/uiview/view.cxx | 4 |
5 files changed, 32 insertions, 23 deletions
diff --git a/include/sfx2/dispatch.hxx b/include/sfx2/dispatch.hxx index 15b26f75abeb..ca6996b1cc1d 100644 --- a/include/sfx2/dispatch.hxx +++ b/include/sfx2/dispatch.hxx @@ -61,6 +61,14 @@ namespace com #define SFX_SHELL_PUSH 1 +enum SfxSlotFilterState +{ + SFX_SLOT_FILTER_DISABLED, + SFX_SLOT_FILTER_ENABLED, + // enabled even if ReadOnlyDoc + SFX_SLOT_FILTER_ENABLED_READONLY, +}; + class SFX2_DLLPUBLIC SfxDispatcher { @@ -158,8 +166,7 @@ public: void Flush(); void Lock( bool bLock ); bool IsLocked( sal_uInt16 nSID = 0 ) const; - // bEnable can be sal_True,sal_False, or 2(some kind of read-only override hack) - void SetSlotFilter( sal_Bool bEnable = sal_False, + void SetSlotFilter( SfxSlotFilterState nEnable = SFX_SLOT_FILTER_DISABLED, sal_uInt16 nCount = 0, const sal_uInt16 *pSIDs = 0 ); void HideUI( bool bHide = true ); @@ -180,8 +187,7 @@ public: bool bOwnShellsOnly, bool bModal, bool bRealSlot=true ); SAL_DLLPRIVATE void SetReadOnly_Impl( bool bOn ); SAL_DLLPRIVATE bool GetReadOnly_Impl() const; - // bEnable can be sal_True,sal_False, or 2(some kind of read-only override hack) - SAL_DLLPRIVATE sal_Bool IsSlotEnabledByFilter_Impl( sal_uInt16 nSID ) const; + SAL_DLLPRIVATE SfxSlotFilterState IsSlotEnabledByFilter_Impl( sal_uInt16 nSID ) const; SAL_DLLPRIVATE void SetQuietMode_Impl( bool bOn ); SAL_DLLPRIVATE bool IsReadOnlyShell_Impl( sal_uInt16 nShell ) const; SAL_DLLPRIVATE void RemoveShell_Impl( SfxShell& rShell ); diff --git a/sd/source/ui/docshell/docshell.cxx b/sd/source/ui/docshell/docshell.cxx index 8999bdf5cee4..7d250a4508b0 100644 --- a/sd/source/ui/docshell/docshell.cxx +++ b/sd/source/ui/docshell/docshell.cxx @@ -393,7 +393,7 @@ void DrawDocShell::ApplySlotFilter() const SfxDispatcher* pDispatcher = pTestViewShell->GetViewFrame()->GetDispatcher(); if( mpFilterSIDs ) - pDispatcher->SetSlotFilter( mbFilterEnable, mnFilterCount, mpFilterSIDs ); + pDispatcher->SetSlotFilter( mbFilterEnable ? SFX_SLOT_FILTER_ENABLED : SFX_SLOT_FILTER_DISABLED, mnFilterCount, mpFilterSIDs ); else pDispatcher->SetSlotFilter(); diff --git a/sd/source/ui/slideshow/slideshowimpl.cxx b/sd/source/ui/slideshow/slideshowimpl.cxx index 86574f86be98..f7dd911167e9 100644 --- a/sd/source/ui/slideshow/slideshowimpl.cxx +++ b/sd/source/ui/slideshow/slideshowimpl.cxx @@ -2744,7 +2744,7 @@ void SAL_CALL SlideshowImpl::activate() throw (RuntimeException, std::exception) if( pDispatcher ) { // filter all forbiden slots - pDispatcher->SetSlotFilter( true, sizeof(pAllowed) / sizeof(sal_uInt16), pAllowed ); + pDispatcher->SetSlotFilter( SFX_SLOT_FILTER_ENABLED, sizeof(pAllowed) / sizeof(sal_uInt16), pAllowed ); } if( getBindings() ) diff --git a/sfx2/source/control/dispatch.cxx b/sfx2/source/control/dispatch.cxx index 0eceb766971e..cd1a946fe2d7 100644 --- a/sfx2/source/control/dispatch.cxx +++ b/sfx2/source/control/dispatch.cxx @@ -133,8 +133,8 @@ struct SfxDispatcher_Impl bool bQuiet; // Only use parent dispatcher bool bModal; // Only slots from parent dispatcher - sal_Bool bFilterEnabling; // sal_True=filter enabled slots, - // 2==ReadOnlyDoc overturned + SfxSlotFilterState nFilterEnabling; // 1==filter enabled slots, + // 2==ReadOnlyDoc overturned sal_uInt16 nFilterCount; // Number of SIDs in pFilterSIDs const sal_uInt16* pFilterSIDs; // sorted Array of SIDs sal_uInt32 nDisableFlags; @@ -347,7 +347,7 @@ void SfxDispatcher::Construct_Impl( SfxDispatcher* pParent ) pImp->bQuiet = false; pImp->bModal = false; pImp->pInCallAliveFlag = 0; - pImp->bFilterEnabling = sal_False; + pImp->nFilterEnabling = SFX_SLOT_FILTER_DISABLED; pImp->nFilterCount = 0; pImp->pFilterSIDs = 0; pImp->nDisableFlags = 0; @@ -1730,11 +1730,11 @@ void SfxDispatcher::FlushImpl() void SfxDispatcher::SetSlotFilter ( // HACK(hier muss mal ein enum rein) ??? - sal_Bool bEnable, /* sal_True: + SfxSlotFilterState nEnable, /* 1==true: only enable specified slots, disable all other - sal_False: + 0==false: disable specified slots, first enable all other */ @@ -1780,7 +1780,7 @@ void SfxDispatcher::SetSlotFilter if ( pImp->pFilterSIDs ) pImp->pFilterSIDs = 0; - pImp->bFilterEnabling = bEnable; + pImp->nFilterEnabling = nEnable; pImp->nFilterCount = nCount; pImp->pFilterSIDs = pSIDs; @@ -1801,7 +1801,7 @@ SfxCompareSIDs_Impl( const void* pSmaller, const void* pBigger ) } -sal_Bool SfxDispatcher::IsSlotEnabledByFilter_Impl( sal_uInt16 nSID ) const +SfxSlotFilterState SfxDispatcher::IsSlotEnabledByFilter_Impl( sal_uInt16 nSID ) const /* [Description] @@ -1810,7 +1810,7 @@ sal_Bool SfxDispatcher::IsSlotEnabledByFilter_Impl( sal_uInt16 nSID ) const disabled by the Filter. [Return value] - sal_Bool 0 => disabled + int 0 => disabled 1 => enabled 2 => enabled even if ReadOnlyDoc */ @@ -1819,17 +1819,20 @@ sal_Bool SfxDispatcher::IsSlotEnabledByFilter_Impl( sal_uInt16 nSID ) const // no filter? if ( 0 == pImp->nFilterCount ) // => all SIDs allowed - return sal_True; + return SFX_SLOT_FILTER_ENABLED; // search bool bFound = 0 != bsearch( &nSID, pImp->pFilterSIDs, pImp->nFilterCount, sizeof(sal_uInt16), SfxCompareSIDs_Impl ); // even if ReadOnlyDoc - if ( 2 == pImp->bFilterEnabling ) - return bFound ? 2 : 1; + if ( SFX_SLOT_FILTER_ENABLED_READONLY == pImp->nFilterEnabling ) + return bFound ? SFX_SLOT_FILTER_ENABLED_READONLY : SFX_SLOT_FILTER_ENABLED; // Otherwise after Negative/Positive Filter - return pImp->bFilterEnabling ? bFound : !bFound; + else if ( SFX_SLOT_FILTER_ENABLED == pImp->nFilterEnabling ) + return bFound ? SFX_SLOT_FILTER_ENABLED : SFX_SLOT_FILTER_DISABLED; + else + return bFound ? SFX_SLOT_FILTER_DISABLED : SFX_SLOT_FILTER_ENABLED; } @@ -1955,11 +1958,11 @@ bool SfxDispatcher::_FindServer } // SID check against set filter - sal_uInt16 nSlotEnableMode=0; + SfxSlotFilterState nSlotEnableMode = SFX_SLOT_FILTER_DISABLED; if ( pImp->pFrame ) { nSlotEnableMode = IsSlotEnabledByFilter_Impl( nSlot ); - if ( 0 == nSlotEnableMode ) + if ( SFX_SLOT_FILTER_DISABLED == nSlotEnableMode ) return false; } @@ -1977,7 +1980,7 @@ bool SfxDispatcher::_FindServer return false; } - bool bReadOnly = ( 2 != nSlotEnableMode && pImp->bReadOnly ); + bool bReadOnly = ( SFX_SLOT_FILTER_ENABLED_READONLY != nSlotEnableMode && pImp->bReadOnly ); // search through all the shells of the chained dispatchers // from top to bottom diff --git a/sw/source/core/uibase/uiview/view.cxx b/sw/source/core/uibase/uiview/view.cxx index e13f9170554b..f9d28d8ec5e0 100644 --- a/sw/source/core/uibase/uiview/view.cxx +++ b/sw/source/core/uibase/uiview/view.cxx @@ -597,7 +597,7 @@ void SwView::_CheckReadonlyState() } if ( SFX_ITEM_DISABLED == eStateRO ) { - rDis.SetSlotFilter( sal_Bool(2), sizeof(aROIds)/sizeof(sal_uInt16), aROIds ); + rDis.SetSlotFilter( SFX_SLOT_FILTER_ENABLED_READONLY, sizeof(aROIds)/sizeof(sal_uInt16), aROIds ); bChgd = sal_True; } } @@ -612,7 +612,7 @@ void SwView::_CheckReadonlyState() qsort( (void*)aAllProtIds, sizeof(aAllProtIds)/sizeof(sal_uInt16), sizeof(sal_uInt16), lcl_CmpIds ); bAllProtFirst = sal_False; } - rDis.SetSlotFilter( sal_Bool(2), + rDis.SetSlotFilter( SFX_SLOT_FILTER_ENABLED_READONLY, sizeof(aAllProtIds)/sizeof(sal_uInt16), aAllProtIds ); bChgd = sal_True; |